diff --git a/tests/integration.mk b/tests/integration.mk index 7c9307b6322cacb286e323343775e7d65f176ed4..685951244fcde8e126cb517827d73182c3130a7c 100644 --- a/tests/integration.mk +++ b/tests/integration.mk @@ -27,6 +27,6 @@ $(libfaketime): $(libfaketime_DIR)/Makefile @CFLAGS="" $(MAKE) -C $(libfaketime_DIR) check-integration: $(libfaketime) - $(preload_LIBS) $(preload_syms) tests/test_integration.py $(TESTS) $(abspath daemon/kresd) ./kresd.j2 config + @$(preload_LIBS) $(preload_syms) tests/test_integration.py $(TESTS) $(abspath daemon/kresd) ./kresd.j2 config .PHONY: check-integration diff --git a/tests/pydnstest/scenario.py b/tests/pydnstest/scenario.py index a0f22ff736929928da2dffc3dd2ca733455277f9..159d5b83a4988f50f533aba11e9cc0af494d3cfc 100644 --- a/tests/pydnstest/scenario.py +++ b/tests/pydnstest/scenario.py @@ -9,6 +9,11 @@ import itertools import time from datetime import datetime +def dprint(msg): + """ Verbose logging (if enabled). """ + if 'VERBOSE' in os.environ: + print(msg) + class Entry: """ Data entry represents scripted message and extra metadata, notably match criteria and reply adjustments. @@ -86,7 +91,7 @@ class Entry: if raw_value is not None: got = binascii.hexlify(raw_value) if expected != got: - print "expected '",expected,"', got '",got,"'" + print("expected '",expected,"', got '",got,"'") raise Exception("comparsion failed") def set_match(self, fields): @@ -273,7 +278,9 @@ class Step: def play(self, ctx, peeraddr): """ Play one step from a scenario. """ + dprint('=> %d\t%s' % (self.id, self.type)) if self.type == 'QUERY': + dprint(self.data[0].message.to_text()) return self.__query(ctx, peeraddr) elif self.type == 'CHECK_OUT_QUERY': pass # Ignore @@ -292,13 +299,13 @@ class Step: raise Exception("response definition required") expected = self.data[0] if expected.is_raw_data_entry is True: - expected.cmp_raw(ctx.last_raw_answer); + dprint(ctx.last_raw_answer.to_text()) + expected.cmp_raw(ctx.last_raw_answer) else: - if ctx.last_answer is None : + if ctx.last_answer is None: raise Exception("no answer from preceding query") expected.match(ctx.last_answer) - - + dprint(ctx.last_answer.to_text()) def __query(self, ctx, peeraddr): """ Resolve a query. """ @@ -307,9 +314,6 @@ class Step: if self.data[0].is_raw_data_entry is True: data_to_wire = self.data[0].raw_data else: - #msg = self.data[0].message - #msg.use_edns(edns = 1) - #data_to_wire = msg.to_wire() # Don't use a message copy as the EDNS data portion is not copied. data_to_wire = self.data[0].message.to_wire() # Send query to client and wait for response diff --git a/tests/pydnstest/testserver.py b/tests/pydnstest/testserver.py index ab131e84b0a4402b4fd59ff5e4cbf3728afca149..a66b05b20b8a6c65387fee4f3c4e68f6912a4523 100644 --- a/tests/pydnstest/testserver.py +++ b/tests/pydnstest/testserver.py @@ -228,7 +228,7 @@ class TestServer: address = "::1" else: raise Exception("[start_srv] unsupported socket type {sock_type}".format(sock_type=type)) - if port == 0 or port is None: + if port == 0 or port is None: port = 53 if (self.thread is None): diff --git a/tests/test_integration.py b/tests/test_integration.py index 172c0c5eb1d3815d33a2c861e2c84e1fd9a01954..dc76fe878149a9f39ba06a41885916049d5f7dea 100755 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -287,6 +287,7 @@ if __name__ == '__main__': print "\t<additional> - additional parameters for <binary>" sys.exit(0) + test_platform() path_to_scenario = "" binary_name = "" template_name = "" @@ -306,15 +307,10 @@ if __name__ == '__main__': j2template_env = jinja2.Environment(loader=j2template_loader) j2template = j2template_env.get_template(template_name) - # Self-tests first + # Scan for scenarios test = test.Test() - test.add('integration/platform', test_platform) - if test.run() != 0: - sys.exit(1) - else: - # Scan for scenarios - for arg in [path_to_scenario]: - objects = find_objects(arg) - for path in objects: - test.add(path, play_object, path, binary_name, config_name, j2template, binary_additional_pars) - sys.exit(test.run()) + for arg in [path_to_scenario]: + objects = find_objects(arg) + for path in objects: + test.add(path, play_object, path, binary_name, config_name, j2template, binary_additional_pars) + sys.exit(test.run()) diff --git a/tests/tests.mk b/tests/tests.mk index 870f749ba21236f19aa81ae81696936bd522511c..b0fe33b9ad2889de43ebc2fb2656b4b75a866b9c 100644 --- a/tests/tests.mk +++ b/tests/tests.mk @@ -1,10 +1,10 @@ # Preload libraries preload_PATH := $(abspath contrib/libfaketime/src) ifeq ($(PLATFORM),Darwin) - preload_LIBS := @DYLD_FORCE_FLAT_NAMESPACE=1 \ + preload_LIBS := DYLD_FORCE_FLAT_NAMESPACE=1 \ DYLD_LIBRARY_PATH="$(preload_PATH):${DYLD_LIBRARY_PATH}" else - preload_LIBS := @LD_LIBRARY_PATH="$(preload_PATH):${LD_LIBRARY_PATH}" + preload_LIBS := LD_LIBRARY_PATH="$(preload_PATH):${LD_LIBRARY_PATH}" endif # Unit tests diff --git a/tests/unit.mk b/tests/unit.mk index 3b69799d66cd901e1f588a2e11acb36cd3bd46cf..ade5a2027f334446f77ddbba86eea8e02dbe22ad 100644 --- a/tests/unit.mk +++ b/tests/unit.mk @@ -30,13 +30,13 @@ $(1)_SOURCES := tests/$(1).c $(1)_LIBS := $(tests_LIBS) $(1)_DEPEND := $(tests_DEPEND) $(call make_bin,$(1),tests) -$(1)-run: $$($(1)) - $(call preload_LIBS) $$< -.PHONY: $(1)-run +$(1): $$($(1)) + @$$< +.PHONY: $(1) endef # Targets $(foreach test,$(tests_BIN),$(eval $(call make_test,$(test)))) -check-unit: $(foreach test,$(tests_BIN),$(test)-run) +check-unit: $(foreach test,$(tests_BIN),$(test)) .PHONY: check-unit