aboutsummaryrefslogtreecommitdiffhomepage
path: root/system/dispatcher_test.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-09-29 02:33:10 +0900
committerOphestra <cat@gensokyo.uk>2025-09-29 06:11:47 +0900
commit46cd3a28c83e93b5d66c52d06a8366c11910d5c0 (patch)
tree6e25c5078b5cd9de78b7a6c9b253f1132358812b /system/dispatcher_test.go
parentad1bc6794f0053c3e63eab408a0d530d53e8b51c (diff)
container: remove global msg
This frees all container instances of side effects. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'system/dispatcher_test.go')
-rw-r--r--system/dispatcher_test.go30
1 files changed, 23 insertions, 7 deletions
diff --git a/system/dispatcher_test.go b/system/dispatcher_test.go
index 96769293..d83b46b4 100644
--- a/system/dispatcher_test.go
+++ b/system/dispatcher_test.go
@@ -3,6 +3,7 @@ package system
import (
"io"
"io/fs"
+ "log"
"os"
"reflect"
"slices"
@@ -214,10 +215,10 @@ func (r *readerOsFile) Close() error {
// InternalNew initialises [I] with a stub syscallDispatcher.
func InternalNew(t *testing.T, want stub.Expect, uid int) (*I, *stub.Stub[syscallDispatcher]) {
- k := stub.New(t, func(s *stub.Stub[syscallDispatcher]) syscallDispatcher { return &kstub{s} }, want)
- sys := New(t.Context(), uid)
- sys.syscallDispatcher = &kstub{k}
- return sys, k
+ k := &kstub{stub.New(t, func(s *stub.Stub[syscallDispatcher]) syscallDispatcher { return &kstub{s} }, want)}
+ sys := New(t.Context(), k, uid)
+ sys.syscallDispatcher = k
+ return sys, k.Stub
}
type kstub struct{ *stub.Stub[syscallDispatcher] }
@@ -357,12 +358,23 @@ func (k *kstub) dbusProxySCW(expect *stub.Call, proxy *dbus.Proxy) error {
return expect.Err
}
-func (k *kstub) isVerbose() bool { k.Helper(); return k.Expects("isVerbose").Ret.(bool) }
+func (k *kstub) GetLogger() *log.Logger { panic("unreachable") }
+
+func (k *kstub) IsVerbose() bool { k.Helper(); return k.Expects("isVerbose").Ret.(bool) }
+func (k *kstub) SwapVerbose(verbose bool) bool {
+ k.Helper()
+ expect := k.Expects("swapVerbose")
+ if expect.Error(
+ stub.CheckArg(k.Stub, "verbose", verbose, 0)) != nil {
+ k.FailNow()
+ }
+ return expect.Ret.(bool)
+}
// ignoreValue marks a value to be ignored by the test suite.
type ignoreValue struct{}
-func (k *kstub) verbose(v ...any) {
+func (k *kstub) Verbose(v ...any) {
k.Helper()
expect := k.Expects("verbose")
@@ -381,7 +393,7 @@ func (k *kstub) verbose(v ...any) {
}
}
-func (k *kstub) verbosef(format string, v ...any) {
+func (k *kstub) Verbosef(format string, v ...any) {
k.Helper()
if k.Expects("verbosef").Error(
stub.CheckArg(k.Stub, "format", format, 0),
@@ -389,3 +401,7 @@ func (k *kstub) verbosef(format string, v ...any) {
k.FailNow()
}
}
+
+func (k *kstub) Suspend() bool { k.Helper(); return k.Expects("suspend").Ret.(bool) }
+func (k *kstub) Resume() bool { k.Helper(); return k.Expects("resume").Ret.(bool) }
+func (k *kstub) BeforeExit() { k.Helper(); k.Expects("beforeExit") }