Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 10 Oct 2014 19:18:53 +0000 (UTC)
From:      Garrett Cooper <ngie@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r272905 - head/contrib/netbsd-tests/lib/libc/gen
Message-ID:  <201410101918.s9AJIrLW045154@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ngie
Date: Fri Oct 10 19:18:52 2014
New Revision: 272905
URL: https://svnweb.freebsd.org/changeset/base/272905

Log:
  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

Modified:
  head/contrib/netbsd-tests/lib/libc/gen/t_setdomainname.c
  head/contrib/netbsd-tests/lib/libc/gen/t_sethostname.c

Modified: head/contrib/netbsd-tests/lib/libc/gen/t_setdomainname.c
==============================================================================
--- head/contrib/netbsd-tests/lib/libc/gen/t_setdomainname.c	Fri Oct 10 19:12:04 2014	(r272904)
+++ head/contrib/netbsd-tests/lib/libc/gen/t_setdomainname.c	Fri Oct 10 19:18:52 2014	(r272905)
@@ -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);
 }
 

Modified: head/contrib/netbsd-tests/lib/libc/gen/t_sethostname.c
==============================================================================
--- head/contrib/netbsd-tests/lib/libc/gen/t_sethostname.c	Fri Oct 10 19:12:04 2014	(r272904)
+++ head/contrib/netbsd-tests/lib/libc/gen/t_sethostname.c	Fri Oct 10 19:18:52 2014	(r272905)
@@ -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));
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201410101918.s9AJIrLW045154>