test: give osbuild time to clean up on SIGINT
When the test runner receives SIGINT, osbuild's mounts stay around. osbuild handles SIGING correctly, but it doesn't have time before being killed because it's parent went away. Fix this by waiting on it explicitly in the test runner. Fixes #119
This commit is contained in:
parent
3e00117d35
commit
8d62bed7e4
1 changed files with 14 additions and 5 deletions
|
|
@ -40,13 +40,22 @@ class TestCase(unittest.TestCase):
|
|||
osbuild_cmd.append("--build-pipeline")
|
||||
osbuild_cmd.append(build_pipeline)
|
||||
|
||||
p = subprocess.Popen(osbuild_cmd, encoding="utf-8", stdin=subprocess.PIPE, stdout=subprocess.PIPE)
|
||||
if input:
|
||||
p.stdin.write(input)
|
||||
p.stdin.close()
|
||||
try:
|
||||
r = subprocess.run(osbuild_cmd, encoding="utf-8", input=input, stdout=subprocess.PIPE, check=True)
|
||||
except subprocess.CalledProcessError as e:
|
||||
print(e.stdout)
|
||||
raise e from None
|
||||
r = p.wait()
|
||||
if r != 0:
|
||||
print(p.stdout.read())
|
||||
self.assertEqual(r, 0)
|
||||
except KeyboardInterrupt:
|
||||
# explicitly wait again to let osbuild clean up
|
||||
p.wait()
|
||||
raise
|
||||
|
||||
result = json.loads(r.stdout)
|
||||
result = json.load(p.stdout)
|
||||
p.stdout.close()
|
||||
return result["tree_id"], result["output_id"]
|
||||
|
||||
def run_tree_diff(self, tree1, tree2):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue