#endif
#if defined(HAVE_GEOIP) || defined(HAVE_GEOIP2)
+static void load_geoip(const char *dir);
+static void close_geoip(void);
+
static int
_setup(void **state) {
isc_result_t result;
result = dns_test_begin(NULL, false);
assert_int_equal(result, ISC_R_SUCCESS);
+ /* Use databases from the geoip system test */
+ load_geoip(TEST_GEOIP_DATA);
+
return (0);
}
_teardown(void **state) {
UNUSED(state);
+ close_geoip();
+
dns_test_end();
return (0);
geoip.isp = open_geoip2(dir, "GeoIP2-ISP.mmdb", &geoip_isp);
geoip.domain = open_geoip2(dir, "GeoIP2-Domain.mmdb", &geoip_domain);
}
+
+static void
+close_geoip(void) {
+ MMDB_close(&geoip_country);
+ MMDB_close(&geoip_city);
+ MMDB_close(&geoip_as);
+ MMDB_close(&geoip_isp);
+ MMDB_close(&geoip_domain);
+}
+
#elif defined(HAVE_GEOIP)
/*
* Helper functions (mostly copied from bin/named/geoip.c)
method, "NetSpeed");
}
+static void
+close_geoip(void) {
+ GeoIP_cleanup();
+}
+
static bool
do_lookup_int(const char *addr, uint8_t *scope,
dns_geoip_subtype_t subtype, int id)
UNUSED(state);
- /* Use databases from the geoip system test */
- load_geoip(TEST_GEOIP_DATA);
-
#ifdef HAVE_GEOIP2
if (geoip.country == NULL) {
skip();
UNUSED(state);
- /* Use databases from the geoip system test */
- load_geoip(TEST_GEOIP_DATA);
-
#ifdef HAVE_GEOIP2
if (geoip.country == NULL) {
skip();
UNUSED(state);
- /* Use databases from the geoip system test */
- load_geoip(TEST_GEOIP_DATA);
-
#ifdef HAVE_GEOIP2
if (geoip.city == NULL) {
skip();
UNUSED(state);
- /* Use databases from the geoip system test */
- load_geoip(TEST_GEOIP_DATA);
-
#ifdef HAVE_GEOIP2
if (geoip.city == NULL) {
skip();
UNUSED(state);
- /* Use databases from the geoip system test */
- load_geoip(TEST_GEOIP_DATA);
-
if (geoip.as == NULL) {
skip();
}
-
match = do_lookup_string("10.53.0.3", NULL,
dns_geoip_as_asnum, "AS100003");
assert_true(match);
UNUSED(state);
- /* Use databases from the geoip system test */
- load_geoip(TEST_GEOIP_DATA);
-
if (geoip.isp == NULL) {
skip();
}
UNUSED(state);
- /* Use databases from the geoip system test */
- load_geoip(TEST_GEOIP_DATA);
-
#ifdef HAVE_GEOIP2
if (geoip.as == NULL) {
skip();
UNUSED(state);
- /* Use databases from the geoip system test */
- load_geoip(TEST_GEOIP_DATA);
-
if (geoip.domain == NULL) {
skip();
}