Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions providers/base/bin/gl_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@

# Checkbox could run in a snap container, so we need to prepend this root path
try:
CHECKBOX_RUNTIME = Path(os.environ["CHECKBOX_RUNTIME"])
# don't use $CHECKBOX_RUNTIME in Path(), it has multiple paths
CHECKBOX_RUNTIME = Path(os.environ["SNAP"]) / "checkbox-runtime"
except KeyError: # from indexing os.environ
CHECKBOX_RUNTIME = None
CHECKBOX_RUNTIME = None # pyright: ignore[reportConstantRedefinition]
GLMARK2_DATA_PATH = Path("/usr/share/glmark2")


Expand Down Expand Up @@ -151,17 +152,18 @@ def call_glmark2_validate(
# but 16, 18, 20 doesn't have this option
# and the /usr/share/glmark2 path is hard-coded inside glmark2
# by the GLMARK_DATA_PATH build macro
src = CHECKBOX_RUNTIME / GLMARK2_DATA_PATH

# do not directly truediv against GLMARK2_DATA_PATH
# absolute path on the right will overwrite the left hand side
src = CHECKBOX_RUNTIME / "usr" / "share" / "glmark2"
dst = GLMARK2_DATA_PATH
print(
"[ DEBUG ] Symlinking glmark2 data dir ({} -> {})".format(
src, dst
)
)
os.symlink(src, dst, target_is_directory=True)
# override is needed for snaps on classic ubuntu
# to allow the glmark2 command itself to be discovered
# in debian version of checkbox this line does nothing

glmark2_output = sp.check_output(
# all glmark2 programs share the same args
[glmark2_executable, "--off-screen", "--validate"],
Expand Down
6 changes: 4 additions & 2 deletions providers/base/bin/reboot_check_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@
import time
import platform

# Checkbox could run in a snap container, so we need to prepend this root path
RUNTIME_ROOT = os.getenv("CHECKBOX_RUNTIME", default="").rstrip("/")
# Snap mount point, see
# https://snapcraft.io/docs/environment-variables#heading--snap
SNAP = os.getenv("SNAP", default="").rstrip("/")
if SNAP:
RUNTIME_ROOT = "{}/checkbox-runtime".format(SNAP)
else:
RUNTIME_ROOT = "" # pyright: ignore[reportConstantRedefinition]
# global const for subprocess calls that should timeout
COMMAND_TIMEOUT_SECONDS = 30

Expand Down
3 changes: 1 addition & 2 deletions providers/base/tests/test_gl_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,7 @@ def test_cleanup_glmark2_data_symlink(

if is_snap:
mock_symlink.assert_called_once_with(
gl_support.CHECKBOX_RUNTIME
/ gl_support.GLMARK2_DATA_PATH,
PosixPath("/snap/runtime/path/usr/share/glmark2"),
PosixPath("/usr/share/glmark2"),
target_is_directory=True,
)
Expand Down
Loading