From 5092ac501cf529e1a0cd32859509eb884277e58b Mon Sep 17 00:00:00 2001 From: Mark Karpilovskij Date: Mon, 5 Nov 2018 13:25:25 +0100 Subject: tests-extra: skip geoip test when MMDB not available --- tests-extra/tests/modules/geoip/test.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests-extra/tests/modules/geoip/test.py b/tests-extra/tests/modules/geoip/test.py index 15594a78d..47b80f350 100644 --- a/tests-extra/tests/modules/geoip/test.py +++ b/tests-extra/tests/modules/geoip/test.py @@ -5,7 +5,22 @@ from dnstest.test import Test from dnstest.module import ModGeoip from dnstest.utils import * +from subprocess import Popen, PIPE import random +import re + +def check_mmdb(): + '''Checks the server binary for the MMDB_open function''' + + try: + proc = Popen(ModGeoip._check_cmd(), stdout=PIPE, stderr=PIPE, + universal_newlines=True) + (out, err) = proc.communicate() + if re.search("MMDB_open", out): + return + raise Skip() + except: + raise Skip("libmaxminddb not detected") t = Test(address=4, stress=False) knot = t.server("knot") @@ -14,6 +29,8 @@ zone = t.zone("example.com.", storage=".") t.link(zone, knot) ModGeoip.check() +check_mmdb() + mod_geoip = ModGeoip(t.data_dir + "geo.conf", "geodb", t.data_dir + "db.mmdb", ["country/iso_code", "(id)city/geoname_id"]) knot.add_module(zone, mod_geoip); -- cgit v1.2.3