[SCM] NSS Wrapper Repository - branch master updated

Andreas Schneider asn at samba.org
Fri Sep 11 07:22:19 UTC 2015


The branch, master has been updated
       via  5c5416b TESTS: Add assertions to tests.
       via  6b595ed TESTS: Switch tests to new CMocka API.
       via  e9e3f5a TESTS: Fix some memory leaks in testsuite.
       via  1769600 nwrap: Use ssize_t for aliases_count
       via  ef45548 nwrap: Prevent compilation failure on machine without IPv4
       via  24dcc9c nwrap: Replace free() calls by SAFE_FREE macro where possible.
       via  119e807 cmake: Add compilation flags
       via  6bac1f7 cmake: Add detection of -fstack-protector-strong compiler flag
      from  1b57476 cmake: Drop test results via https.

https://git.samba.org/?p=nss_wrapper.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 5c5416bcfe45bec2fb2899ae55eb1e0cbf824284
Author: Robin Hack <hack.robin at gmail.com>
Date:   Tue Mar 24 11:59:53 2015 +0100

    TESTS: Add assertions to tests.
    
    When function returns NULL then test raise assert fail istead of
    SIGSEGV now.
    
    Signed-off-by: Robin Hack <hack.robin at gmail.com>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit 6b595ed65bf40dfb6ed2ccf9443aaf82ea799f39
Author: Robin Hack <hack.robin at gmail.com>
Date:   Wed Mar 25 11:30:35 2015 +0100

    TESTS: Switch tests to new CMocka API.
    
    Signed-off-by: Robin Hack <hack.robin at gmail.com>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit e9e3f5a6795c307a80907643897f13591b8aeeba
Author: Robin Hack <hack.robin at gmail.com>
Date:   Tue Mar 24 12:02:24 2015 +0100

    TESTS: Fix some memory leaks in testsuite.
    
    Signed-off-by: Robin Hack <hack.robin at gmail.com>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit 1769600bfff87e266dab666e568eb146a1d4e5c9
Author: Robin Hack <hack.robin at gmail.com>
Date:   Wed Jul 15 15:00:02 2015 +0200

    nwrap: Use ssize_t for aliases_count
    
    Signed-off-by: Robin Hack <hack.robin at gmail.com>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit ef45548ef6dc45647e0b93baf46b38bd70d9e638
Author: Robin Hack <hack.robin at gmail.com>
Date:   Wed Mar 25 09:36:10 2015 +0100

    nwrap: Prevent compilation failure on machine without IPv4
    
    Signed-off-by: Robin Hack <hack.robin at gmail.com>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit 24dcc9c5179aeb08d8b0ed43c4c3b607b9dc6b2c
Author: Robin Hack <hack.robin at gmail.com>
Date:   Sat Nov 29 13:22:46 2014 +0100

    nwrap: Replace free() calls by SAFE_FREE macro where possible.
    
    Signed-off-by: Robin Hack <hack.robin at gmail.com>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit 119e8070783142613534b8e3cf77348e44abc108
Author: Robin Hack <hack.robin at gmail.com>
Date:   Wed Mar 25 12:50:16 2015 +0100

    cmake: Add compilation flags
    
    Flags added:
        -Wbad-function-cast
        -fstrict-aliasing
        -Wstrict-aliasing=3
    
    Signed-off-by: Robin Hack <hack.robin at gmail.com>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit 6bac1f7e6b250c391f13ee233063d36fba7652e0
Author: Robin Hack <hack.robin at gmail.com>
Date:   Wed Mar 25 12:34:53 2015 +0100

    cmake: Add detection of -fstack-protector-strong compiler flag
    
    Signed-off-by: Robin Hack <hack.robin at gmail.com>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

-----------------------------------------------------------------------

Summary of changes:
 cmake/Modules/DefineCompilerFlags.cmake | 21 ++++++++++---
 src/nss_wrapper.c                       | 48 +++++++++++++----------------
 tests/test_getaddrinfo.c                | 42 +++++++++++++++++--------
 tests/test_gethostby_name_addr.c        | 29 ++++++++++++------
 tests/test_gethostent.c                 |  6 ++--
 tests/test_getnameinfo.c                | 16 +++++-----
 tests/test_nwrap_disabled.c             | 12 ++++----
 tests/testsuite.c                       | 54 ++++++++++++++-------------------
 8 files changed, 126 insertions(+), 102 deletions(-)


Changeset truncated at 500 lines:

diff --git a/cmake/Modules/DefineCompilerFlags.cmake b/cmake/Modules/DefineCompilerFlags.cmake
index 0ab8802..111b2f4 100644
--- a/cmake/Modules/DefineCompilerFlags.cmake
+++ b/cmake/Modules/DefineCompilerFlags.cmake
@@ -13,7 +13,13 @@ if (UNIX AND NOT WIN32)
         set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -pedantic -pedantic-errors")
         set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wshadow -Wmissing-prototypes -Wdeclaration-after-statement")
         set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wunused -Wfloat-equal -Wpointer-arith -Wwrite-strings -Wformat-security")
-        set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wmissing-format-attribute")
+	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wmissing-format-attribute -fstrict-aliasing -Wbad-function-cast")
+
+	# check -Wstrict-aliasing support
+	check_c_compiler_flag("-Wstrict-aliasing=3" WITH_WSTRICT_ALIASING)
+	if (WITH_WSTRICT_ALIASING)
+            set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wstrict-aliasing=3")
+	endif (WITH_WSTRICT_ALIASING)
 
         # with -fPIC
         check_c_compiler_flag("-fPIC" WITH_FPIC)
@@ -21,10 +27,15 @@ if (UNIX AND NOT WIN32)
             set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
         endif (WITH_FPIC)
 
-        check_c_compiler_flag_ssp("-fstack-protector" WITH_STACK_PROTECTOR)
-        if (WITH_STACK_PROTECTOR)
-            set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fstack-protector")
-        endif (WITH_STACK_PROTECTOR)
+	check_c_compiler_flag_ssp("-fstack-protector-strong" WITH_STACK_PROTECTOR_STRONG)
+	if (WITH_STACK_PROTECTOR_STRONG)
+            set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fstack-protector-strong")
+        else (!WITH_STACK_PROTECTOR_STRONG)
+	    check_c_compiler_flag_ssp("-fstack-protector" WITH_STACK_PROTECTOR)
+	    if (WITH_STACK_PROTECTOR)
+	        set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fstack-protector")
+	    endif (WITH_STACK_PROTECTOR)
+	endif (WITH_STACK_PROTECTOR_STRONG)
 
         if (CMAKE_BUILD_TYPE)
             string(TOLOWER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_LOWER)
diff --git a/src/nss_wrapper.c b/src/nss_wrapper.c
index 28c23d8..2abbc24 100644
--- a/src/nss_wrapper.c
+++ b/src/nss_wrapper.c
@@ -140,6 +140,16 @@ typedef nss_status_t NSS_STATUS;
 
 #define ZERO_STRUCTP(x) do { if ((x) != NULL) memset((char *)(x), 0, sizeof(*(x))); } while(0)
 
+#ifndef SAFE_FREE
+#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); (x)=NULL;} } while(0)
+#endif
+
+#ifdef HAVE_IPV6
+#define NWRAP_INET_ADDRSTRLEN INET6_ADDRSTRLEN
+#else
+#define NWRAP_INET_ADDRSTRLEN INET_ADDRSTRLEN
+#endif
+
 enum nwrap_dbglvl_e {
 	NWRAP_LOG_ERROR = 0,
 	NWRAP_LOG_WARN,
@@ -1078,8 +1088,7 @@ static void *nwrap_load_module_fn(struct nwrap_backend *b,
 			  "Cannot find function %s in %s",
 			  s, b->so_path);
 	}
-	free(s);
-	s = NULL;
+	SAFE_FREE(s);
 	return res;
 }
 
@@ -1380,7 +1389,7 @@ done:
 	return true;
 
 failed:
-	if (buf) free(buf);
+	SAFE_FREE(buf);
 	return false;
 }
 
@@ -1388,9 +1397,7 @@ static void nwrap_files_cache_unload(struct nwrap_cache *nwrap)
 {
 	nwrap->unload(nwrap);
 
-	if (nwrap->buf) free(nwrap->buf);
-
-	nwrap->buf = NULL;
+	SAFE_FREE(nwrap->buf);
 }
 
 static void nwrap_files_cache_reload(struct nwrap_cache *nwrap)
@@ -1626,9 +1633,7 @@ static void nwrap_pw_unload(struct nwrap_cache *nwrap)
 	struct nwrap_pw *nwrap_pw;
 	nwrap_pw = (struct nwrap_pw *)nwrap->private_data;
 
-	if (nwrap_pw->list) free(nwrap_pw->list);
-
-	nwrap_pw->list = NULL;
+	SAFE_FREE(nwrap_pw->list);
 	nwrap_pw->num = 0;
 	nwrap_pw->idx = 0;
 }
@@ -1813,14 +1818,11 @@ static void nwrap_gr_unload(struct nwrap_cache *nwrap)
 
 	if (nwrap_gr->list) {
 		for (i=0; i < nwrap_gr->num; i++) {
-			if (nwrap_gr->list[i].gr_mem) {
-				free(nwrap_gr->list[i].gr_mem);
-			}
+			SAFE_FREE(nwrap_gr->list[i].gr_mem);
 		}
-		free(nwrap_gr->list);
+		SAFE_FREE(nwrap_gr->list);
 	}
 
-	nwrap_gr->list = NULL;
 	nwrap_gr->num = 0;
 	nwrap_gr->idx = 0;
 }
@@ -1884,7 +1886,7 @@ static bool nwrap_he_parse_line(struct nwrap_cache *nwrap, char *line)
 	struct nwrap_entdata *ed;
 	size_t list_size;
 	bool do_aliases = true;
-	int aliases_count = 0;
+	ssize_t aliases_count = 0;
 	char *p;
 	char *i;
 	char *n;
@@ -2044,17 +2046,12 @@ static void nwrap_he_unload(struct nwrap_cache *nwrap)
 
 	if (nwrap_he->list != NULL) {
 		for (i = 0; i < nwrap_he->num; i++) {
-			if (nwrap_he->list[i].ht.h_aliases != NULL) {
-				free(nwrap_he->list[i].ht.h_aliases);
-			}
-			if (nwrap_he->list[i].addr != NULL) {
-				free(nwrap_he->list[i].addr);
-			}
+			SAFE_FREE(nwrap_he->list[i].ht.h_aliases);
+			SAFE_FREE(nwrap_he->list[i].addr);
 		}
-		free(nwrap_he->list);
+		SAFE_FREE(nwrap_he->list);
 	}
 
-	nwrap_he->list = NULL;
 	nwrap_he->num = 0;
 	nwrap_he->idx = 0;
 }
@@ -2448,7 +2445,7 @@ static struct hostent *nwrap_files_gethostbyaddr(const void *addr,
 						 socklen_t len, int type)
 {
 	struct hostent *he;
-	char ip[INET6_ADDRSTRLEN] = {0};
+	char ip[NWRAP_INET_ADDRSTRLEN] = {0};
 	const char *a;
 	int i;
 
@@ -2550,9 +2547,6 @@ static void nwrap_files_endhostent(void)
  * module backend
  */
 
-#ifndef SAFE_FREE
-#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); (x)=NULL;} } while(0)
-#endif
 
 static struct passwd *nwrap_module_getpwnam(struct nwrap_backend *b,
 					    const char *name)
diff --git a/tests/test_getaddrinfo.c b/tests/test_getaddrinfo.c
index 492913b..5489102 100644
--- a/tests/test_getaddrinfo.c
+++ b/tests/test_getaddrinfo.c
@@ -17,7 +17,7 @@
 static void test_nwrap_getaddrinfo(void **state)
 {
 	struct addrinfo hints;
-	struct addrinfo *res;
+	struct addrinfo *res = NULL;
 	struct sockaddr_in *sinp;
 	struct sockaddr_in6 *sin6p;
 	char ip6[INET6_ADDRSTRLEN];
@@ -38,6 +38,7 @@ static void test_nwrap_getaddrinfo(void **state)
 
 	rc = getaddrinfo("127.0.0.11", NULL, &hints, &res);
 	assert_int_equal(rc, 0);
+	assert_non_null(res);
 
 	assert_non_null(res->ai_canonname);
 	assert_string_equal(res->ai_canonname, "magrathea.galaxy.site");
@@ -52,6 +53,7 @@ static void test_nwrap_getaddrinfo(void **state)
 	assert_string_equal(ip, "127.0.0.11");
 
 	freeaddrinfo(res);
+	res = NULL;
 
 	memset(&hints, 0, sizeof(struct addrinfo));
 	hints.ai_family = AF_UNSPEC;    /* Allow IPv4 or IPv6 */
@@ -63,6 +65,7 @@ static void test_nwrap_getaddrinfo(void **state)
 	hints.ai_next = NULL;
 
 	rc = getaddrinfo("::13", NULL, &hints, &res);
+	assert_non_null(res);
 	assert_int_equal(rc, 0);
 
 	assert_non_null(res->ai_canonname);
@@ -83,7 +86,7 @@ static void test_nwrap_getaddrinfo(void **state)
 static void test_nwrap_getaddrinfo_any(void **state)
 {
 	struct addrinfo hints;
-	struct addrinfo *res;
+	struct addrinfo *res = NULL;
 	struct sockaddr_in *sinp;
 	struct sockaddr_in6 *sin6p;
 	char ip6[INET6_ADDRSTRLEN];
@@ -100,6 +103,7 @@ static void test_nwrap_getaddrinfo_any(void **state)
 
 	rc = getaddrinfo("0.0.0.0", "389", &hints, &res);
 	assert_int_equal(rc, 0);
+	assert_non_null(res);
 
 	assert_int_equal(res->ai_family, AF_INET);
 	assert_int_equal(res->ai_socktype, SOCK_STREAM);
@@ -115,6 +119,7 @@ static void test_nwrap_getaddrinfo_any(void **state)
 	assert_string_equal(ip, "0.0.0.0");
 
 	freeaddrinfo(res);
+	res = NULL;
 
 	/* IPv4 */
 	memset(&hints, 0, sizeof(struct addrinfo));
@@ -124,6 +129,7 @@ static void test_nwrap_getaddrinfo_any(void **state)
 
 	rc = getaddrinfo("::", "389", &hints, &res);
 	assert_int_equal(rc, 0);
+	assert_non_null(res);
 
 	assert_int_equal(res->ai_family, AF_INET6);
 	assert_int_equal(res->ai_socktype, SOCK_STREAM);
@@ -191,7 +197,9 @@ static void test_nwrap_getaddrinfo_name(void **state)
 
 	rc = getaddrinfo("maximegalon.galaxy.site", NULL, &hints, &res);
 	assert_int_equal(rc, 0);
+	assert_non_null(res);
 
+	assert_non_null(res);
 	assert_int_equal(res->ai_family, AF_INET);
 	assert_int_equal(res->ai_socktype, SOCK_STREAM);
 
@@ -204,6 +212,7 @@ static void test_nwrap_getaddrinfo_name(void **state)
 	assert_string_equal(ip, "127.0.0.12");
 
 	freeaddrinfo(res);
+	res = NULL;
 
 	/* IPv4 */
 	memset(&hints, 0, sizeof(struct addrinfo));
@@ -214,6 +223,7 @@ static void test_nwrap_getaddrinfo_name(void **state)
 	rc = getaddrinfo("MAGRATHEA", NULL, &hints, &res);
 	assert_int_equal(rc, 0);
 
+	assert_non_null(res);
 	assert_int_equal(res->ai_family, AF_INET);
 	assert_int_equal(res->ai_socktype, SOCK_STREAM);
 
@@ -250,6 +260,7 @@ static void test_nwrap_getaddrinfo_service(void **state)
 	/* Check ldap port */
 	rc = getaddrinfo("magrathea", "ldap", &hints, &res);
 	assert_int_equal(rc, 0);
+	assert_non_null(res);
 
 	assert_int_equal(res->ai_family, AF_INET);
 	assert_int_equal(res->ai_socktype, SOCK_STREAM);
@@ -257,6 +268,7 @@ static void test_nwrap_getaddrinfo_service(void **state)
 	assert_non_null(res->ai_canonname);
 	assert_string_equal(res->ai_canonname, "magrathea.galaxy.site");
 
+	assert_non_null(res->ai_addr);
 	sinp = (struct sockaddr_in *)res->ai_addr;
 	ip = inet_ntoa(sinp->sin_addr);
 
@@ -290,20 +302,24 @@ static void test_nwrap_getaddrinfo_null(void **state)
 	rc = getaddrinfo(NULL, "domain", &hints, &res);
 	assert_int_equal(rc, 0);
 
+	assert_non_null(res);
 	assert_null(res->ai_canonname);
 
 	assert_int_equal(res->ai_family, AF_INET6);
 	assert_int_equal(res->ai_socktype, SOCK_DGRAM);
 
+	assert_non_null(res->ai_addr);
 	sin6p = (struct sockaddr_in6 *)res->ai_addr;
 	inet_ntop(AF_INET6, (void *)&sin6p->sin6_addr, ip6, sizeof(ip6));
 
 	assert_string_equal(ip6, "::1");
 
 	freeaddrinfo(res);
+	res = NULL;
 
 	/* Check dns service */
 	rc = getaddrinfo("magrathea", "domain", NULL, &res);
+	assert_non_null(res);
 	assert_int_equal(rc, 0);
 
 	assert_non_null(res->ai_canonname);
@@ -326,6 +342,7 @@ static void test_nwrap_getaddrinfo_dot(void **state)
 	/* Check with a dot at the end */
 	rc = getaddrinfo("magrathea.galaxy.site.", NULL, &hints, &res);
 	assert_int_equal(rc, 0);
+	assert_non_null(res);
 
 	assert_non_null(res->ai_next);
 	assert_int_equal(res->ai_family, AF_INET);
@@ -358,6 +375,7 @@ static void test_nwrap_getaddrinfo_ipv6(void **state)
 
 	rc = getaddrinfo("krikkit.galaxy.site", NULL, &hints, &res);
 	assert_int_equal(rc, 0);
+	assert_non_null(res);
 
 	assert_non_null(res->ai_next);
 	assert_int_equal(res->ai_family, AF_INET6);
@@ -374,18 +392,18 @@ static void test_nwrap_getaddrinfo_ipv6(void **state)
 int main(void) {
 	int rc;
 
-	const UnitTest tests[] = {
-		unit_test(test_nwrap_getaddrinfo),
-		unit_test(test_nwrap_getaddrinfo_any),
-		unit_test(test_nwrap_getaddrinfo_local),
-		unit_test(test_nwrap_getaddrinfo_name),
-		unit_test(test_nwrap_getaddrinfo_service),
-		unit_test(test_nwrap_getaddrinfo_null),
-		unit_test(test_nwrap_getaddrinfo_dot),
-		unit_test(test_nwrap_getaddrinfo_ipv6),
+	const struct CMUnitTest tests[] = {
+		cmocka_unit_test(test_nwrap_getaddrinfo),
+		cmocka_unit_test(test_nwrap_getaddrinfo_any),
+		cmocka_unit_test(test_nwrap_getaddrinfo_local),
+		cmocka_unit_test(test_nwrap_getaddrinfo_name),
+		cmocka_unit_test(test_nwrap_getaddrinfo_service),
+		cmocka_unit_test(test_nwrap_getaddrinfo_null),
+		cmocka_unit_test(test_nwrap_getaddrinfo_dot),
+		cmocka_unit_test(test_nwrap_getaddrinfo_ipv6),
 	};
 
-	rc = run_tests(tests);
+	rc = cmocka_run_group_tests(tests, NULL, NULL);
 
 	return rc;
 }
diff --git a/tests/test_gethostby_name_addr.c b/tests/test_gethostby_name_addr.c
index bfc8437..b9ae603 100644
--- a/tests/test_gethostby_name_addr.c
+++ b/tests/test_gethostby_name_addr.c
@@ -59,6 +59,8 @@ static void test_nwrap_gethostbyname(void **state)
 
 	he = gethostbyname("magrathea.galaxy.site");
 	assert_non_null(he);
+	assert_non_null(he->h_name);
+	assert_non_null(he->h_addr_list);
 
 	assert_string_equal(he->h_name, "magrathea.galaxy.site");
 	assert_int_equal(he->h_addrtype, AF_INET);
@@ -84,10 +86,11 @@ static void test_nwrap_gethostbyname2(void **state)
 	he = gethostbyname2("magrathea.galaxy.site", AF_INET);
 	assert_non_null(he);
 
-
 	/* Check ipv6 he */
 	he = gethostbyname2("krikkit.galaxy.site", AF_INET6);
 	assert_non_null(he);
+	assert_non_null(he->h_name);
+	assert_non_null(he->h_addr_list);
 
 	assert_string_equal(he->h_name, "krikkit.galaxy.site");
 	assert_int_equal(he->h_addrtype, AF_INET6);
@@ -100,6 +103,8 @@ static void test_nwrap_gethostbyname2(void **state)
 	/* Check ipv4 he */
 	he = gethostbyname2("krikkit.galaxy.site", AF_INET);
 	assert_non_null(he);
+	assert_non_null(he->h_name);
+	assert_non_null(he->h_addr_list);
 
 	assert_string_equal(he->h_name, "krikkit.galaxy.site");
 	assert_int_equal(he->h_addrtype, AF_INET);
@@ -124,6 +129,8 @@ static void test_nwrap_gethostbyaddr(void **state)
 
 	he = gethostbyaddr(&in, sizeof(struct in_addr), AF_INET);
 	assert_non_null(he);
+	assert_non_null(he->h_name);
+	assert_non_null(he->h_addr_list);
 
 	assert_string_equal(he->h_name, "magrathea.galaxy.site");
 	assert_int_equal(he->h_addrtype, AF_INET);
@@ -149,6 +156,8 @@ static void test_nwrap_gethostbyname_r(void **state)
 			     &herr);
 	assert_int_equal(rc, 0);
 	assert_non_null(he);
+	assert_non_null(he->h_name);
+	assert_non_null(he->h_addr_list);
 
 	assert_string_equal(he->h_name, "magrathea.galaxy.site");
 	assert_int_equal(he->h_addrtype, AF_INET);
@@ -182,6 +191,8 @@ static void test_nwrap_gethostbyaddr_r(void **state)
 			     &herr);
 	assert_int_equal(rc, 0);
 	assert_non_null(he);
+	assert_non_null(he->h_name);
+	assert_non_null(he->h_addr_list);
 
 	assert_string_equal(he->h_name, "magrathea.galaxy.site");
 	assert_int_equal(he->h_addrtype, AF_INET);
@@ -192,22 +203,22 @@ static void test_nwrap_gethostbyaddr_r(void **state)
 int main(void) {
 	int rc;
 
-	const UnitTest tests[] = {
-		unit_test(test_nwrap_gethostname),
-		unit_test(test_nwrap_gethostbyname),
+	const struct CMUnitTest tests[] = {
+		cmocka_unit_test(test_nwrap_gethostname),
+		cmocka_unit_test(test_nwrap_gethostbyname),
 #ifdef HAVE_GETHOSTBYNAME2
-		unit_test(test_nwrap_gethostbyname2),
+		cmocka_unit_test(test_nwrap_gethostbyname2),
 #endif
-		unit_test(test_nwrap_gethostbyaddr),
+		cmocka_unit_test(test_nwrap_gethostbyaddr),
 #ifdef HAVE_GETHOSTBYNAME_R
-		unit_test(test_nwrap_gethostbyname_r),
+		cmocka_unit_test(test_nwrap_gethostbyname_r),
 #endif
 #ifdef HAVE_GETHOSTBYADDR_R
-		unit_test(test_nwrap_gethostbyaddr_r),
+		cmocka_unit_test(test_nwrap_gethostbyaddr_r),
 #endif
 	};
 
-	rc = run_tests(tests);
+	rc = cmocka_run_group_tests(tests, NULL, NULL);
 
 	return rc;
 }
diff --git a/tests/test_gethostent.c b/tests/test_gethostent.c
index e95195f..aa61696 100644
--- a/tests/test_gethostent.c
+++ b/tests/test_gethostent.c
@@ -51,11 +51,11 @@ static void test_nwrap_gethostent(void **state)
 int main(void) {
 	int rc;
 
-	const UnitTest tests[] = {
-		unit_test(test_nwrap_gethostent),
+	const struct CMUnitTest tests[] = {
+		cmocka_unit_test(test_nwrap_gethostent),
 	};
 
-	rc = run_tests(tests);
+	rc = cmocka_run_group_tests(tests, NULL, NULL);
 
 	return rc;
 }
diff --git a/tests/test_getnameinfo.c b/tests/test_getnameinfo.c
index 95db681..bfafa98 100644
--- a/tests/test_getnameinfo.c
+++ b/tests/test_getnameinfo.c
@@ -328,16 +328,16 @@ static void test_nwrap_getnameinfo_flags(void **state)
 int main(void) {
 	int rc;
 
-	const UnitTest tests[] = {
-		unit_test(test_nwrap_getnameinfo),
-		unit_test(test_nwrap_getnameinfo_numeric),
-		unit_test(test_nwrap_getnameinfo_any),
-		unit_test(test_nwrap_getnameinfo_local),
-		unit_test(test_nwrap_getnameinfo_null),
-		unit_test(test_nwrap_getnameinfo_flags),
+	const struct CMUnitTest tests[] = {
+		cmocka_unit_test(test_nwrap_getnameinfo),
+		cmocka_unit_test(test_nwrap_getnameinfo_numeric),
+		cmocka_unit_test(test_nwrap_getnameinfo_any),
+		cmocka_unit_test(test_nwrap_getnameinfo_local),
+		cmocka_unit_test(test_nwrap_getnameinfo_null),
+		cmocka_unit_test(test_nwrap_getnameinfo_flags),
 	};
 
-	rc = run_tests(tests);
+	rc = cmocka_run_group_tests(tests, NULL, NULL);
 
 	return rc;
 }
diff --git a/tests/test_nwrap_disabled.c b/tests/test_nwrap_disabled.c
index a64cee4..56e1589 100644
--- a/tests/test_nwrap_disabled.c
+++ b/tests/test_nwrap_disabled.c
@@ -96,14 +96,14 @@ static void test_nwrap_getaddrinfo_local(void **state)
 int main(void) {
 	int rc;
 
-	const UnitTest tests[] = {
-		unit_test(test_nwrap_passwd_group),


-- 
NSS Wrapper Repository



More information about the samba-cvs mailing list