From ea48ebd82b87cb2e1d2d0dc73d8162e867ea62ef Mon Sep 17 00:00:00 2001 From: urso Date: Fri, 23 Jun 2017 16:18:59 +0200 Subject: [PATCH] Packetbeat tests write log output on fail Write the packetbeat log output to the test output, in case of packetbeat exit code does not match the expected exit code --- packetbeat/tests/system/packetbeat.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/packetbeat/tests/system/packetbeat.py b/packetbeat/tests/system/packetbeat.py index 7202ee48ab6..2d142ba87c7 100644 --- a/packetbeat/tests/system/packetbeat.py +++ b/packetbeat/tests/system/packetbeat.py @@ -61,9 +61,15 @@ def run_packetbeat(self, pcap, stdout=outputfile, stderr=subprocess.STDOUT) actual_exit_code = proc.wait() - assert actual_exit_code == exit_code, "Expected exit code to be %d, but it was %d" % ( - exit_code, actual_exit_code) - return actual_exit_code + + if actual_exit_code != exit_code: + print("============ Log Output =====================") + with open(os.path.join(self.working_dir, output)) as f: + print(f.read()) + print("============ Log End Output =====================") + assert actual_exit_code == exit_code, "Expected exit code to be %d, but it was %d" % ( + exit_code, actual_exit_code) + return actual_exit_code def start_packetbeat(self, cmd="../../packetbeat.test",