aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEnji Cooper <ngie@FreeBSD.org>2014-10-10 19:18:52 +0000
committerEnji Cooper <ngie@FreeBSD.org>2014-10-10 19:18:52 +0000
commit4cf97cc9d2d73dddc11b1915f4eb12a4906c9f41 (patch)
tree76c8d856e36250a97111129003b14d6c27d05bb2
parent97dc3d98cbeb598bd49dd3603cde75e0dc8d128b (diff)
downloadsrc-4cf97cc9d2d73dddc11b1915f4eb12a4906c9f41.tar.gz
src-4cf97cc9d2d73dddc11b1915f4eb12a4906c9f41.zip
FreeBSD doesn't support strings greater than MAXHOSTNAMELEN-1 in
{get,set}{domain,host}name. Adjust the tests to not exceed that value when testing out the code Add a positive and negative test for MAXHOSTNAMELEN-1 and MAXHOSTNAMELEN, respectively PR: 181127 In collaboration with: pho Sponsored by: EMC / Isilon Storage Division
Notes
Notes: svn path=/head/; revision=272905
-rw-r--r--contrib/netbsd-tests/lib/libc/gen/t_setdomainname.c16
-rw-r--r--contrib/netbsd-tests/lib/libc/gen/t_sethostname.c16
2 files changed, 32 insertions, 0 deletions
diff --git a/contrib/netbsd-tests/lib/libc/gen/t_setdomainname.c b/contrib/netbsd-tests/lib/libc/gen/t_setdomainname.c
index 89818f083083..a93083a17f69 100644
--- a/contrib/netbsd-tests/lib/libc/gen/t_setdomainname.c
+++ b/contrib/netbsd-tests/lib/libc/gen/t_setdomainname.c
@@ -63,8 +63,20 @@ ATF_TC_BODY(setdomainname_basic, tc)
(void)memset(name, 0, sizeof(name));
+#if defined(__FreeBSD__)
+ /*
+ * Sanity checks to ensure that the wrong invariant isn't being
+ * tested for per PR # 181127
+ */
+ ATF_REQUIRE_EQ(sizeof(domains[i]), MAXHOSTNAMELEN);
+ ATF_REQUIRE_EQ(sizeof(name), MAXHOSTNAMELEN);
+
+ ATF_REQUIRE(setdomainname(domains[i],sizeof(domains[i]) - 1) == 0);
+ ATF_REQUIRE(getdomainname(name, sizeof(name) - 1) == 0);
+#else
ATF_REQUIRE(setdomainname(domains[i],sizeof(domains[i])) == 0);
ATF_REQUIRE(getdomainname(name, sizeof(name)) == 0);
+#endif
ATF_REQUIRE(strcmp(domains[i], name) == 0);
}
@@ -89,6 +101,10 @@ ATF_TC_BODY(setdomainname_limit, tc)
(void)memset(name, 0, sizeof(name));
+#if defined(__FreeBSD__)
+ ATF_REQUIRE(setdomainname(name, MAXHOSTNAMELEN - 1 ) == 0);
+ ATF_REQUIRE(setdomainname(name, MAXHOSTNAMELEN) == -1);
+#endif
ATF_REQUIRE(setdomainname(name, sizeof(name)) == -1);
}
diff --git a/contrib/netbsd-tests/lib/libc/gen/t_sethostname.c b/contrib/netbsd-tests/lib/libc/gen/t_sethostname.c
index a753ac7b0331..9c5abac32a35 100644
--- a/contrib/netbsd-tests/lib/libc/gen/t_sethostname.c
+++ b/contrib/netbsd-tests/lib/libc/gen/t_sethostname.c
@@ -63,8 +63,20 @@ ATF_TC_BODY(sethostname_basic, tc)
(void)memset(name, 0, sizeof(name));
+#if defined(__FreeBSD__)
+ /*
+ * Sanity checks to ensure that the wrong invariant isn't being
+ * tested for per PR # 181127
+ */
+ ATF_REQUIRE_EQ(sizeof(hosts[i]), MAXHOSTNAMELEN);
+ ATF_REQUIRE_EQ(sizeof(name), MAXHOSTNAMELEN);
+
+ ATF_REQUIRE(sethostname(hosts[i], sizeof(hosts[i]) - 1) == 0);
+ ATF_REQUIRE(gethostname(name, sizeof(name) - 1) == 0);
+#else
ATF_REQUIRE(sethostname(hosts[i], sizeof(hosts[i])) == 0);
ATF_REQUIRE(gethostname(name, sizeof(name)) == 0);
+#endif
ATF_REQUIRE(strcmp(hosts[i], name) == 0);
}
@@ -94,6 +106,10 @@ ATF_TC_BODY(sethostname_limit, tc)
ATF_TC_CLEANUP(sethostname_limit, tc)
{
+#if defined(__FreeBSD__)
+ ATF_REQUIRE(sethostname(host, MAXHOSTNAMELEN - 1 ) == 0);
+ ATF_REQUIRE(sethostname(host, MAXHOSTNAMELEN) == -1);
+#endif
(void)sethostname(host, sizeof(host));
}