Skip to content

Commit

Permalink
tests: allow mount tests to run in parallel
Browse files Browse the repository at this point in the history
  • Loading branch information
mvo5 committed Nov 14, 2023
1 parent d52738d commit 854b38d
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions test/run/test_mount.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import pytest

from osbuild import devices, host, meta, mounts
from osbuild.util import linux

from ..test import TestBase

Expand All @@ -27,15 +28,21 @@ def tmpdir_fixture():

@contextmanager
def make_arguments(opts):
os.makedirs("/run/osbuild/api")
with open("/run/osbuild/api/arguments", "w", encoding="utf-8") as f:
json.dump(opts, f)
try:
yield
finally:
os.remove("/run/osbuild/api/arguments")
os.rmdir("/run/osbuild/api")

os.makedirs("/run/osbuild/", exist_ok=True)
# The lock is needed to run the test in parallel, ideally the code
# would allow to point to a different API path *or* just accept
# the data from stdin
with open("/run/osbuild/test-mount-lock", "w") as lck:
linux.fcntl_flock(lck.fileno(), linux.fcntl.F_WRLCK, wait=True)

os.makedirs("/run/osbuild/api")
with open("/run/osbuild/api/arguments", "w", encoding="utf-8") as f:
json.dump(opts, f)
try:
yield
finally:
os.remove("/run/osbuild/api/arguments")
os.rmdir("/run/osbuild/api")

@contextmanager
def make_dev_tmpfs(tmpdir):
Expand Down

0 comments on commit 854b38d

Please sign in to comment.