Skip to content

Commit 96e2349

Browse files
fix: make TestCheckSocketRoundTrip resilient to restricted CI containers
GitHub Actions containers block bind-mounts even with --cap-add SYS_ADMIN. The test now falls back to a plain regular file for /dev/null (functionally equivalent for the check child) when the bind mount fails, keeping the stub -> socket -> chroot round-trip test green in the distro matrix.
1 parent 3f1ee48 commit 96e2349

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

pkg/sandbox/check_test.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,13 +209,16 @@ func TestCheckSocketRoundTrip(t *testing.T) {
209209
os.MkdirAll(filepath.Join(Rootfs, "home", "ahmed", "level1", "answer"), 0755)
210210

211211
// The sandbox child normally bind-mounts /dev/null before the shell starts;
212-
// replicate it so the check child has a working /dev/null.
212+
// replicate it so the check child has a working /dev/null. If the host
213+
// blocks mounts (e.g. an unprivileged CI container), fall back to the plain
214+
// regular file — functionally equivalent for the check child.
213215
os.MkdirAll(filepath.Join(Rootfs, "dev"), 0755)
214216
os.WriteFile(filepath.Join(Rootfs, "dev", "null"), nil, 0666)
215217
if err := syscall.Mount("/dev/null", filepath.Join(Rootfs, "dev", "null"), "", syscall.MS_BIND, ""); err != nil {
216-
t.Fatalf("mount /dev/null: %v", err)
218+
t.Logf("bind-mount /dev/null unavailable (%v); using regular file", err)
219+
} else {
220+
defer syscall.Unmount(filepath.Join(Rootfs, "dev", "null"), syscall.MNT_FORCE)
217221
}
218-
defer syscall.Unmount(filepath.Join(Rootfs, "dev", "null"), syscall.MNT_FORCE)
219222

220223
if _, err := WriteCheckStubs(); err != nil {
221224
t.Fatal(err)

0 commit comments

Comments
 (0)