static MMDB_s geoip_country, geoip_city, geoip_as, geoip_isp, geoip_domain;
+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.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);
+}
+
static bool
do_lookup_string(const char *addr, dns_geoip_subtype_t subtype,
const char *string)
UNUSED(state);
- /* Use databases from the geoip system test */
- load_geoip(TEST_GEOIP_DATA);
-
if (geoip.country == NULL) {
skip();
}
UNUSED(state);
- /* Use databases from the geoip system test */
- load_geoip(TEST_GEOIP_DATA);
-
if (geoip.country == NULL) {
skip();
}
UNUSED(state);
- /* Use databases from the geoip system test */
- load_geoip(TEST_GEOIP_DATA);
-
if (geoip.city == NULL) {
skip();
}
UNUSED(state);
- /* Use databases from the geoip system test */
- load_geoip(TEST_GEOIP_DATA);
-
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", 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);
-
if (geoip.as == NULL) {
skip();
}
UNUSED(state);
- /* Use databases from the geoip system test */
- load_geoip(TEST_GEOIP_DATA);
-
if (geoip.domain == NULL) {
skip();
}