aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--cmd/hakurei/testsuite/main.go8
-rw-r--r--cmd/hakurei/testsuite/notify.go24
-rw-r--r--cmd/hakurei/testsuite/notify_rosa.go68
3 files changed, 95 insertions, 5 deletions
diff --git a/cmd/hakurei/testsuite/main.go b/cmd/hakurei/testsuite/main.go
index cb315401..c3cada17 100644
--- a/cmd/hakurei/testsuite/main.go
+++ b/cmd/hakurei/testsuite/main.go
@@ -174,6 +174,7 @@ func main() {
defer swg.Wait()
dbusEnv := testsuite.MustStartSessionBus(&cred)
testsuite.MustStartSway(&swg, &cred, dbusEnv)
+ startMako(&swg, &cred, dbusEnv)
defer testsuite.TerminateSway(&cred)
pipewireVersion := testsuite.MustStartPipeWire(&cred, dbusEnv)
sessionEnv := testsuite.SessionEnv(dbusEnv)
@@ -588,11 +589,8 @@ func main() {
"Test notification",
}
}, nil, func(output string) bool {
- return output == "GDBus.Error:"+
- "org.freedesktop.DBus.Error.ServiceUnknown: "+
- "The name org.freedesktop.Notifications "+
- "was not provided by any .service files\r\n"
- }, hst.ExitFailure,
+ return output == pdcOutput
+ }, pdcExit,
)
checkHakurei(
diff --git a/cmd/hakurei/testsuite/notify.go b/cmd/hakurei/testsuite/notify.go
new file mode 100644
index 00000000..492d2ca7
--- /dev/null
+++ b/cmd/hakurei/testsuite/notify.go
@@ -0,0 +1,24 @@
+//go:build !rosa
+
+package main
+
+import (
+ "sync"
+ "syscall"
+
+ "hakurei.app/hst"
+)
+
+// startMako is a noop.
+func startMako(_ *sync.WaitGroup, _ *syscall.Credential, _ string) {}
+
+const (
+ // pdcExit is the expected error code of the proxied dbus call test.
+ pdcExit = hst.ExitFailure
+
+ // pdcOutput is the expected output of the proxied dbus call test.
+ pdcOutput = "GDBus.Error:" +
+ "org.freedesktop.DBus.Error.ServiceUnknown: " +
+ "The name org.freedesktop.Notifications " +
+ "was not provided by any .service files\r\n"
+)
diff --git a/cmd/hakurei/testsuite/notify_rosa.go b/cmd/hakurei/testsuite/notify_rosa.go
new file mode 100644
index 00000000..4b67611a
--- /dev/null
+++ b/cmd/hakurei/testsuite/notify_rosa.go
@@ -0,0 +1,68 @@
+//go:build rosa
+
+package main
+
+import (
+ "context"
+ "errors"
+ "log"
+ "os/exec"
+ "sync"
+ "sync/atomic"
+ "syscall"
+ "time"
+
+ "hakurei.app/internal/testsuite"
+)
+
+// startMako starts the mako notification daemon against sway and waits for it
+// to be ready. It terminates the program if mako terminates before it is ready,
+// or terminates with an unexpected exit status.
+func startMako(
+ wg *sync.WaitGroup,
+ cred *syscall.Credential,
+ dbusEnv string,
+) {
+ var makoReady atomic.Bool
+ wg.Go(func() {
+ // terminated on sway termination
+ _, done := testsuite.MustStartWith(
+ context.Background(), cred, false, []string{
+ testsuite.XDGRuntimeEnv,
+ testsuite.WaylandEnv,
+ dbusEnv,
+ }, nil,
+ "mako",
+ )
+ err := <-done
+
+ if !makoReady.Load() {
+ log.Fatalf("mako terminated before ready: %v", err)
+ }
+
+ if err == nil {
+ return
+ }
+
+ if e, ok := errors.AsType[*exec.ExitError](err); !ok {
+ log.Fatalf("mako terminated unexpectedly: %v", err)
+ } else if e.ExitCode() != 1 {
+ log.Fatalf("mako terminated with unexpected status: %v", err)
+ }
+ })
+ testsuite.Poll(
+ 50*time.Millisecond,
+ cred,
+ []string{dbusEnv},
+ "makoctl", "list",
+ )
+ makoReady.Store(true)
+}
+
+const (
+ // pdcExit is the expected error code of the proxied dbus call test.
+ pdcExit = 0
+
+ // pdcOutput is the expected output of the proxied dbus call test.
+ pdcOutput = ""
+)