Skip to content

Commit

Permalink
Merge pull request #2709 from dtrudg/pick-2708
Browse files Browse the repository at this point in the history
 e2e: fix OCI profile requirements (4.1)
  • Loading branch information
dtrudg authored Mar 5, 2024
2 parents 64a8a60 + 28e2d4d commit 96e05b7
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
3 changes: 2 additions & 1 deletion e2e/internal/e2e/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,8 @@ func fakerootRequirements(t *testing.T) {
func ociRequirements(t *testing.T) {
require.Kernel(t, 4, 18) // FUSE in userns
require.UserNamespace(t)
require.Command(t, "runc")
require.OneCommand(t, []string{"runc", "crun"})
require.OneCommand(t, []string{"sqfstar", "tar2sqfs"})

uid := uint32(origUID)

Expand Down
17 changes: 17 additions & 0 deletions internal/pkg/test/tool/require/require.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,23 @@ func Command(t *testing.T, command string) {
t.Skipf("%s command not found in $PATH", command)
}

// OneCommand checks if one of the provided commands is available (via
// Singularity's internal bin.FindBin() facility, or else simply on the PATH).
// If none are found, the current test is skipped with a message.
func OneCommand(t *testing.T, commands []string) {
for _, c := range commands {
if _, err := bin.FindBin(c); err == nil {
return
}

if _, err := exec.LookPath(c); err == nil {
return
}
}

t.Skipf("%v commands not found in $PATH", commands)
}

// Seccomp checks that seccomp is enabled, if not the
// current test is skipped with a message.
func Seccomp(t *testing.T) {
Expand Down
3 changes: 3 additions & 0 deletions internal/pkg/util/bin/bin.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ func FindBin(name string) (path string, err error) {
// unprivileged overlays
case "fuse-overlayfs":
return findOnPath(name)
// tar to squashfs tools for OCI-mode image conversion
case "tar2sqfs", "sqfstar":
return findOnPath(name)
default:
return "", fmt.Errorf("executable name %q is not known to FindBin", name)
}
Expand Down

0 comments on commit 96e05b7

Please sign in to comment.