aboutsummaryrefslogtreecommitdiffhomepage
path: root/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'cmd')
-rw-r--r--cmd/hakurei/testsuite/main.go50
-rw-r--r--cmd/hakurei/testsuite/sandbox/main.go2
2 files changed, 25 insertions, 27 deletions
diff --git a/cmd/hakurei/testsuite/main.go b/cmd/hakurei/testsuite/main.go
index 7f8a14b3..220b8a2a 100644
--- a/cmd/hakurei/testsuite/main.go
+++ b/cmd/hakurei/testsuite/main.go
@@ -75,15 +75,14 @@ func checkHakurei(
dbusEnv string,
name, long string,
- scan, verbose, insecure bool,
- retry int,
+ flags, retry int,
processConfig func(c *hst.Config),
f func(p hst.State, pid int) error,
checkOutput func(output string) bool,
wantCode ...int,
) {
- if !scan && f != nil {
+ if flags&testsuite.SHScan == 0 && f != nil {
log.Fatalf("(%s) cannot inspect without scanning", name)
}
if checkOutput == nil {
@@ -137,12 +136,11 @@ func checkHakurei(
checkHakurei(
ctx, wg, cred, dbusEnv,
name, long,
- scan, verbose, insecure,
- retry-1,
+ flags, retry-1,
processConfig, f,
checkOutput, wantCode...,
)
- }, scan, false, verbose, insecure, c,
+ }, flags, c,
)
if f != nil {
@@ -151,7 +149,7 @@ func checkHakurei(
}
}
- if scan {
+ if flags&testsuite.SHScan != 0 {
testsuite.MustRun(
cred, testsuite.SessionEnv(dbusEnv),
"hakurei", "kill", p.ID.String(),
@@ -351,7 +349,7 @@ func main() {
output,
)
}
- }, false, false, false, false, &hst.Config{
+ }, 0, &hst.Config{
Container: &hst.ContainerConfig{
Shell: absNonexistent,
Home: absNonexistent,
@@ -366,13 +364,13 @@ func main() {
checkHakurei(
ctx, &wg, &cred, dbusEnv,
"indirect-termination", "indirect termination",
- true, false, false, 0, nil, nil, nil,
+ testsuite.SHScan, 0, nil, nil, nil,
)
checkHakurei(
ctx, &wg, &cred, dbusEnv,
"immediate-termination", "immediate termination",
- true, false, false, 0, func(c *hst.Config) {
+ testsuite.SHScan, 0, func(c *hst.Config) {
c.Container.WaitDelay = -1
}, nil, nil, 254,
)
@@ -380,7 +378,7 @@ func main() {
checkHakurei(
ctx, &wg, &cred, dbusEnv,
"shim-poke", "unexpected shim notification",
- true, true, false, 0, nil, func(p hst.State, pid int) error {
+ testsuite.SHScan|testsuite.SHVerbose, 0, nil, func(p hst.State, pid int) error {
if err := syscall.Kill(p.ShimPID, syscall.SIGCONT); err != nil {
return os.NewSyscallError("kill", err)
}
@@ -396,7 +394,7 @@ func main() {
checkHakurei(
ctx, &wg, &cred, dbusEnv,
"reject-deprecated", "reject insecure configuration",
- false, false, false, 0, func(c *hst.Config) {
+ 0, 0, func(c *hst.Config) {
c.Enablements = new(hst.EPulse)
}, nil, func(output string) bool {
return output == "hakurei: enablement PulseAudio is insecure "+
@@ -407,7 +405,7 @@ func main() {
checkHakurei(
ctx, &wg, &cred, dbusEnv,
"pipewire-pulse", "pipewire proxying behaviour",
- false, false, false, 0, func(c *hst.Config) {
+ 0, 0, func(c *hst.Config) {
c.Enablements = new(hst.EPipeWire)
c.Container.Path = prefix.Append("bin", "pactl")
c.Container.Args = []string{"pactl", "info"}
@@ -451,7 +449,7 @@ func main() {
checkHakurei(
ctx, &wg, &cred, dbusEnv,
"pipewire-security", "pipewire SecurityContext",
- false, false, false, 32, func(c *hst.Config) {
+ 0, 32, func(c *hst.Config) {
c.Enablements = new(hst.EPipeWire)
c.Container.Path = prefix.Append("bin", "pactl")
c.Container.Args = []string{
@@ -468,7 +466,7 @@ func main() {
checkHakurei(
ctx, &wg, &cred, dbusEnv,
"pipewire-direct-failure", "pipewire cover direct access",
- false, false, false, 0, func(c *hst.Config) {
+ 0, 0, func(c *hst.Config) {
c.Enablements = new(hst.EPipeWire)
c.Container.Path = prefix.Append("bin", "pw-dump")
c.Container.Args = []string{"pw-dump"}
@@ -480,7 +478,7 @@ func main() {
checkHakurei(
ctx, &wg, &cred, dbusEnv,
"pipewire-direct", "pipewire direct access",
- false, false, true, 0, func(c *hst.Config) {
+ testsuite.SHInsecure, 0, func(c *hst.Config) {
c.Enablements = new(hst.EPipeWire)
c.DirectPipeWire = true
c.Container.Path = prefix.Append("bin", "pw-dump")
@@ -493,7 +491,7 @@ func main() {
checkHakurei(
ctx, &wg, &cred, dbusEnv,
"wayland-client", "wayland client",
- true, false, false, 0, func(c *hst.Config) {
+ testsuite.SHScan, 0, func(c *hst.Config) {
c.Enablements = new(hst.EWayland)
c.Container.Path = prefix.Append("bin", "foot")
c.Container.Args = []string{"foot"}
@@ -511,7 +509,7 @@ func main() {
checkHakurei(
ctx, &wg, &cred, dbusEnv,
"wayland-security-context", "wayland security-context-v1",
- false, false, false, 0, func(c *hst.Config) {
+ 0, 0, func(c *hst.Config) {
c.Enablements = new(hst.EWayland)
c.Container.Path = prefix.Append("bin", "wayland-info")
c.Container.Args = []string{"wayland-info"}
@@ -526,7 +524,7 @@ func main() {
checkHakurei(
ctx, &wg, &cred, dbusEnv,
"wlr-screencopy-unstable-v1", "direct wlr-screencopy-unstable-v1",
- false, false, true, 0, func(c *hst.Config) {
+ testsuite.SHInsecure, 0, func(c *hst.Config) {
c.Enablements = new(hst.EWayland)
c.DirectWayland = true
c.Container.Path = prefix.Append("bin", "wayland-info")
@@ -544,7 +542,7 @@ func main() {
checkHakurei(
ctx, &wg, &cred, dbusEnv,
"direct-wayland-client", "direct wayland client",
- true, false, true, 0, func(c *hst.Config) {
+ testsuite.SHScan|testsuite.SHInsecure, 0, func(c *hst.Config) {
c.Enablements = new(hst.EWayland)
c.DirectWayland = true
c.Container.Path = prefix.Append("bin", "foot")
@@ -564,7 +562,7 @@ func main() {
checkHakurei(
ctx, &wg, &cred, dbusEnv,
"xwayland-client", "xwayland client",
- false, false, false, 32, func(c *hst.Config) {
+ 0, 32, func(c *hst.Config) {
c.Enablements = new(hst.EX11)
c.Container.Path = prefix.Append("bin", "xset")
c.Container.Args = []string{"xset", "q"}
@@ -577,7 +575,7 @@ func main() {
checkHakurei(
ctx, &wg, &cred, dbusEnv,
"dbus", "proxied dbus call",
- false, false, false, 0, func(c *hst.Config) {
+ 0, 0, func(c *hst.Config) {
c.Enablements = new(hst.EDBus)
c.SessionBus = &hst.BusConfig{
Talk: []string{"org.freedesktop.Notifications"},
@@ -596,7 +594,7 @@ func main() {
checkHakurei(
ctx, &wg, &cred, dbusEnv,
"dbus reject", "rejected dbus call",
- false, false, false, 0, func(c *hst.Config) {
+ 0, 0, func(c *hst.Config) {
c.Enablements = new(hst.EDBus)
c.SessionBus = &hst.BusConfig{Filter: true}
c.Container.Path = prefix.Append("bin", "notify-send")
@@ -722,7 +720,7 @@ func main() {
checkHakurei(
ctx, &wg, &cred, dbusEnv,
"setscheduler-"+strconv.Itoa(int(policy)), "setscheduler "+strconv.Quote(policy.String()),
- true, false, false, 0, func(c *hst.Config) {
+ testsuite.SHScan, 0, func(c *hst.Config) {
c.SchedPolicy = _policy
}, func(p hst.State, pid int) error {
got := -1
@@ -842,7 +840,7 @@ func main() {
"--numeric",
"/tmp/hakurei.0/runtime/"+strconv.Itoa(c.Identity),
))
- }, true, false, false, false, c,
+ }, testsuite.SHScan, c,
)
validatePresent("after first process")
@@ -852,7 +850,7 @@ func main() {
defer close(done)
onDone(err, output)
validatePresent("after second process termination")
- }, true, false, false, false, c,
+ }, testsuite.SHScan, c,
)
validatePresent("after second process")
diff --git a/cmd/hakurei/testsuite/sandbox/main.go b/cmd/hakurei/testsuite/sandbox/main.go
index 681718a7..4eb36f8c 100644
--- a/cmd/hakurei/testsuite/sandbox/main.go
+++ b/cmd/hakurei/testsuite/sandbox/main.go
@@ -359,7 +359,7 @@ func main() {
if err != nil {
log.Fatalf("test case %s: %v\n%s", name, err, output)
}
- }, true, true, false, false, &tc.Hakurei,
+ }, testsuite.SHScan|testsuite.SHWait, &tc.Hakurei,
)
if err != nil {