Support sethostname() and gethostname()

This commit is contained in:
Sebastian Huber
2014-10-24 09:46:53 +02:00
parent feffbc2894
commit 54ed53794b
5 changed files with 96 additions and 0 deletions

View File

@@ -1714,6 +1714,25 @@ test_syslog(void)
syslog(LOG_DEBUG, "debug");
}
static void
test_setgethostname(void)
{
int rv;
char out[] = { 'f', 'o', 'o', 'b', 'a', 'r' };
char in[] = { '?', '?', '?', '?', '?', '?', '?' };
puts("test set/get hostname");
rv = sethostname(&out[0], sizeof(out));
assert(rv == 0);
rv = gethostname(&in[0], sizeof(in));
assert(rv == 0);
assert(memcmp(&in[0], &out[0], sizeof(in) - 1) == 0);
assert(in[sizeof(in) - 1] == '\0');
}
static void
test_main(void)
{
@@ -1744,6 +1763,7 @@ test_main(void)
test_warn();
test_err();
test_syslog();
test_setgethostname();
exit(0);
}