Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: fix t151 recv_runcmd test code. #1765

Merged
merged 1 commit into from Jul 26, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions tests/t151_recv_runcmd.py
@@ -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()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you need to close the epoll object here.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think close() implies flush() but maybe it's better to have it explicitly.

epolls.close()

return TestBase.TEST_SUCCESS

Expand Down