"""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)