aboutsummaryrefslogtreecommitdiffhomepage
path: root/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'cmd')
-rw-r--r--cmd/hakurei/testsuite/main.go56
1 files changed, 40 insertions, 16 deletions
diff --git a/cmd/hakurei/testsuite/main.go b/cmd/hakurei/testsuite/main.go
index ede95275..506b10c5 100644
--- a/cmd/hakurei/testsuite/main.go
+++ b/cmd/hakurei/testsuite/main.go
@@ -76,6 +76,7 @@ func checkHakurei(
name, long string,
scan, verbose, insecure bool,
+ retry int,
processConfig func(c *hst.Config),
f func(p hst.State, pid int) error,
@@ -102,22 +103,45 @@ func checkHakurei(
ctx, wg, cred, dbusEnv, func(err error, output string) {
if err == nil {
if !slices.Contains(wantCode, 0) {
+ if retry > 0 {
+ goto retry
+ }
log.Fatalf(
"%s test process unexpectedly succeeded\n%s",
long, output,
)
}
} else if e, ok := errors.AsType[*exec.ExitError](err); !ok {
+ // problem with starting cmd/hakurei, not retryable
log.Fatalf("%s: %v\n%s", long, err, output)
} else if !slices.Contains(wantCode, e.ExitCode()) {
+ if retry > 0 {
+ goto retry
+ }
log.Fatalf("%s: %v\n%s", long, e, output)
}
if !checkOutput(output) {
+ if retry > 0 {
+ goto retry
+ }
log.Fatalf("%s: %q", long, output)
}
log.Println("validated", long)
+ return
+
+ retry:
+ time.Sleep(100 * time.Millisecond)
+ log.Printf("retrying %s", name)
+ checkHakurei(
+ ctx, wg, cred, dbusEnv,
+ name, long,
+ scan, verbose, insecure,
+ retry-1,
+ processConfig, f,
+ checkOutput, wantCode...,
+ )
}, scan, false, verbose, insecure, c,
)
@@ -322,13 +346,13 @@ func main() {
checkHakurei(
ctx, &wg, &cred, dbusEnv,
"indirect-termination", "indirect termination",
- true, false, false, nil, nil, nil,
+ true, false, false, 0, nil, nil, nil,
)
checkHakurei(
ctx, &wg, &cred, dbusEnv,
"immediate-termination", "immediate termination",
- true, false, false, func(c *hst.Config) {
+ true, false, false, 0, func(c *hst.Config) {
c.Container.WaitDelay = -1
}, nil, nil, 254,
)
@@ -336,7 +360,7 @@ func main() {
checkHakurei(
ctx, &wg, &cred, dbusEnv,
"shim-poke", "unexpected shim notification",
- true, true, false, nil, func(p hst.State, pid int) error {
+ true, true, false, 0, nil, func(p hst.State, pid int) error {
if err := syscall.Kill(p.ShimPID, syscall.SIGCONT); err != nil {
return os.NewSyscallError("kill", err)
}
@@ -352,7 +376,7 @@ func main() {
checkHakurei(
ctx, &wg, &cred, dbusEnv,
"reject-deprecated", "reject insecure configuration",
- false, false, false, func(c *hst.Config) {
+ false, false, false, 0, func(c *hst.Config) {
c.Enablements = new(hst.EPulse)
}, nil, func(output string) bool {
return output == "hakurei: enablement PulseAudio is insecure "+
@@ -363,7 +387,7 @@ func main() {
checkHakurei(
ctx, &wg, &cred, dbusEnv,
"pipewire-pulse", "pipewire proxying behaviour",
- false, false, false, func(c *hst.Config) {
+ false, false, false, 0, func(c *hst.Config) {
c.Enablements = new(hst.EPipeWire)
c.Container.Path = fhs.AbsUsrBin.Append("pactl")
c.Container.Args = []string{"pactl", "info"}
@@ -407,7 +431,7 @@ func main() {
checkHakurei(
ctx, &wg, &cred, dbusEnv,
"pipewire-security", "pipewire SecurityContext",
- false, false, false, func(c *hst.Config) {
+ false, false, false, 32, func(c *hst.Config) {
c.Enablements = new(hst.EPipeWire)
c.Container.Path = fhs.AbsUsrBin.Append("pactl")
c.Container.Args = []string{
@@ -424,7 +448,7 @@ func main() {
checkHakurei(
ctx, &wg, &cred, dbusEnv,
"pipewire-direct-failure", "pipewire cover direct access",
- false, false, false, func(c *hst.Config) {
+ false, false, false, 0, func(c *hst.Config) {
c.Enablements = new(hst.EPipeWire)
c.Container.Path = fhs.AbsUsrBin.Append("pw-dump")
c.Container.Args = []string{"pw-dump"}
@@ -436,7 +460,7 @@ func main() {
checkHakurei(
ctx, &wg, &cred, dbusEnv,
"pipewire-direct", "pipewire direct access",
- false, false, true, func(c *hst.Config) {
+ false, false, true, 0, func(c *hst.Config) {
c.Enablements = new(hst.EPipeWire)
c.DirectPipeWire = true
c.Container.Path = fhs.AbsUsrBin.Append("pw-dump")
@@ -449,7 +473,7 @@ func main() {
checkHakurei(
ctx, &wg, &cred, dbusEnv,
"wayland-client", "wayland client",
- true, false, false, func(c *hst.Config) {
+ true, false, false, 0, func(c *hst.Config) {
c.Enablements = new(hst.EWayland)
c.Container.Path = fhs.AbsUsrBin.Append("foot")
c.Container.Args = []string{"foot"}
@@ -467,7 +491,7 @@ func main() {
checkHakurei(
ctx, &wg, &cred, dbusEnv,
"wayland-security-context", "wayland security-context-v1",
- false, false, false, func(c *hst.Config) {
+ false, false, false, 0, func(c *hst.Config) {
c.Enablements = new(hst.EWayland)
c.Container.Path = fhs.AbsUsrBin.Append("grim")
c.Container.Args = []string{"grim"}
@@ -481,7 +505,7 @@ func main() {
checkHakurei(
ctx, &wg, &cred, dbusEnv,
"wlr-screencopy-unstable-v1", "direct wlr-screencopy-unstable-v1",
- false, false, true, func(c *hst.Config) {
+ false, false, true, 0, func(c *hst.Config) {
c.Enablements = new(hst.EWayland)
c.DirectWayland = true
c.Container.Path = fhs.AbsUsrBin.Append("grim")
@@ -494,7 +518,7 @@ func main() {
checkHakurei(
ctx, &wg, &cred, dbusEnv,
"direct-wayland-client", "direct wayland client",
- true, false, true, func(c *hst.Config) {
+ true, false, true, 0, func(c *hst.Config) {
c.Enablements = new(hst.EWayland)
c.DirectWayland = true
c.Container.Path = fhs.AbsUsrBin.Append("foot")
@@ -514,7 +538,7 @@ func main() {
checkHakurei(
ctx, &wg, &cred, dbusEnv,
"xwayland-client", "xwayland client",
- false, false, false, func(c *hst.Config) {
+ false, false, false, 32, func(c *hst.Config) {
c.Enablements = new(hst.EX11)
c.Container.Path = fhs.AbsUsrBin.Append("xset")
c.Container.Args = []string{"xset", "q"}
@@ -527,7 +551,7 @@ func main() {
checkHakurei(
ctx, &wg, &cred, dbusEnv,
"dbus", "proxied dbus call",
- false, false, false, func(c *hst.Config) {
+ false, false, false, 0, func(c *hst.Config) {
c.Enablements = new(hst.EDBus)
c.SessionBus = &hst.BusConfig{
Talk: []string{"org.freedesktop.Notifications"},
@@ -549,7 +573,7 @@ func main() {
checkHakurei(
ctx, &wg, &cred, dbusEnv,
"dbus reject", "rejected dbus call",
- false, false, false, func(c *hst.Config) {
+ false, false, false, 0, func(c *hst.Config) {
c.Enablements = new(hst.EDBus)
c.SessionBus = &hst.BusConfig{Filter: true}
c.Container.Path = fhs.AbsUsrBin.Append("notify-send")
@@ -673,7 +697,7 @@ func main() {
checkHakurei(
ctx, &wg, &cred, dbusEnv,
"setscheduler-"+strconv.Itoa(int(policy)), "setscheduler",
- true, false, false, func(c *hst.Config) {
+ true, false, false, 0, func(c *hst.Config) {
c.SchedPolicy = _policy
}, func(p hst.State, pid int) error {
got := -1