Skip to content

Commit 59451a3

Browse files
committed
test(functional): factor busybox skip check into requireBusybox
Six tests had a copy-pasted `[[ $busybox =~ busybox ]]` check that only verifies the variable contains the substring "busybox" — it passes even when the path doesn't exist. Factor into `requireBusybox` in functions.sh using `[[ -x "$busybox" ]]` instead, which at least catches an unset variable, a nonexistent path, or a non-executable file. Note this still doesn't probe whether a nested build sandbox can actually exec the path — on some remote builders the host path is valid but the chroot-store sandbox cannot reach it. The comment in requireBusybox documents that limitation; such environments must skip these tests explicitly.
1 parent f2d4cc7 commit 59451a3

7 files changed

Lines changed: 18 additions & 6 deletions

File tree

tests/functional/build-remote-trustless-should-fail-0.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ restartDaemon
99

1010
requireSandboxSupport
1111
requiresUnprivilegedUserNamespaces
12-
[[ $busybox =~ busybox ]] || skipTest "no busybox"
12+
requireBusybox
1313

1414
unset NIX_STORE_DIR
1515

tests/functional/build-remote-trustless.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
requireSandboxSupport
88
requiresUnprivilegedUserNamespaces
9-
[[ "$busybox" =~ busybox ]] || skipTest "no busybox"
9+
requireBusybox
1010

1111
unset NIX_STORE_DIR
1212

tests/functional/build-remote-with-mounted-ssh-ng.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
source common.sh
44

55
requireSandboxSupport
6-
[[ $busybox =~ busybox ]] || skipTest "no busybox"
6+
requireBusybox
77

88
enableFeatures mounted-ssh-store
99

tests/functional/build-remote.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
# shellcheck shell=bash
22

3+
# shellcheck disable=SC2154
34
: "${file?must be defined by caller (remote building test case using this)}"
45

56
requireSandboxSupport
67
requiresUnprivilegedUserNamespaces
7-
[[ "${busybox-}" =~ busybox ]] || skipTest "no busybox"
8+
requireBusybox
89

910
# Avoid store dir being inside sandbox build-dir
1011
unset NIX_STORE_DIR

tests/functional/common/functions.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,17 @@ requireSandboxSupport () {
162162
canUseSandbox || skipTest "Sandboxing not supported"
163163
}
164164

165+
requireBusybox() {
166+
# Check executability, not just that the path contains "busybox" — the
167+
# variable is @sandbox_shell@ from meson and is empty when not found.
168+
# Note: this does not probe whether a nested build sandbox can exec the
169+
# path; on some remote builders the host path is valid but the sandbox
170+
# built from a chroot store cannot reach it. Such environments must skip
171+
# these tests explicitly.
172+
# shellcheck disable=SC2154 # set by subst-vars.sh
173+
[[ -x "$busybox" ]] || skipTest "no busybox"
174+
}
175+
165176
requireGit() {
166177
[[ $(type -p git) ]] || skipTest "Git not installed"
167178
}

tests/functional/local-overlay-store/common.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export LIBMOUNT_FORCE_MOUNT2=always
2929

3030
requireEnvironment () {
3131
requireSandboxSupport
32-
[[ $busybox =~ busybox ]] || skipTest "no busybox"
32+
requireBusybox
3333
if [[ $(uname) != Linux ]]; then skipTest "Need Linux for overlayfs"; fi
3434
needLocalStore "The test uses --store always so we would just be bypassing the daemon"
3535
}

tests/functional/supplementary-groups.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
source common.sh
44

55
requireSandboxSupport
6-
[[ $busybox =~ busybox ]] || skipTest "no busybox"
6+
requireBusybox
77
if ! command -p -v unshare; then skipTest "Need unshare"; fi
88
needLocalStore "The test uses --store always so we would just be bypassing the daemon"
99

0 commit comments

Comments
 (0)