diff --git a/test/mavsdk_tests/mavsdk_test_runner.py b/test/mavsdk_tests/mavsdk_test_runner.py index 9f0a5be8b7..3562c60b9d 100755 --- a/test/mavsdk_tests/mavsdk_test_runner.py +++ b/test/mavsdk_tests/mavsdk_test_runner.py @@ -325,12 +325,13 @@ class Tester: test_timeout_s = test['timeout_min']*60 while self.active_runners[-1].time_elapsed_s() < test_timeout_s: returncode = self.active_runners[-1].poll() + + self.collect_runner_output() + if returncode is not None: is_success = (returncode == 0) break - self.collect_runner_output() - else: print(colorize( "Test timeout of {} mins triggered!". @@ -439,14 +440,15 @@ class Tester: max_name = max(len(runner.name) for runner in self.active_runners) for runner in self.active_runners: - output = runner.get_output() - if not output: - continue + while True: + line = runner.get_output_line() + if not line: + break - output = self.add_name_prefix(max_name, runner.name, output) - self.add_to_combined_log(output) - if self.verbose: - print(output, end="") + line = self.add_name_prefix(max_name, runner.name, line) + self.add_to_combined_log(line) + if self.verbose: + print(line, end="") def start_combined_log(self, filename: str) -> None: self.log_fd = open(filename, 'w') diff --git a/test/mavsdk_tests/process_helper.py b/test/mavsdk_tests/process_helper.py index 71e2f94663..26c8b94542 100644 --- a/test/mavsdk_tests/process_helper.py +++ b/test/mavsdk_tests/process_helper.py @@ -72,6 +72,8 @@ class Runner: line = self.process.stdout.readline() if line == "\n": continue + if not line: + continue self.output_queue.put(line) self.log_fd.write(line) self.log_fd.flush() @@ -89,11 +91,12 @@ class Runner: print("stopped.") return errno.ETIMEDOUT - def get_output(self) -> Optional[str]: - try: - return self.output_queue.get(block=True, timeout=0.1) - except queue.Empty: - return None + def get_output_line(self) -> Optional[str]: + while True: + try: + return self.output_queue.get(block=True, timeout=0.1) + except queue.Empty: + return None def stop(self) -> int: atexit.unregister(self.stop)