Hello community, here is the log from the commit of package resolv_wrapper for openSUSE:Factory checked in at 2015-09-09 20:21:28 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/resolv_wrapper (Old) and /work/SRC/openSUSE:Factory/.resolv_wrapper.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "resolv_wrapper" Changes: -------- --- /work/SRC/openSUSE:Factory/resolv_wrapper/resolv_wrapper.changes 2015-06-11 08:22:02.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.resolv_wrapper.new/resolv_wrapper.changes 2015-09-09 20:21:29.000000000 +0200 @@ -1,0 +2,9 @@ +Wed Sep 2 11:52:01 UTC 2015 - [email protected] + +- Update to version 1.1.3: + * Fixed symbol detection if macros are used for res_* functions + * Fixed strict aliasing warnings for symbol binding + * Added missing tests for req_query and res_search + * Fix detection for ns_name_compress. + +------------------------------------------------------------------- Old: ---- resolv_wrapper-1.1.1.tar.gz New: ---- resolv_wrapper-1.1.3.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ resolv_wrapper.spec ++++++ --- /var/tmp/diff_new_pack.iTJVAf/_old 2015-09-09 20:21:30.000000000 +0200 +++ /var/tmp/diff_new_pack.iTJVAf/_new 2015-09-09 20:21:30.000000000 +0200 @@ -15,6 +15,7 @@ # Please submit bugfixes or comments via http://bugs.opensuse.org/ # + ############################# NOTE ################################## # # This is a special library. You are not able to link this library. @@ -23,7 +24,7 @@ ############################# NOTE ################################## Name: resolv_wrapper -Version: 1.1.1 +Version: 1.1.3 Release: 0 Summary: A wrapper for dns name resolving or dns faking @@ -35,13 +36,13 @@ Source1: %{name}-rpmlintrc BuildRequires: cmake -BuildRequires: libcmocka-devel BuildRequires: glibc-devel +BuildRequires: libcmocka-devel BuildRequires: pkg-config BuildRequires: socket_wrapper -Requires: pkg-config Requires: cmake +Requires: pkg-config %description resolv_wrapper makes it possible on most UNIX platforms to contact your own DNS ++++++ resolv_wrapper-1.1.1.tar.gz -> resolv_wrapper-1.1.3.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/resolv_wrapper-1.1.1/CMakeLists.txt new/resolv_wrapper-1.1.3/CMakeLists.txt --- old/resolv_wrapper-1.1.1/CMakeLists.txt 2015-01-12 17:27:42.000000000 +0100 +++ new/resolv_wrapper-1.1.3/CMakeLists.txt 2015-08-24 15:17:00.000000000 +0200 @@ -8,7 +8,7 @@ set(APPLICATION_VERSION_MAJOR "1") set(APPLICATION_VERSION_MINOR "1") -set(APPLICATION_VERSION_PATCH "1") +set(APPLICATION_VERSION_PATCH "3") set(APPLICATION_VERSION "${APPLICATION_VERSION_MAJOR}.${APPLICATION_VERSION_MINOR}.${APPLICATION_VERSION_PATCH}") @@ -19,7 +19,7 @@ # Increment AGE. Set REVISION to 0 # If the source code was changed, but there were no interface changes: # Increment REVISION. -set(LIBRARY_VERSION "0.0.2") +set(LIBRARY_VERSION "0.0.3") set(LIBRARY_SOVERSION "0") # where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked @@ -30,7 +30,6 @@ # add definitions include(DefineCMakeDefaults) include(DefinePlatformDefaults) -include(DefineCompilerFlags) include(DefineInstallationPaths) include(DefineOptions.cmake) include(CPackConfig.cmake) @@ -47,6 +46,9 @@ include(ConfigureChecks.cmake) configure_file(config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h) +# Add compiler flags for the project now. +include(DefineCompilerFlags) + # check subdirectories add_subdirectory(src) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/resolv_wrapper-1.1.1/CTestConfig.cmake new/resolv_wrapper-1.1.3/CTestConfig.cmake --- old/resolv_wrapper-1.1.1/CTestConfig.cmake 2014-10-21 14:33:48.000000000 +0200 +++ new/resolv_wrapper-1.1.3/CTestConfig.cmake 2015-08-13 14:32:44.000000000 +0200 @@ -3,7 +3,7 @@ set(CTEST_PROJECT_NAME "resolvwrapper") set(CTEST_NIGHTLY_START_TIME "01:00:00 UTC") -set(CTEST_DROP_METHOD "http") +set(CTEST_DROP_METHOD "https") set(CTEST_DROP_SITE "mock.cryptomilk.org") set(CTEST_DROP_LOCATION "/submit.php?project=resolvwrapper") set(CTEST_DROP_SITE_CDASH TRUE) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/resolv_wrapper-1.1.1/ChangeLog new/resolv_wrapper-1.1.3/ChangeLog --- old/resolv_wrapper-1.1.1/ChangeLog 2015-01-12 17:27:42.000000000 +0100 +++ new/resolv_wrapper-1.1.3/ChangeLog 2015-08-24 15:17:00.000000000 +0200 @@ -1,6 +1,14 @@ ChangeLog ========== +version 1.1.3 (released 2015-01-13) + * Fixed symbol detection if macros are used for res_* functions + * Fixed strict aliasing warnings for symbol binding + * Added missing tests for req_query and res_search + +version 1.1.2 (released 2015-01-13) + * Fix detection for ns_name_compress. + version 1.1.1 (released 2015-01-12) * Fixed building on older Linux distributions. * Fix a possible segfault. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/resolv_wrapper-1.1.1/ConfigureChecks.cmake new/resolv_wrapper-1.1.3/ConfigureChecks.cmake --- old/resolv_wrapper-1.1.1/ConfigureChecks.cmake 2015-01-12 17:27:42.000000000 +0100 +++ new/resolv_wrapper-1.1.3/ConfigureChecks.cmake 2015-01-13 15:11:34.000000000 +0100 @@ -94,7 +94,7 @@ check_function_exists(res_nsearch HAVE_RES_NSEARCH) check_function_exists(__res_nsearch HAVE___RES_NSEARCH) -check_function_exists(ns_name_compress HAVE_NS_NAME_COMPRESS) +check_symbol_exists(ns_name_compress "sys/types.h;arpa/nameser.h" HAVE_NS_NAME_COMPRESS) if (UNIX) if (NOT LINUX) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/resolv_wrapper-1.1.1/doc/resolv_wrapper.1 new/resolv_wrapper-1.1.3/doc/resolv_wrapper.1 --- old/resolv_wrapper-1.1.1/doc/resolv_wrapper.1 2014-10-23 07:00:52.000000000 +0200 +++ new/resolv_wrapper-1.1.3/doc/resolv_wrapper.1 2015-08-18 12:28:45.000000000 +0200 @@ -2,12 +2,12 @@ .\" Title: resolv_wrapper .\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] .\" Generator: DocBook XSL Stylesheets v1.78.1 <http://docbook.sf.net/> -.\" Date: 10/12/2014 +.\" Date: 2015-08-18 .\" Manual: \ \& .\" Source: \ \& .\" Language: English .\" -.TH "RESOLV_WRAPPER" "1" "10/12/2014" "\ \&" "\ \&" +.TH "RESOLV_WRAPPER" "1" "2015\-08\-18" "\ \&" "\ \&" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -147,11 +147,13 @@ .RE .SH "EXAMPLE" .sp +The following command would trick \fIkinit(1)\fR into using DNS servers from "\&./resolv\&.conf" for Kerberos service resolution: +.sp .if n \{\ .RS 4 .\} .nf -$ LD_PRELOAD=libresolv_wrapper\&.so RESOLV_WRAPPER_CONF="\&./resolv\&.conf" dig test\&.example\&.site +$ LD_PRELOAD=libresolv_wrapper\&.so RESOLV_WRAPPER_CONF="\&./resolv\&.conf" kinit user@EXAMPLE\&.COM .fi .if n \{\ .RE diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/resolv_wrapper-1.1.1/doc/resolv_wrapper.1.txt new/resolv_wrapper-1.1.3/doc/resolv_wrapper.1.txt --- old/resolv_wrapper-1.1.1/doc/resolv_wrapper.1.txt 2014-10-23 07:00:52.000000000 +0200 +++ new/resolv_wrapper-1.1.3/doc/resolv_wrapper.1.txt 2015-08-18 12:28:45.000000000 +0200 @@ -1,5 +1,6 @@ resolv_wrapper(1) ================= +:revdate: 2015-08-18 NAME ---- @@ -61,4 +62,7 @@ EXAMPLE ------- - $ LD_PRELOAD=libresolv_wrapper.so RESOLV_WRAPPER_CONF="./resolv.conf" dig test.example.site +The following command would trick 'kinit(1)' into using DNS servers from "./resolv.conf" +for Kerberos service resolution: + + $ LD_PRELOAD=libresolv_wrapper.so RESOLV_WRAPPER_CONF="./resolv.conf" kinit [email protected] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/resolv_wrapper-1.1.1/src/resolv_wrapper.c new/resolv_wrapper-1.1.3/src/resolv_wrapper.c --- old/resolv_wrapper-1.1.1/src/resolv_wrapper.c 2015-01-12 17:27:42.000000000 +0100 +++ new/resolv_wrapper-1.1.3/src/resolv_wrapper.c 2015-08-18 12:28:45.000000000 +0200 @@ -1,6 +1,6 @@ /* * Copyright (c) 2014 Andreas Schneider <[email protected]> - * Copyright (c) 2014 Jakub Hrozek <[email protected]> + * Copyright (c) 2014 Jakub Hrozek <[email protected]> * * All rights reserved. * @@ -981,51 +981,68 @@ #include <dlfcn.h> -struct rwrap_libc_fns { - int (*libc_res_init)(void); - int (*libc___res_init)(void); - int (*libc_res_ninit)(struct __res_state *state); - int (*libc___res_ninit)(struct __res_state *state); - void (*libc_res_nclose)(struct __res_state *state); - void (*libc___res_nclose)(struct __res_state *state); - void (*libc_res_close)(void); - void (*libc___res_close)(void); - int (*libc_res_nquery)(struct __res_state *state, - const char *dname, - int class, - int type, - unsigned char *answer, - int anslen); - int (*libc___res_nquery)(struct __res_state *state, +typedef int (*__libc_res_ninit)(struct __res_state *state); +typedef int (*__libc___res_ninit)(struct __res_state *state); +typedef void (*__libc_res_nclose)(struct __res_state *state); +typedef void (*__libc___res_nclose)(struct __res_state *state); +typedef int (*__libc_res_nquery)(struct __res_state *state, const char *dname, int class, int type, unsigned char *answer, int anslen); - int (*libc_res_nsearch)(struct __res_state *state, - const char *dname, - int class, - int type, - unsigned char *answer, - int anslen); - int (*libc___res_nsearch)(struct __res_state *state, +typedef int (*__libc___res_nquery)(struct __res_state *state, + const char *dname, + int class, + int type, + unsigned char *answer, + int anslen); +typedef int (*__libc_res_nsearch)(struct __res_state *state, const char *dname, int class, int type, unsigned char *answer, int anslen); +typedef int (*__libc___res_nsearch)(struct __res_state *state, + const char *dname, + int class, + int type, + unsigned char *answer, + int anslen); + +#define RWRAP_SYMBOL_ENTRY(i) \ + union { \ + __libc_##i f; \ + void *obj; \ + } _libc_##i + +struct rwrap_libc_symbols { + RWRAP_SYMBOL_ENTRY(res_ninit); + RWRAP_SYMBOL_ENTRY(__res_ninit); + RWRAP_SYMBOL_ENTRY(res_nclose); + RWRAP_SYMBOL_ENTRY(__res_nclose); + RWRAP_SYMBOL_ENTRY(res_nquery); + RWRAP_SYMBOL_ENTRY(__res_nquery); + RWRAP_SYMBOL_ENTRY(res_nsearch); + RWRAP_SYMBOL_ENTRY(__res_nsearch); }; +#undef RWRAP_SYMBOL_ENTRY struct rwrap { - void *libc_handle; - void *libresolv_handle; + struct { + void *handle; + struct rwrap_libc_symbols symbols; + } libc; + + struct { + void *handle; + struct rwrap_libc_symbols symbols; + } libresolv; bool initialised; bool enabled; char *socket_dir; - - struct rwrap_libc_fns fns; }; static struct rwrap rwrap; @@ -1063,7 +1080,7 @@ switch (lib) { case RWRAP_LIBRESOLV: #ifdef HAVE_LIBRESOLV - handle = rwrap.libresolv_handle; + handle = rwrap.libresolv.handle; if (handle == NULL) { for (i = 10; i >= 0; i--) { char soname[256] = {0}; @@ -1075,18 +1092,18 @@ } } - rwrap.libresolv_handle = handle; + rwrap.libresolv.handle = handle; } break; #endif /* FALL TROUGH */ case RWRAP_LIBC: - handle = rwrap.libc_handle; + handle = rwrap.libc.handle; #ifdef LIBC_SO if (handle == NULL) { handle = dlopen(LIBC_SO, flags); - rwrap.libc_handle = handle; + rwrap.libc.handle = handle; } #endif if (handle == NULL) { @@ -1100,14 +1117,14 @@ } } - rwrap.libc_handle = handle; + rwrap.libc.handle = handle; } break; } if (handle == NULL) { #ifdef RTLD_NEXT - handle = rwrap.libc_handle = rwrap.libresolv_handle = RTLD_NEXT; + handle = rwrap.libc.handle = rwrap.libresolv.handle = RTLD_NEXT; #else RWRAP_LOG(RWRAP_LOG_ERROR, "Failed to dlopen library: %s\n", @@ -1119,7 +1136,7 @@ return handle; } -static void *_rwrap_load_lib_function(enum rwrap_lib lib, const char *fn_name) +static void *_rwrap_bind_symbol(enum rwrap_lib lib, const char *fn_name) { void *handle; void *func; @@ -1140,10 +1157,16 @@ return func; } -#define rwrap_load_lib_function(lib, fn_name) \ - if (rwrap.fns.libc_##fn_name == NULL) { \ - *(void **) (&rwrap.fns.libc_##fn_name) = \ - _rwrap_load_lib_function(lib, #fn_name); \ +#define rwrap_bind_symbol_libc(sym_name) \ + if (rwrap.libc.symbols._libc_##sym_name.obj == NULL) { \ + rwrap.libc.symbols._libc_##sym_name.obj = \ + _rwrap_bind_symbol(RWRAP_LIBC, #sym_name); \ + } + +#define rwrap_bind_symbol_libresolv(sym_name) \ + if (rwrap.libresolv.symbols._libc_##sym_name.obj == NULL) { \ + rwrap.libresolv.symbols._libc_##sym_name.obj = \ + _rwrap_bind_symbol(RWRAP_LIBRESOLV, #sym_name); \ } /* @@ -1154,36 +1177,25 @@ * has probably something todo with with the linker. * So we need load each function at the point it is called the first time. */ -#if 0 -static int libc_res_init(void) -{ -#if defined(HAVE_RES_INIT) - rwrap_load_lib_function(RWRAP_LIBRESOLV, res_init); - - return rwrap.fns.libc_res_init(); -#elif defined(HAVE___RES_INIT) - rwrap_load_lib_function(RWRAP_LIBRESOLV, __res_init); - - return rwrap.fns.libc___res_init(); -#endif -} -#endif static int libc_res_ninit(struct __res_state *state) { -#if defined(HAVE_RES_NINIT) +#if !defined(res_ninit) && defined(HAVE_RES_NINIT) #if defined(HAVE_RES_NINIT_IN_LIBRESOLV) - rwrap_load_lib_function(RWRAP_LIBRESOLV, res_ninit); + rwrap_bind_symbol_libresolv(res_ninit); + + return rwrap.libresolv.symbols._libc_res_ninit.f(state); #else /* HAVE_RES_NINIT_IN_LIBRESOLV */ - rwrap_load_lib_function(RWRAP_LIBC, res_ninit); + rwrap_bind_symbol_libc(res_ninit); + + return rwrap.libc.symbols._libc_res_ninit.f(state); #endif /* HAVE_RES_NINIT_IN_LIBRESOLV */ - return rwrap.fns.libc_res_ninit(state); #elif defined(HAVE___RES_NINIT) - rwrap_load_lib_function(RWRAP_LIBC, __res_ninit); + rwrap_bind_symbol_libc(__res_ninit); - return rwrap.fns.libc___res_ninit(state); + return rwrap.libc.symbols._libc___res_ninit.f(state); #else #error "No res_ninit function" #endif @@ -1191,19 +1203,24 @@ static void libc_res_nclose(struct __res_state *state) { -#if defined(HAVE_RES_NCLOSE) +#if !defined(res_close) && defined(HAVE_RES_NCLOSE) #if defined(HAVE_RES_NCLOSE_IN_LIBRESOLV) - rwrap_load_lib_function(RWRAP_LIBRESOLV, res_nclose); + rwrap_bind_symbol_libresolv(res_nclose); + + rwrap.libresolv.symbols._libc_res_nclose.f(state); + return; #else /* HAVE_RES_NCLOSE_IN_LIBRESOLV */ - rwrap_load_lib_function(RWRAP_LIBC, res_nclose); + rwrap_bind_symbol_libc(res_nclose); + + rwrap.libc.symbols._libc_res_nclose.f(state); + return; #endif /* HAVE_RES_NCLOSE_IN_LIBRESOLV */ - rwrap.fns.libc_res_nclose(state); #elif defined(HAVE___RES_NCLOSE) - rwrap_load_lib_function(RWRAP_LIBC, __res_nclose); + rwrap_bind_symbol_libc(__res_nclose); - rwrap.fns.libc___res_nclose(state); + rwrap.libc.symbols._libc___res_nclose.f(state); #else #error "No res_nclose function" #endif @@ -1216,24 +1233,24 @@ unsigned char *answer, int anslen) { -#if defined(HAVE_RES_NQUERY) - rwrap_load_lib_function(RWRAP_LIBRESOLV, res_nquery); +#if !defined(res_nquery) && defined(HAVE_RES_NQUERY) + rwrap_bind_symbol_libresolv(res_nquery); - return rwrap.fns.libc_res_nquery(state, - dname, - class, - type, - answer, - anslen); + return rwrap.libresolv.symbols._libc_res_nquery.f(state, + dname, + class, + type, + answer, + anslen); #elif defined(HAVE___RES_NQUERY) - rwrap_load_lib_function(RWRAP_LIBRESOLV, __res_nquery); + rwrap_bind_symbol_libresolv(__res_nquery); - return rwrap.fns.libc___res_nquery(state, - dname, - class, - type, - answer, - anslen); + return rwrap.libresolv.symbols._libc___res_nquery.f(state, + dname, + class, + type, + answer, + anslen); #else #error "No res_nquery function" #endif @@ -1246,24 +1263,24 @@ unsigned char *answer, int anslen) { -#if defined(HAVE_RES_NSEARCH) - rwrap_load_lib_function(RWRAP_LIBRESOLV, res_nsearch); +#if !defined(res_nsearch) && defined(HAVE_RES_NSEARCH) + rwrap_bind_symbol_libresolv(res_nsearch); - return rwrap.fns.libc_res_nsearch(state, - dname, - class, - type, - answer, - anslen); + return rwrap.libresolv.symbols._libc_res_nsearch.f(state, + dname, + class, + type, + answer, + anslen); #elif defined(HAVE___RES_NSEARCH) - rwrap_load_lib_function(RWRAP_LIBRESOLV, __res_nsearch); + rwrap_bind_symbol_libresolv(__res_nsearch); - return rwrap.fns.libc___res_nsearch(state, - dname, - class, - type, - answer, - anslen); + return rwrap.libresolv.symbols._libc___res_nsearch.f(state, + dname, + class, + type, + answer, + anslen); #else #error "No res_nsearch function" #endif @@ -1418,7 +1435,7 @@ return rc; } -#if defined(HAVE_RES_NINIT) +#if !defined(res_ninit) && defined(HAVE_RES_NINIT) int res_ninit(struct __res_state *state) #elif defined(HAVE___RES_NINIT) int __res_ninit(struct __res_state *state) @@ -1442,7 +1459,7 @@ return rc; } -#if defined(HAVE_RES_INIT) +#if !defined(res_ninit) && defined(HAVE_RES_INIT) int res_init(void) #elif defined(HAVE___RES_INIT) int __res_init(void) @@ -1472,7 +1489,7 @@ #endif } -#if defined(HAVE_RES_NCLOSE) +#if !defined(res_nclose) && defined(HAVE_RES_NCLOSE) void res_nclose(struct __res_state *state) #elif defined(HAVE___RES_NCLOSE) void __res_nclose(struct __res_state *state) @@ -1545,7 +1562,7 @@ return rc; } -#if defined(HAVE_RES_NQUERY) +#if !defined(res_nquery) && defined(HAVE_RES_NQUERY) int res_nquery(struct __res_state *state, const char *dname, int class, @@ -1591,7 +1608,7 @@ return rc; } -#if defined(HAVE_RES_QUERY) +#if !defined(res_query) && defined(HAVE_RES_QUERY) int res_query(const char *dname, int class, int type, @@ -1653,7 +1670,7 @@ return rc; } -#if defined(HAVE_RES_NSEARCH) +#if !defined(res_nsearch) && defined(HAVE_RES_NSEARCH) int res_nsearch(struct __res_state *state, const char *dname, int class, @@ -1673,7 +1690,7 @@ } /**************************************************************************** - * RES_QUERY + * RES_SEARCH ***************************************************************************/ static int rwrap_res_search(const char *dname, @@ -1699,7 +1716,7 @@ return rc; } -#if defined(HAVE_RES_SEARCH) +#if !defined(res_search) && defined(HAVE_RES_SEARCH) int res_search(const char *dname, int class, int type, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/resolv_wrapper-1.1.1/tests/dns_srv.c new/resolv_wrapper-1.1.3/tests/dns_srv.c --- old/resolv_wrapper-1.1.1/tests/dns_srv.c 2014-11-07 10:27:45.000000000 +0100 +++ new/resolv_wrapper-1.1.3/tests/dns_srv.c 2015-08-18 12:28:45.000000000 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (C) Jakub Hrozek 2014 <[email protected]> + * Copyright (C) Jakub Hrozek 2014 <[email protected]> * * All rights reserved. * diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/resolv_wrapper-1.1.1/tests/test_dns_fake.c new/resolv_wrapper-1.1.3/tests/test_dns_fake.c --- old/resolv_wrapper-1.1.1/tests/test_dns_fake.c 2014-12-03 10:54:58.000000000 +0100 +++ new/resolv_wrapper-1.1.3/tests/test_dns_fake.c 2015-08-18 12:28:45.000000000 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (C) Jakub Hrozek 2014 <[email protected]> + * Copyright (C) Jakub Hrozek 2014 <[email protected]> * * All rights reserved. * @@ -563,21 +563,21 @@ { int rc; - const UnitTest tests[] = { - unit_test(test_res_fake_a_query), - unit_test(test_res_fake_a_query_case_insensitive), - unit_test(test_res_fake_a_query_trailing_dot), - unit_test(test_res_fake_a_query_notfound), - unit_test(test_res_fake_aaaa_query), - unit_test(test_res_fake_aaaa_query_notfound), - unit_test(test_res_fake_srv_query), - unit_test(test_res_fake_srv_query_minimal), - unit_test(test_res_fake_soa_query), - unit_test(test_res_fake_cname_query), - unit_test(test_res_fake_a_via_cname), + const struct CMUnitTest fake_tests[] = { + cmocka_unit_test(test_res_fake_a_query), + cmocka_unit_test(test_res_fake_a_query_case_insensitive), + cmocka_unit_test(test_res_fake_a_query_trailing_dot), + cmocka_unit_test(test_res_fake_a_query_notfound), + cmocka_unit_test(test_res_fake_aaaa_query), + cmocka_unit_test(test_res_fake_aaaa_query_notfound), + cmocka_unit_test(test_res_fake_srv_query), + cmocka_unit_test(test_res_fake_srv_query_minimal), + cmocka_unit_test(test_res_fake_soa_query), + cmocka_unit_test(test_res_fake_cname_query), + cmocka_unit_test(test_res_fake_a_via_cname), }; - rc = run_tests(tests); + rc = cmocka_run_group_tests(fake_tests, NULL, NULL); return rc; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/resolv_wrapper-1.1.1/tests/test_real_res_query.c new/resolv_wrapper-1.1.3/tests/test_real_res_query.c --- old/resolv_wrapper-1.1.1/tests/test_real_res_query.c 2014-12-03 10:54:58.000000000 +0100 +++ new/resolv_wrapper-1.1.3/tests/test_real_res_query.c 2015-08-18 12:28:45.000000000 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (C) Jakub Hrozek 2014 <[email protected]> + * Copyright (C) Jakub Hrozek 2014 <[email protected]> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -189,12 +189,12 @@ { int rc; - const UnitTest tests[] = { - unit_test(test_res_query_a_record), - unit_test(test_res_query_srv_record), + const struct CMUnitTest real_tests[] = { + cmocka_unit_test(test_res_query_a_record), + cmocka_unit_test(test_res_query_srv_record), }; - rc = run_tests(tests); + rc = cmocka_run_group_tests(real_tests, NULL, NULL); return rc; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/resolv_wrapper-1.1.1/tests/test_res_init.c new/resolv_wrapper-1.1.3/tests/test_res_init.c --- old/resolv_wrapper-1.1.1/tests/test_res_init.c 2014-11-07 10:27:45.000000000 +0100 +++ new/resolv_wrapper-1.1.3/tests/test_res_init.c 2015-08-17 10:27:53.000000000 +0200 @@ -23,7 +23,7 @@ char *resolv_conf_path; }; -static void setup(void **state) +static int setup(void **state) { struct resolv_conf_test_state *test_state; @@ -40,15 +40,17 @@ assert_non_null(test_state->resolv_conf); *state = test_state; + + return 0; } -static void teardown(void **state) +static int teardown(void **state) { struct resolv_conf_test_state *test_state; test_state = (struct resolv_conf_test_state *) *state; - if (test_state == NULL) return; + if (test_state == NULL) return -1; if (test_state->resolv_conf) { fclose(test_state->resolv_conf); @@ -64,6 +66,8 @@ } free(test_state); + + return 0; } static void test_res_ninit(void **state) @@ -195,11 +199,12 @@ int main(void) { int rc; - const UnitTest tests[] = { - unit_test_setup_teardown(test_res_ninit, setup, teardown), - unit_test(test_res_ninit_enoent), + const struct CMUnitTest init_tests[] = { + cmocka_unit_test_setup_teardown(test_res_ninit, setup, teardown), + cmocka_unit_test(test_res_ninit_enoent), }; - rc = run_tests(tests); + rc = cmocka_run_group_tests(init_tests, NULL, NULL); + return rc; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/resolv_wrapper-1.1.1/tests/test_res_query_search.c new/resolv_wrapper-1.1.3/tests/test_res_query_search.c --- old/resolv_wrapper-1.1.1/tests/test_res_query_search.c 2014-11-07 10:27:45.000000000 +0100 +++ new/resolv_wrapper-1.1.3/tests/test_res_query_search.c 2015-08-24 15:16:51.000000000 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (C) Jakub Hrozek 2014 <[email protected]> + * Copyright (C) Jakub Hrozek 2014 <[email protected]> * * All rights reserved. * @@ -51,18 +51,22 @@ #define ANSIZE 256 -static void setup_dns_srv_ipv4(void **state) +static int setup_dns_srv_ipv4(void **state) { torture_setup_dns_srv_ipv4(state); setenv("RESOLV_WRAPPER_CONF", torture_server_resolv_conf(state), 1); + + return 0; } -static void teardown(void **state) +static int teardown(void **state) { torture_teardown_dns_srv(state); + + return 0; } -static void test_res_query(void **state) +static void test_res_nquery(void **state) { int rv; struct __res_state dnsstate; @@ -98,7 +102,38 @@ res_nclose(&dnsstate); } -static void test_res_search(void **state) +static void test_res_query(void **state) +{ + int rv; + unsigned char answer[ANSIZE]; + char addr[INET_ADDRSTRLEN]; + ns_msg handle; + ns_rr rr; /* expanded resource record */ + + (void) state; /* unused */ + + rv = res_query("www.cwrap.org", ns_c_in, ns_t_a, + answer, sizeof(answer)); + assert_int_not_equal(rv, -1); + + ns_initparse(answer, sizeof(answer), &handle); + /* + * The query must finish w/o an error, have one answer and the answer + * must be a parseable RR of type A and have the address that our + * test server sends. + */ + assert_int_equal(ns_msg_getflag(handle, ns_f_rcode), ns_r_noerror); + assert_int_equal(ns_msg_count(handle, ns_s_an), 1); + assert_int_equal(ns_parserr(&handle, ns_s_an, 0, &rr), 0); + assert_int_equal(ns_rr_type(rr), ns_t_a); + assert_non_null(inet_ntop(AF_INET, ns_rr_rdata(rr), + addr, sizeof(addr))); + assert_string_equal(addr, "127.0.10.10"); + + res_close(); +} + +static void test_res_nsearch(void **state) { int rv; struct __res_state dnsstate; @@ -133,20 +168,56 @@ res_nclose(&dnsstate); } +static void test_res_search(void **state) +{ + int rv; + unsigned char answer[ANSIZE]; + char addr[INET_ADDRSTRLEN]; + ns_msg handle; + ns_rr rr; /* expanded resource record */ + + (void) state; /* unused */ + + rv = res_search("www.cwrap.org", ns_c_in, ns_t_a, + answer, sizeof(answer)); + assert_int_not_equal(rv, -1); + + ns_initparse(answer, sizeof(answer), &handle); + /* The query must finish w/o an error, have one answer and the answer + * must be a parseable RR of type A and have the address that our + * test server sends + */ + assert_int_equal(ns_msg_getflag(handle, ns_f_rcode), ns_r_noerror); + assert_int_equal(ns_msg_count(handle, ns_s_an), 1); + assert_int_equal(ns_parserr(&handle, ns_s_an, 0, &rr), 0); + assert_int_equal(ns_rr_type(rr), ns_t_a); + assert_non_null(inet_ntop(AF_INET, ns_rr_rdata(rr), + addr, sizeof(addr))); + assert_string_equal(addr, "127.0.10.10"); + + res_close(); +} + int main(void) { int rc; - const UnitTest tests[] = { - unit_test_setup_teardown(test_res_query, - setup_dns_srv_ipv4, - teardown), - unit_test_setup_teardown(test_res_search, - setup_dns_srv_ipv4, - teardown), + const struct CMUnitTest res_tests[] = { + cmocka_unit_test_setup_teardown(test_res_nquery, + setup_dns_srv_ipv4, + teardown), + cmocka_unit_test_setup_teardown(test_res_query, + setup_dns_srv_ipv4, + teardown), + cmocka_unit_test_setup_teardown(test_res_nsearch, + setup_dns_srv_ipv4, + teardown), + cmocka_unit_test_setup_teardown(test_res_search, + setup_dns_srv_ipv4, + teardown), }; - rc = run_tests(tests); + rc = cmocka_run_group_tests(res_tests, NULL, NULL); return rc; }
