aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-11-02 11:58:09 +0900
committerOphestra <cat@gensokyo.uk>2025-11-02 11:58:09 +0900
commite7fc311d0b880e7ae44b97d406a309604b01dbac (patch)
tree18d48ef015c35c4490ed84c693e464a47f77e61c
parentf5274067f648a4fc40ba254b4ce546b1229d0bdf (diff)
internal/outcome/shim: cover reparent and exit request paths
These test cases were missed when making the changes. Signed-off-by: Ophestra <cat@gensokyo.uk>
-rw-r--r--internal/outcome/shim_test.go34
1 files changed, 34 insertions, 0 deletions
diff --git a/internal/outcome/shim_test.go b/internal/outcome/shim_test.go
index 55dec3c5..f16d3718 100644
--- a/internal/outcome/shim_test.go
+++ b/internal/outcome/shim_test.go
@@ -3,6 +3,7 @@ package outcome
import (
"bytes"
"context"
+ "io"
"log"
"os"
"syscall"
@@ -138,6 +139,19 @@ func TestShimEntrypoint(t *testing.T) {
call("fatalf", stub.ExpectArgs{"cannot set SUID_DUMP_DISABLE: %v", []any{stub.UniqueError(11)}}, nil, nil),
}}, nil},
+ {"receive exit request", func(k *kstub) error { shimEntrypoint(k); return nil }, stub.Expect{Calls: []stub.Call{
+ call("getMsg", stub.ExpectArgs{}, nil, nil),
+ call("getLogger", stub.ExpectArgs{}, (*log.Logger)(nil), nil),
+ call("setDumpable", stub.ExpectArgs{uintptr(container.SUID_DUMP_DISABLE)}, nil, nil),
+ call("getppid", stub.ExpectArgs{}, 0xbad, nil),
+ call("setupContSignal", stub.ExpectArgs{0xbad}, 0, nil),
+ call("receive", stub.ExpectArgs{"HAKUREI_SHIM", outcomeState{}, nil}, nil, io.EOF),
+ call("exit", stub.ExpectArgs{hst.ExitRequest}, stub.PanicExit, nil),
+
+ // deferred
+ call("wKeepAlive", stub.ExpectArgs{}, nil, nil),
+ }}, nil},
+
{"receive fd", func(k *kstub) error { shimEntrypoint(k); return nil }, stub.Expect{Calls: []stub.Call{
call("getMsg", stub.ExpectArgs{}, nil, nil),
call("getLogger", stub.ExpectArgs{}, (*log.Logger)(nil), nil),
@@ -177,6 +191,26 @@ func TestShimEntrypoint(t *testing.T) {
call("wKeepAlive", stub.ExpectArgs{}, nil, nil),
}}, nil},
+ {"reparent", func(k *kstub) error { shimEntrypoint(k); return nil }, stub.Expect{Calls: []stub.Call{
+ call("getMsg", stub.ExpectArgs{}, nil, nil),
+ call("getLogger", stub.ExpectArgs{}, (*log.Logger)(nil), nil),
+ call("setDumpable", stub.ExpectArgs{uintptr(container.SUID_DUMP_DISABLE)}, nil, nil),
+ call("getppid", stub.ExpectArgs{}, 0xbad, nil),
+ call("setupContSignal", stub.ExpectArgs{0xbad}, 0, nil),
+ call("receive", stub.ExpectArgs{"HAKUREI_SHIM", func() outcomeState {
+ state := templateState
+ state.Shim = newShimParams()
+ state.Shim.PrivPID = 0xfff
+ return state
+ }(), nil}, nil, nil),
+ call("swapVerbose", stub.ExpectArgs{true}, false, nil),
+ call("verbosef", stub.ExpectArgs{"process share directory at %q, runtime directory at %q", []any{m("/tmp/hakurei.10"), m("/run/user/1000/hakurei")}}, nil, nil),
+ call("fatalf", stub.ExpectArgs{"unexpectedly reparented from %d to %d", []any{0xfff, 0xbad}}, nil, nil),
+
+ // deferred
+ call("wKeepAlive", stub.ExpectArgs{}, nil, nil),
+ }}, nil},
+
{"invalid state", func(k *kstub) error { shimEntrypoint(k); return nil }, stub.Expect{Calls: []stub.Call{
call("getMsg", stub.ExpectArgs{}, nil, nil),
call("getLogger", stub.ExpectArgs{}, (*log.Logger)(nil), nil),