]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
convert geoip_test
authorEvan Hunt <each@isc.org>
Thu, 25 Oct 2018 04:28:34 +0000 (21:28 -0700)
committerEvan Hunt <each@isc.org>
Thu, 15 Nov 2018 04:17:04 +0000 (20:17 -0800)
lib/dns/tests/Kyuafile
lib/dns/tests/Makefile.in
lib/dns/tests/geoip_test.c

index 5f16e4b4e12c6cd5f7b3da77d1b6376829eb842b..1ced0d6a73e8962c5930cb7cfe9d450742cd53d0 100644 (file)
@@ -10,7 +10,7 @@ tap_test_program{name='dh_test'}
 atf_test_program{name='dispatch_test'}
 atf_test_program{name='dnstap_test'}
 atf_test_program{name='dst_test'}
-atf_test_program{name='geoip_test'}
+tap_test_program{name='geoip_test'}
 atf_test_program{name='keytable_test'}
 atf_test_program{name='master_test'}
 atf_test_program{name='name_test'}
index 3093d733a30112ab222d5df9ef7004f26c942532..747cafdcb85562d53987e76c568567851aff2236 100644 (file)
@@ -143,9 +143,9 @@ dst_test@EXEEXT@: dst_test.@O@ dnstest.@O@ ${ISCDEPLIBS} ${DNSDEPLIBS}
                        ${ISCLIBS} ${LIBS}
 
 geoip_test@EXEEXT@: geoip_test.@O@ dnstest.@O@ ${ISCDEPLIBS} ${DNSDEPLIBS}
-       ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ \
-                       geoip_test.@O@ dnstest.@O@ ${DNSLIBS} \
-                       ${ISCLIBS} ${LIBS}
+       ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${CMOCKA_CFLAGS} \
+               ${LDFLAGS} -o $@ geoip_test.@O@ dnstest.@O@ \
+               ${DNSLIBS} ${ISCLIBS} ${LIBS} ${CMOCKA_LIBS}
 
 keytable_test@EXEEXT@: keytable_test.@O@ dnstest.@O@ ${ISCDEPLIBS} ${DNSDEPLIBS}
        ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ \
index d59f0d969e9f81ccf5f6121a93afc2d94c32e024..49bbfca0a1e25f10821b05a4a9b5dc04871906c4 100644 (file)
@@ -9,18 +9,26 @@
  * information regarding copyright ownership.
  */
 
-/*! \file */
-
 #include <config.h>
 
-#include <atf-c.h>
+#if HAVE_CMOCKA
+
+#include <stdarg.h>
+#include <stddef.h>
+#include <setjmp.h>
 
 #include <stdbool.h>
+#include <stdlib.h>
+#include <string.h>
 #include <unistd.h>
 
+#define UNIT_TESTING
+#include <cmocka.h>
+
 #include <isc/print.h>
 #include <isc/string.h>
 #include <isc/types.h>
+#include <isc/util.h>
 
 #include <dns/geoip.h>
 
 /* We use GeoIP databases from the 'geoip' system test */
 #define TEST_GEOIP_DATA "../../../bin/tests/system/geoip/data"
 
+static int
+_setup(void **state) {
+       isc_result_t result;
+
+       UNUSED(state);
+
+       result = dns_test_begin(NULL, false);
+       assert_int_equal(result, ISC_R_SUCCESS);
+
+       return (0);
+}
+
+static int
+_teardown(void **state) {
+       UNUSED(state);
+
+       dns_test_end();
+
+       return (0);
+}
+
 /*
  * Helper functions
  * (Mostly copied from bin/named/geoip.c)
@@ -44,7 +73,6 @@ static void
 init_geoip_db(GeoIP **dbp, GeoIPDBTypes edition, GeoIPDBTypes fallback,
              GeoIPOptions method, const char *name)
 {
-       char *info;
        GeoIP *db;
 
        REQUIRE(dbp != NULL);
@@ -57,34 +85,21 @@ init_geoip_db(GeoIP **dbp, GeoIPDBTypes edition, GeoIPDBTypes fallback,
        }
 
        if (! GeoIP_db_avail(edition)) {
-               fprintf(stderr, "GeoIP %s (type %d) DB not available\n",
-                       name, edition);
                goto fail;
        }
 
-       fprintf(stderr, "initializing GeoIP %s (type %d) DB\n",
-               name, edition);
-
        db = GeoIP_open_type(edition, method);
        if (db == NULL) {
-               fprintf(stderr,
-                       "failed to initialize GeoIP %s (type %d) DB%s\n",
-                       name, edition, fallback == 0
-                        ? "; geoip matches using this database will fail"
-                        : "");
                goto fail;
        }
 
-       info = GeoIP_database_info(db);
-       if (info != NULL)
-               fprintf(stderr, "%s\n", info);
-
        *dbp = db;
        return;
 
  fail:
-       if (fallback != 0)
+       if (fallback != 0) {
                init_geoip_db(dbp, fallback, 0, method, name);
+       }
 }
 
 static void
@@ -180,249 +195,192 @@ do_lookup_int(const char *addr, dns_geoip_subtype_t subtype, int id) {
        return (dns_geoip_match(&na, &geoip, &elt));
 }
 
-/*
- * Individual unit tests
- */
-
 /* GeoIP country matching */
-ATF_TC(country);
-ATF_TC_HEAD(country, tc) {
-       atf_tc_set_md_var(tc, "descr", "test country database matching");
-}
-ATF_TC_BODY(country, tc) {
-       isc_result_t result;
+static void
+country(void **state) {
        bool match;
 
-       UNUSED(tc);
-
-       result = dns_test_begin(NULL, true);
-       ATF_REQUIRE(result == ISC_R_SUCCESS);
+       UNUSED(state);
 
        /* Use databases from the geoip system test */
        load_geoip(TEST_GEOIP_DATA);
 
        if (geoip.country_v4 == NULL) {
-               dns_test_end();
-               atf_tc_skip("Database not available");
+               skip();
        }
 
-       match = do_lookup_string("10.53.0.1",
-                                dns_geoip_country_code, "AU");
-       ATF_CHECK(match);
+       match = do_lookup_string("10.53.0.1", dns_geoip_country_code, "AU");
+       assert_true(match);
 
-       match = do_lookup_string("10.53.0.1",
-                                dns_geoip_country_code3, "AUS");
-       ATF_CHECK(match);
+       match = do_lookup_string("10.53.0.1", dns_geoip_country_code3, "AUS");
+       assert_true(match);
 
        match = do_lookup_string("10.53.0.1",
                                 dns_geoip_country_name, "Australia");
-       ATF_CHECK(match);
+       assert_true(match);
 
-       match = do_lookup_string("192.0.2.128",
-                                dns_geoip_country_code, "O1");
-       ATF_CHECK(match);
+       match = do_lookup_string("192.0.2.128", dns_geoip_country_code, "O1");
+       assert_true(match);
 
        match = do_lookup_string("192.0.2.128",
                                 dns_geoip_country_name, "Other");
-       ATF_CHECK(match);
-
-       dns_test_end();
+       assert_true(match);
 }
 
 /* GeoIP country (ipv6) matching */
-ATF_TC(country_v6);
-ATF_TC_HEAD(country_v6, tc) {
-       atf_tc_set_md_var(tc, "descr", "test country (ipv6) database matching");
-}
-ATF_TC_BODY(country_v6, tc) {
-       isc_result_t result;
+static void
+country_v6(void **state) {
        bool match;
 
-       UNUSED(tc);
-
-       result = dns_test_begin(NULL, true);
-       ATF_REQUIRE(result == ISC_R_SUCCESS);
+       UNUSED(state);
 
        /* Use databases from the geoip system test */
        load_geoip(TEST_GEOIP_DATA);
 
        if (geoip.country_v6 == NULL) {
-               dns_test_end();
-               atf_tc_skip("Database not available");
+               skip();
        }
 
        match = do_lookup_string_v6("fd92:7065:b8e:ffff::1",
                                    dns_geoip_country_code, "AU");
-       ATF_CHECK(match);
+       assert_true(match);
 
        match = do_lookup_string_v6("fd92:7065:b8e:ffff::1",
                                    dns_geoip_country_code3, "AUS");
-       ATF_CHECK(match);
+       assert_true(match);
 
        match = do_lookup_string_v6("fd92:7065:b8e:ffff::1",
                                    dns_geoip_country_name, "Australia");
-       ATF_CHECK(match);
-
-       dns_test_end();
+       assert_true(match);
 }
 
 /* GeoIP city (ipv4) matching */
-ATF_TC(city);
-ATF_TC_HEAD(city, tc) {
-       atf_tc_set_md_var(tc, "descr", "test city database matching");
-}
-ATF_TC_BODY(city, tc) {
-       isc_result_t result;
+static void
+city(void **state) {
        bool match;
 
-       UNUSED(tc);
-
-       result = dns_test_begin(NULL, true);
-       ATF_REQUIRE(result == ISC_R_SUCCESS);
+       UNUSED(state);
 
        /* Use databases from the geoip system test */
        load_geoip(TEST_GEOIP_DATA);
 
        if (geoip.city_v4 == NULL) {
-               dns_test_end();
-               atf_tc_skip("Database not available");
+               skip();
        }
 
        match = do_lookup_string("10.53.0.1",
                                 dns_geoip_city_continentcode, "NA");
-       ATF_CHECK(match);
+       assert_true(match);
 
        match = do_lookup_string("10.53.0.1",
                                 dns_geoip_city_countrycode, "US");
-       ATF_CHECK(match);
+       assert_true(match);
 
        match = do_lookup_string("10.53.0.1",
                                 dns_geoip_city_countrycode3, "USA");
-       ATF_CHECK(match);
+       assert_true(match);
 
        match = do_lookup_string("10.53.0.1",
                                 dns_geoip_city_countryname, "United States");
-       ATF_CHECK(match);
+       assert_true(match);
 
        match = do_lookup_string("10.53.0.1",
                                 dns_geoip_city_region, "CA");
-       ATF_CHECK(match);
+       assert_true(match);
 
        match = do_lookup_string("10.53.0.1",
                                 dns_geoip_city_regionname, "California");
-       ATF_CHECK(match);
+       assert_true(match);
 
        match = do_lookup_string("10.53.0.1",
                                 dns_geoip_city_name, "Redwood City");
-       ATF_CHECK(match);
+       assert_true(match);
 
        match = do_lookup_string("10.53.0.1",
                                 dns_geoip_city_postalcode, "94063");
-       ATF_CHECK(match);
+       assert_true(match);
 
        match = do_lookup_int("10.53.0.1", dns_geoip_city_areacode, 650);
-       ATF_CHECK(match);
+       assert_true(match);
 
        match = do_lookup_int("10.53.0.1", dns_geoip_city_metrocode, 807);
-       ATF_CHECK(match);
-
-       dns_test_end();
+       assert_true(match);
 }
 
 /* GeoIP city (ipv6) matching */
-ATF_TC(city_v6);
-ATF_TC_HEAD(city_v6, tc) {
-       atf_tc_set_md_var(tc, "descr", "test city (ipv6) database matching");
-}
-ATF_TC_BODY(city_v6, tc) {
-       isc_result_t result;
+static void
+city_v6(void **state) {
        bool match;
 
-       UNUSED(tc);
-
-       result = dns_test_begin(NULL, true);
-       ATF_REQUIRE(result == ISC_R_SUCCESS);
+       UNUSED(state);
 
        /* Use databases from the geoip system test */
        load_geoip(TEST_GEOIP_DATA);
 
        if (geoip.city_v6 == NULL) {
-               dns_test_end();
-               atf_tc_skip("Database not available");
+               skip();
        }
 
        match = do_lookup_string_v6("fd92:7065:b8e:ffff::1",
                                    dns_geoip_city_continentcode, "NA");
-       ATF_CHECK(match);
+       assert_true(match);
 
        match = do_lookup_string_v6("fd92:7065:b8e:ffff::1",
                                    dns_geoip_city_countrycode, "US");
-       ATF_CHECK(match);
+       assert_true(match);
 
        match = do_lookup_string_v6("fd92:7065:b8e:ffff::1",
                                    dns_geoip_city_countrycode3, "USA");
-       ATF_CHECK(match);
+       assert_true(match);
 
        match = do_lookup_string_v6("fd92:7065:b8e:ffff::1",
                                    dns_geoip_city_countryname,
                                    "United States");
-       ATF_CHECK(match);
+       assert_true(match);
 
        match = do_lookup_string_v6("fd92:7065:b8e:ffff::1",
                                    dns_geoip_city_region, "CA");
-       ATF_CHECK(match);
+       assert_true(match);
 
        match = do_lookup_string_v6("fd92:7065:b8e:ffff::1",
                                    dns_geoip_city_regionname, "California");
-       ATF_CHECK(match);
+       assert_true(match);
 
        match = do_lookup_string_v6("fd92:7065:b8e:ffff::1",
                                    dns_geoip_city_name, "Redwood City");
-       ATF_CHECK(match);
+       assert_true(match);
 
        match = do_lookup_string_v6("fd92:7065:b8e:ffff::1",
                                    dns_geoip_city_postalcode, "94063");
-       ATF_CHECK(match);
-
-       dns_test_end();
+       assert_true(match);
 }
 
 
 /* GeoIP region matching */
-ATF_TC(region);
-ATF_TC_HEAD(region, tc) {
-       atf_tc_set_md_var(tc, "descr", "test region database matching");
-}
-ATF_TC_BODY(region, tc) {
-       isc_result_t result;
+static void
+region(void **state) {
        bool match;
 
-       UNUSED(tc);
-
-       result = dns_test_begin(NULL, true);
-       ATF_REQUIRE(result == ISC_R_SUCCESS);
+       UNUSED(state);
 
        /* Use databases from the geoip system test */
        load_geoip(TEST_GEOIP_DATA);
 
        if (geoip.region == NULL) {
-               dns_test_end();
-               atf_tc_skip("Database not available");
+               skip();
        }
 
        match = do_lookup_string("10.53.0.1",
                                 dns_geoip_region_code, "CA");
-       ATF_CHECK(match);
+       assert_true(match);
 
        match = do_lookup_string("10.53.0.1",
                                 dns_geoip_region_name, "California");
-       ATF_CHECK(match);
+       assert_true(match);
 
        match = do_lookup_string("10.53.0.1",
                                 dns_geoip_region_countrycode, "US");
-       ATF_CHECK(match);
-
-       dns_test_end();
+       assert_true(match);
 }
 
 /*
@@ -431,53 +389,45 @@ ATF_TC_BODY(region, tc) {
  * should come from city database.  With city database unavailable, region
  * database.  Region database unavailable, country database.)
  */
-ATF_TC(best);
-ATF_TC_HEAD(best, tc) {
-       atf_tc_set_md_var(tc, "descr", "test best database matching");
-}
-ATF_TC_BODY(best, tc) {
-       isc_result_t result;
+static void
+best(void **state) {
        bool match;
 
-       UNUSED(tc);
-
-       result = dns_test_begin(NULL, true);
-       ATF_REQUIRE(result == ISC_R_SUCCESS);
+       UNUSED(state);
 
        /* Use databases from the geoip system test */
        load_geoip(TEST_GEOIP_DATA);
 
        if (geoip.region == NULL) {
-               dns_test_end();
-               atf_tc_skip("Database not available");
+               skip();
        }
 
        match = do_lookup_string("10.53.0.4",
                                 dns_geoip_countrycode, "US");
-       ATF_CHECK(match);
+       assert_true(match);
 
        match = do_lookup_string("10.53.0.4",
                                 dns_geoip_countrycode3, "USA");
-       ATF_CHECK(match);
+       assert_true(match);
 
        match = do_lookup_string("10.53.0.4",
                                 dns_geoip_countryname, "United States");
-       ATF_CHECK(match);
+       assert_true(match);
 
        match = do_lookup_string("10.53.0.4",
                                 dns_geoip_regionname, "Virginia");
-       ATF_CHECK(match);
+       assert_true(match);
 
        match = do_lookup_string("10.53.0.4",
                                 dns_geoip_region, "VA");
-       ATF_CHECK(match);
+       assert_true(match);
 
        GeoIP_delete(geoip.city_v4);
        geoip.city_v4 = NULL;
 
        match = do_lookup_string("10.53.0.4",
                                 dns_geoip_countrycode, "AU");
-       ATF_CHECK(match);
+       assert_true(match);
 
        /*
         * Note, region doesn't support code3 or countryname, so
@@ -485,215 +435,165 @@ ATF_TC_BODY(best, tc) {
         */
        match = do_lookup_string("10.53.0.4",
                                 dns_geoip_countrycode3, "CAN");
-       ATF_CHECK(match);
+       assert_true(match);
 
        match = do_lookup_string("10.53.0.4",
                                 dns_geoip_countryname, "Canada");
-       ATF_CHECK(match);
+       assert_true(match);
 
        GeoIP_delete(geoip.region);
        geoip.region = NULL;
 
        match = do_lookup_string("10.53.0.4",
                                 dns_geoip_countrycode, "CA");
-       ATF_CHECK(match);
+       assert_true(match);
 
        match = do_lookup_string("10.53.0.4",
                                 dns_geoip_countrycode3, "CAN");
-       ATF_CHECK(match);
+       assert_true(match);
 
        match = do_lookup_string("10.53.0.4",
                                 dns_geoip_countryname, "Canada");
-       ATF_CHECK(match);
-
-       dns_test_end();
+       assert_true(match);
 }
 
 
 /* GeoIP asnum matching */
-ATF_TC(asnum);
-ATF_TC_HEAD(asnum, tc) {
-       atf_tc_set_md_var(tc, "descr", "test asnum database matching");
-}
-ATF_TC_BODY(asnum, tc) {
-       isc_result_t result;
+static void
+asnum(void **state) {
        bool match;
 
-       UNUSED(tc);
-
-       result = dns_test_begin(NULL, true);
-       ATF_REQUIRE(result == ISC_R_SUCCESS);
+       UNUSED(state);
 
        /* Use databases from the geoip system test */
        load_geoip(TEST_GEOIP_DATA);
 
        if (geoip.as == NULL) {
-               dns_test_end();
-               atf_tc_skip("Database not available");
+               skip();
        }
 
 
        match = do_lookup_string("10.53.0.3", dns_geoip_as_asnum,
                                 "AS100003 Three Network Labs");
-       ATF_CHECK(match);
-
-       dns_test_end();
+       assert_true(match);
 }
 
 /* GeoIP isp matching */
-ATF_TC(isp);
-ATF_TC_HEAD(isp, tc) {
-       atf_tc_set_md_var(tc, "descr", "test isp database matching");
-}
-ATF_TC_BODY(isp, tc) {
-       isc_result_t result;
+static void
+isp(void **state) {
        bool match;
 
-       UNUSED(tc);
-
-       result = dns_test_begin(NULL, true);
-       ATF_REQUIRE(result == ISC_R_SUCCESS);
+       UNUSED(state);
 
        /* Use databases from the geoip system test */
        load_geoip(TEST_GEOIP_DATA);
 
        if (geoip.isp == NULL) {
-               dns_test_end();
-               atf_tc_skip("Database not available");
+               skip();
        }
 
        match = do_lookup_string("10.53.0.1", dns_geoip_isp_name,
                                 "One Systems, Inc.");
-       ATF_CHECK(match);
-
-       dns_test_end();
+       assert_true(match);
 }
 
 /* GeoIP org matching */
-ATF_TC(org);
-ATF_TC_HEAD(org, tc) {
-       atf_tc_set_md_var(tc, "descr", "test org database matching");
-}
-ATF_TC_BODY(org, tc) {
-       isc_result_t result;
+static void
+org(void **state) {
        bool match;
 
-       UNUSED(tc);
-
-       result = dns_test_begin(NULL, true);
-       ATF_REQUIRE(result == ISC_R_SUCCESS);
+       UNUSED(state);
 
        /* Use databases from the geoip system test */
        load_geoip(TEST_GEOIP_DATA);
 
        if (geoip.org == NULL) {
-               dns_test_end();
-               atf_tc_skip("Database not available");
+               skip();
        }
 
        match = do_lookup_string("10.53.0.2", dns_geoip_org_name,
                                 "Two Technology Ltd.");
-       ATF_CHECK(match);
-
-       dns_test_end();
+       assert_true(match);
 }
 
 /* GeoIP domain matching */
-ATF_TC(domain);
-ATF_TC_HEAD(domain, tc) {
-       atf_tc_set_md_var(tc, "descr", "test domain database matching");
-}
-ATF_TC_BODY(domain, tc) {
-       isc_result_t result;
+static void
+domain(void **state) {
        bool match;
 
-       UNUSED(tc);
-
-       result = dns_test_begin(NULL, true);
-       ATF_REQUIRE(result == ISC_R_SUCCESS);
+       UNUSED(state);
 
        /* Use databases from the geoip system test */
        load_geoip(TEST_GEOIP_DATA);
 
        if (geoip.domain == NULL) {
-               dns_test_end();
-               atf_tc_skip("Database not available");
+               skip();
        }
 
        match = do_lookup_string("10.53.0.4",
                                 dns_geoip_domain_name, "four.com");
-       ATF_CHECK(match);
-
-       dns_test_end();
+       assert_true(match);
 }
 
 /* GeoIP netspeed matching */
-ATF_TC(netspeed);
-ATF_TC_HEAD(netspeed, tc) {
-       atf_tc_set_md_var(tc, "descr", "test netspeed database matching");
-}
-ATF_TC_BODY(netspeed, tc) {
-       isc_result_t result;
+static void
+netspeed(void **state) {
        bool match;
 
-       UNUSED(tc);
-
-       result = dns_test_begin(NULL, true);
-       ATF_REQUIRE(result == ISC_R_SUCCESS);
+       UNUSED(state);
 
        /* Use databases from the geoip system test */
        load_geoip(TEST_GEOIP_DATA);
 
        if (geoip.netspeed == NULL) {
-               dns_test_end();
-               atf_tc_skip("Database not available");
+               skip();
        }
 
        match = do_lookup_int("10.53.0.1", dns_geoip_netspeed_id, 0);
-       ATF_CHECK(match);
+       assert_true(match);
 
        match = do_lookup_int("10.53.0.2", dns_geoip_netspeed_id, 1);
-       ATF_CHECK(match);
+       assert_true(match);
 
        match = do_lookup_int("10.53.0.3", dns_geoip_netspeed_id, 2);
-       ATF_CHECK(match);
+       assert_true(match);
 
        match = do_lookup_int("10.53.0.4", dns_geoip_netspeed_id, 3);
-       ATF_CHECK(match);
-
-       dns_test_end();
-}
-#else
-ATF_TC(untested);
-ATF_TC_HEAD(untested, tc) {
-       atf_tc_set_md_var(tc, "descr", "skipping geoip test");
-}
-ATF_TC_BODY(untested, tc) {
-       UNUSED(tc);
-       atf_tc_skip("GeoIP not available");
+       assert_true(match);
 }
-#endif
+#endif /* HAVE_GEOIP */
 
-/*
- * Main
- */
-ATF_TP_ADD_TCS(tp) {
+int
+main(void) {
 #ifdef HAVE_GEOIP
-       ATF_TP_ADD_TC(tp, country);
-       ATF_TP_ADD_TC(tp, country_v6);
-       ATF_TP_ADD_TC(tp, city);
-       ATF_TP_ADD_TC(tp, city_v6);
-       ATF_TP_ADD_TC(tp, region);
-       ATF_TP_ADD_TC(tp, best);
-       ATF_TP_ADD_TC(tp, asnum);
-       ATF_TP_ADD_TC(tp, isp);
-       ATF_TP_ADD_TC(tp, org);
-       ATF_TP_ADD_TC(tp, domain);
-       ATF_TP_ADD_TC(tp, netspeed);
+       const struct CMUnitTest tests[] = {
+               cmocka_unit_test_setup_teardown(country, _setup, _teardown),
+               cmocka_unit_test_setup_teardown(country_v6, _setup, _teardown),
+               cmocka_unit_test_setup_teardown(city, _setup, _teardown),
+               cmocka_unit_test_setup_teardown(city_v6, _setup, _teardown),
+               cmocka_unit_test_setup_teardown(region, _setup, _teardown),
+               cmocka_unit_test_setup_teardown(best, _setup, _teardown),
+               cmocka_unit_test_setup_teardown(asnum, _setup, _teardown),
+               cmocka_unit_test_setup_teardown(isp, _setup, _teardown),
+               cmocka_unit_test_setup_teardown(org, _setup, _teardown),
+               cmocka_unit_test_setup_teardown(domain, _setup, _teardown),
+               cmocka_unit_test_setup_teardown(netspeed, _setup, _teardown),
+       };
+
+       return (cmocka_run_group_tests(tests, NULL, NULL));
 #else
-       ATF_TP_ADD_TC(tp, untested);
-#endif
+       print_message("1..0 # Skip geoip not enabled\n");
+#endif /* HAVE_GEOIP */
+}
+
+#else /* HAVE_CMOCKA */
+
+#include <stdio.h>
 
-       return (atf_no_error());
+int
+main(void) {
+       printf("1..0 # Skipped: cmocka not available\n");
+       return (0);
 }
 
+#endif /* HAVE_CMOCKA */