From 661c223eda641eeb2ee02db3d1e1cd4e5cd583f7 Mon Sep 17 00:00:00 2001 From: Max Romanov Date: Wed, 22 Jul 2020 10:05:10 +0300 Subject: Tests: switching stdout to blocking before printing log. This is another attempt to fix the following error message: BlockingIOError: [Errno 11] write could not complete without blocking --- test/unit/main.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'test/unit/main.py') diff --git a/test/unit/main.py b/test/unit/main.py index 408cf31c..8bca888c 100644 --- a/test/unit/main.py +++ b/test/unit/main.py @@ -407,8 +407,11 @@ class TestUnit(unittest.TestCase): print('Path to unit.log:\n' + path + '\n') if TestUnit.print_log: + os.set_blocking(sys.stdout.fileno(), True) + sys.stdout.flush() + if data is None: with open(path, 'r', encoding='utf-8', errors='ignore') as f: - data = f.read() - - print(data) + shutil.copyfileobj(f, sys.stdout) + else: + sys.stdout.write(data) -- cgit From dc1377dc489937abcc6a5d0dcbfa628e0e6bdf1c Mon Sep 17 00:00:00 2001 From: Andrei Zeliankou Date: Tue, 28 Jul 2020 03:09:50 +0100 Subject: Tests: style. --- test/unit/main.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'test/unit/main.py') diff --git a/test/unit/main.py b/test/unit/main.py index 8bca888c..253ddc71 100644 --- a/test/unit/main.py +++ b/test/unit/main.py @@ -58,7 +58,6 @@ class TestUnit(unittest.TestCase): if prereq_version == 'all': for version in available_versions: self.application_type = type + ' ' + version - self.application_version = version super().run(result) elif prereq_version == 'any': self.application_type = type + ' ' + available_versions[0] @@ -166,7 +165,7 @@ class TestUnit(unittest.TestCase): self._run() def _run(self): - build_dir = os.path.join(self.pardir, 'build') + build_dir = self.pardir + '/build' self.unitd = build_dir + '/unitd' if not os.path.isfile(self.unitd): -- cgit From 355ed9697d10f163f4b96bc459f9c402aefa5d55 Mon Sep 17 00:00:00 2001 From: Andrei Zeliankou Date: Tue, 28 Jul 2020 04:53:32 +0100 Subject: Tests: fixed double stop() call for some tests. --- test/unit/main.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'test/unit/main.py') diff --git a/test/unit/main.py b/test/unit/main.py index 253ddc71..83aa9139 100644 --- a/test/unit/main.py +++ b/test/unit/main.py @@ -201,6 +201,8 @@ class TestUnit(unittest.TestCase): self._print_log() exit("Could not start unit") + self._started = True + self.skip_alerts = [ r'read signalfd\(4\) failed', r'sendmsg.+failed', @@ -209,7 +211,7 @@ class TestUnit(unittest.TestCase): self.skip_sanitizer = False def tearDown(self): - stop_errs = self.stop() + self.stop() # detect errors and failures for current test @@ -244,18 +246,21 @@ class TestUnit(unittest.TestCase): else: self._print_log() - self.assertListEqual(stop_errs, [None, None], 'stop errors') + self.assertListEqual(self.stop_errors, [None, None], 'stop errors') def stop(self): - errors = [] + if not self._started: + return + + self.stop_errors = [] - errors.append(self._stop()) + self.stop_errors.append(self._stop()) - errors.append(self.stop_processes()) + self.stop_errors.append(self.stop_processes()) atexit.unregister(self.stop) - return errors + self._started = False def _stop(self): if self._p.poll() is not None: -- cgit