From: Josh Soref Date: Tue, 8 Jan 2019 15:50:42 +0000 (-0500) Subject: catch subprocess.check_output and raise AssertionError with the output X-Git-Tag: rec-4.2.0-alpha1~33^2~2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ff0bc6a6f9475689165a072cd51e7866ce799fc4;p=thirdparty%2Fpdns.git catch subprocess.check_output and raise AssertionError with the output --- diff --git a/regression-tests.auth-py/authtests.py b/regression-tests.auth-py/authtests.py index 3ceae7b070..d04eb3dc4a 100644 --- a/regression-tests.auth-py/authtests.py +++ b/regression-tests.auth-py/authtests.py @@ -124,8 +124,7 @@ distributor-threads=1""".format(confdir=confdir, prefix=cls._PREFIX, try: subprocess.check_output(pdnsutilCmd, stderr=subprocess.STDOUT) except subprocess.CalledProcessError as e: - print(e.output) - raise + raise AssertionError('%s failed (%d): %s' % (pdnsutilCmd, e.returncode, e.output)) @classmethod def secureZone(cls, confdir, zonename, key=None): @@ -152,8 +151,7 @@ distributor-threads=1""".format(confdir=confdir, prefix=cls._PREFIX, try: subprocess.check_output(pdnsutilCmd, stderr=subprocess.STDOUT) except subprocess.CalledProcessError as e: - print(e.output) - raise + raise AssertionError('%s failed (%d): %s' % (pdnsutilCmd, e.returncode, e.output)) @classmethod def generateAllAuthConfig(cls, confdir): diff --git a/regression-tests.dnsdist/dnsdisttests.py b/regression-tests.dnsdist/dnsdisttests.py index 91fc086b49..86789f0461 100644 --- a/regression-tests.dnsdist/dnsdisttests.py +++ b/regression-tests.dnsdist/dnsdisttests.py @@ -86,7 +86,10 @@ class DNSDistTest(unittest.TestCase): # validate config with --check-config, which sets client=true, possibly exposing bugs. testcmd = dnsdistcmd + ['--check-config'] - output = subprocess.check_output(testcmd, close_fds=True) + try: + output = subprocess.check_output(testcmd, stderr=subprocess.STDOUT, close_fds=True) + except subprocess.CalledProcessError as exc: + raise AssertionError('dnsdist --check-config failed (%d): %s' % (exc.returncode, exc.output)) if output != b'Configuration \'dnsdist_test.conf\' OK!\n': raise AssertionError('dnsdist --check-config failed: %s' % output) diff --git a/regression-tests.recursor-dnssec/recursortests.py b/regression-tests.recursor-dnssec/recursortests.py index ec1b0fce46..2f26dc7c53 100644 --- a/regression-tests.recursor-dnssec/recursortests.py +++ b/regression-tests.recursor-dnssec/recursortests.py @@ -345,8 +345,7 @@ distributor-threads=1""".format(confdir=confdir, try: subprocess.check_output(pdnsutilCmd, stderr=subprocess.STDOUT) except subprocess.CalledProcessError as e: - print(e.output) - raise + raise AssertionError('%s failed (%d): %s' % (pdnsutilCmd, e.returncode, e.output)) @classmethod def secureZone(cls, confdir, zonename, key=None): @@ -373,8 +372,7 @@ distributor-threads=1""".format(confdir=confdir, try: subprocess.check_output(pdnsutilCmd, stderr=subprocess.STDOUT) except subprocess.CalledProcessError as e: - print(e.output) - raise + raise AssertionError('%s failed (%d): %s' % (pdnsutilCmd, e.returncode, e.output)) @classmethod def generateAllAuthConfig(cls, confdir): @@ -505,8 +503,7 @@ distributor-threads=1""".format(confdir=confdir, try: subprocess.check_output(rec_controlCmd, stderr=subprocess.STDOUT) except subprocess.CalledProcessError as e: - print(e.output) - raise + raise AssertionError('%s failed (%d): %s' % (rec_controlCmd, e.returncode, e.output)) @classmethod def setUpSockets(cls): diff --git a/regression-tests.recursor-dnssec/test_basicNSEC3.py b/regression-tests.recursor-dnssec/test_basicNSEC3.py index 870ba2e343..75aef9db30 100644 --- a/regression-tests.recursor-dnssec/test_basicNSEC3.py +++ b/regression-tests.recursor-dnssec/test_basicNSEC3.py @@ -32,8 +32,7 @@ class basicNSEC3(BasicDNSSEC): try: subprocess.check_output(pdnsutilCmd, stderr=subprocess.STDOUT) except subprocess.CalledProcessError as e: - print(e.output) - raise + raise AssertionError('%s failed (%d): %s' % (pdnsutilCmd, e.returncode, e.output)) params = "1 0 100 AABBCCDDEEFF112233" @@ -50,5 +49,4 @@ class basicNSEC3(BasicDNSSEC): try: subprocess.check_output(pdnsutilCmd, stderr=subprocess.STDOUT) except subprocess.CalledProcessError as e: - print(e.output) - raise + raise AssertionError('%s failed (%d): %s' % (pdnsutilCmd, e.returncode, e.output))