diff options
| author | Ophestra <cat@gensokyo.uk> | 2026-10-18 18:23:14 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2026-10-18 18:23:14 +0900 |
| commit | bdca60d4959919a02f744457aaade3d9e2425f3a (patch) | |
| tree | cc3c7a543f7890560665492019f5d4d3ad86c786 | |
| parent | 189376727e42147715e9dca58d09644c2eaa21bb (diff) | |
cmd/hakurei/testsuite: synchronise after termination
This ensures that cmd/hakurei has finished cleanup and terminated before
validating the outcome of that cleanup.
Signed-off-by: Ophestra <cat@gensokyo.uk>
| -rw-r--r-- | cmd/hakurei/testsuite/main.go | 60 | ||||
| -rw-r--r-- | internal/testsuite/testsuite.go | 2 |
2 files changed, 32 insertions, 30 deletions
diff --git a/cmd/hakurei/testsuite/main.go b/cmd/hakurei/testsuite/main.go index 61c2833e..c9defc18 100644 --- a/cmd/hakurei/testsuite/main.go +++ b/cmd/hakurei/testsuite/main.go @@ -759,7 +759,7 @@ func main() { wg.Go(func() { defer log.Println("validated revert type selection") - c := newConfig("rts 0", "sleep", "infinity") + c := newConfig("rts", "sleep", "infinity") c.Container.Flags |= hst.FShareRuntime uid := hst.ToUser(0, c.Identity) @@ -778,9 +778,9 @@ func main() { } } - validatePresent := func() { + validatePresent := func(step string) { testsuite.AssertOutput( - "validating ACLs for rts present", + "validating ACLs for rts present "+step, "user::rwx\n"+ "user:"+strconv.Itoa(uid)+":rwx\n"+ "group::---\n"+ @@ -797,50 +797,52 @@ func main() { "/tmp/hakurei.0/runtime/"+strconv.Itoa(c.Identity), )) } - validateReverted := func() { - testsuite.AssertOutput( - "validating ACLs for rts reverted", - "user::rwx\n"+ - "group::---\n"+ - "mask::---\n"+ - "other::---\n"+ - "\n", - "", - )(testsuite.MustOutput( - ctx, &cred, nil, 0, "getfacl rts present", - "getfacl", - "--absolute-names", - "--omit-header", - "--numeric", - "/tmp/hakurei.0/runtime/"+strconv.Itoa(c.Identity), - )) - } p0, pid0 := testsuite.MustStartHakurei( - ctx, &wg, &cred, dbusEnv, onDone, - true, false, false, false, c, + ctx, &wg, &cred, dbusEnv, func(err error, output string) { + onDone(err, output) + testsuite.AssertOutput( + "validating ACLs for rts reverted", + "user::rwx\n"+ + "group::---\n"+ + "mask::---\n"+ + "other::---\n"+ + "\n", + "", + )(testsuite.MustOutput( + ctx, &cred, nil, 0, "getfacl rts present", + "getfacl", + "--absolute-names", + "--omit-header", + "--numeric", + "/tmp/hakurei.0/runtime/"+strconv.Itoa(c.Identity), + )) + }, true, false, false, false, c, ) - validatePresent() + validatePresent("after first process") + done := make(chan struct{}) p1, pid1 := testsuite.MustStartHakurei( - ctx, &wg, &cred, dbusEnv, onDone, - true, false, false, false, c, + ctx, &wg, &cred, dbusEnv, func(err error, output string) { + defer close(done) + onDone(err, output) + validatePresent("after second process termination") + }, true, false, false, false, c, ) - validatePresent() + validatePresent("after second process") testsuite.MustRun( &cred, testsuite.SessionEnv(dbusEnv), "hakurei", "kill", p1.ID.String(), ) testsuite.PollPID("revert type selection 1", pid1) - validatePresent() + <-done testsuite.MustRun( &cred, testsuite.SessionEnv(dbusEnv), "hakurei", "kill", p0.ID.String(), ) testsuite.PollPID("revert type selection 0", pid0) - validateReverted() }) wg.Wait() diff --git a/internal/testsuite/testsuite.go b/internal/testsuite/testsuite.go index b7805380..dd261afd 100644 --- a/internal/testsuite/testsuite.go +++ b/internal/testsuite/testsuite.go @@ -39,7 +39,7 @@ import ( var serial atomic.Uint64 // NewSerial returns a serial number. -func NewSerial() uint64 { defer serial.Add(1); return serial.Load() } +func NewSerial() uint64 { return serial.Add(1) - 1 } // ReceiveSignals blocks until a termination signal arrives, and terminates. func ReceiveSignals() { |
