aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal
diff options
context:
space:
mode:
Diffstat (limited to 'internal')
-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),