Skip to content

Commit

Permalink
Packetbeat tests write log output on fail
Browse files Browse the repository at this point in the history
Write the packetbeat log output to the test output, in case of packetbeat exit
code does not match the expected exit code
  • Loading branch information
urso committed Jun 23, 2017
1 parent 7f87b55 commit ea48ebd
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions packetbeat/tests/system/packetbeat.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit ea48ebd

Please sign in to comment.