Skip "loom." prefix from hostname
This commit is contained in:
parent
28517c2000
commit
3da9e27190
@ -13,13 +13,16 @@
|
||||
static void
|
||||
set_hostname(char host[PATH_MAX], const char name[PATH_MAX])
|
||||
{
|
||||
/* Skip prefix */
|
||||
const char *start = name + strlen("loom.");
|
||||
|
||||
/* Copy until dot or end */
|
||||
int i;
|
||||
for (i = 0; i < PATH_MAX - 1; i++) {
|
||||
if (name[i] == '.' || name[i] == '\0')
|
||||
if (start[i] == '.' || start[i] == '\0')
|
||||
break;
|
||||
|
||||
host[i] = name[i];
|
||||
host[i] = start[i];
|
||||
}
|
||||
|
||||
host[i] = '\0';
|
||||
|
@ -34,6 +34,18 @@ test_bad_name(struct loom *loom)
|
||||
err("ok");
|
||||
}
|
||||
|
||||
static void
|
||||
test_hostname(struct loom *loom)
|
||||
{
|
||||
if (loom_init_begin(loom, "loom.node1.blah") != 0)
|
||||
die("loom_init_begin failed");
|
||||
|
||||
if (strcmp(loom->hostname, "node1") != 0)
|
||||
die("wrong hostname: %s", loom->hostname);
|
||||
|
||||
err("ok");
|
||||
}
|
||||
|
||||
static void
|
||||
test_negative_cpu(struct loom *loom)
|
||||
{
|
||||
@ -125,6 +137,7 @@ int main(void)
|
||||
struct loom loom;
|
||||
|
||||
test_bad_name(&loom);
|
||||
test_hostname(&loom);
|
||||
test_negative_cpu(&loom);
|
||||
test_duplicate_cpus(&loom);
|
||||
//test_sort_cpus(&loom);
|
||||
|
Loading…
Reference in New Issue
Block a user