From e2fe861be75ce3d815d4da9122b1821eb099d6fd Mon Sep 17 00:00:00 2001 From: Dirk Engling Date: Mon, 2 Nov 2026 02:24:05 +0100 Subject: add test for the version report fascilities --- tests/integration/test_version.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 tests/integration/test_version.py (limited to 'tests/integration/test_version.py') diff --git a/tests/integration/test_version.py b/tests/integration/test_version.py new file mode 100644 index 0000000..66f570d --- /dev/null +++ b/tests/integration/test_version.py @@ -0,0 +1,36 @@ +"""The -v report, which is where a build says what went into it. + +Driving the binary is the only way to see this: the feature list is a table +of #ifdefs, so it is only true for the flags the binary itself was built with. +""" + +import subprocess +import unittest + +from harness import TRACKER + + +class VersionFlag(unittest.TestCase): + def report(self): + # -v writes to stderr and exits before it binds anything + done = subprocess.run([TRACKER, "-v"], capture_output=True, timeout=30) + self.assertEqual(done.returncode, 0, done.stderr) + return done.stderr.decode() + + def test_first_line_names_the_release(self): + # The commit in brackets is there in a checkout and in a release + # tarball, and absent in a build that had neither to ask. + first = self.report().splitlines()[0] + self.assertRegex(first, r"^opentracker \d+\.\d+\.\d+( \(\S+\))?$") + + def test_names_the_event_mechanism(self): + self.assertRegex(self.report(), r"(?m)^events: (epoll|kqueue|poll)$") + + def test_lists_the_features_this_build_has(self): + # The Makefile builds this binary with these and not with those, so a + # feature table that stops following the build fails here. + report = self.report() + for want in ("WANT_KEEPALIVE", "WANT_ACCESSLIST_BLACK", "WANT_DYNAMIC_ACCESSLIST"): + self.assertIn(want, report) + for unwanted in ("WANT_SPOT_WOODPECKER", "WANT_V4_ONLY", "WANT_RESTRICT_STATS"): + self.assertNotIn(unwanted, report) -- cgit v1.3