Skip to content

Commit

Permalink
tests: fix t151 recv_runcmd test code.
Browse files Browse the repository at this point in the history
wait for recv_cmd server to process record_cmd client's data.

Fixed: namhyung#1578 recv runcmd run test need result (x86_64, aarch64)
Signed-off-by: kang-hyuck <[email protected]>
  • Loading branch information
kang-hyuck authored and namhyung committed Jul 26, 2023
1 parent 2f6302c commit c7c58d7
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tests/t151_recv_runcmd.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python

import select
import subprocess as sp

from runtest import TestBase
Expand Down Expand Up @@ -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)]
Expand All @@ -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

Expand Down

0 comments on commit c7c58d7

Please sign in to comment.