From c7c58d7a4aa33009cc14f6053f7fffd51cc4c78a Mon Sep 17 00:00:00 2001 From: kang-hyuck Date: Sat, 22 Jul 2023 17:34:35 +0900 Subject: [PATCH] tests: fix t151 recv_runcmd test code. wait for recv_cmd server to process record_cmd client's data. Fixed: #1578 recv runcmd run test need result (x86_64, aarch64) Signed-off-by: kang-hyuck --- tests/t151_recv_runcmd.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/t151_recv_runcmd.py b/tests/t151_recv_runcmd.py index eaf60068a..aee9f1ced 100644 --- a/tests/t151_recv_runcmd.py +++ b/tests/t151_recv_runcmd.py @@ -1,5 +1,6 @@ #!/usr/bin/env python +import select import subprocess as sp from runtest import TestBase @@ -34,6 +35,9 @@ def prerun(self, timeout): self.pr_debug('prerun command: ' + ' '.join(recv_cmd)) self.recv_p = sp.Popen(recv_cmd, stdout=sp.PIPE, stderr=sp.PIPE) + epolls = select.epoll() + epolls.register(self.recv_p.stdout, select.EPOLLIN) + record_cmd = [TestBase.uftrace_cmd, 'record'] record_cmd += TestBase.default_opt.split() record_cmd += ['--host', 'localhost', '--port', str(self.port)] @@ -42,11 +46,16 @@ def prerun(self, timeout): record_cmd += ['t-' + self.name] self.pr_debug('prerun command: ' + ' '.join(record_cmd)) sp.call(record_cmd, stderr=sp.PIPE) + + epolls.poll(timeout=timeout) + self.recv_p.terminate() out = self.recv_p.communicate()[0].decode(errors='ignore') self.file_p.write(out) + self.file_p.flush() self.file_p.close() + epolls.close() return TestBase.TEST_SUCCESS