All checks were successful
Test / Create distribution (push) Successful in 34s
Test / Sandbox (push) Successful in 2m6s
Test / Hakurei (push) Successful in 3m22s
Test / Hpkg (push) Successful in 3m49s
Test / Sandbox (race detector) (push) Successful in 5m34s
Test / Hakurei (race detector) (push) Successful in 3m12s
Test / Flake checks (push) Successful in 1m35s
This allows tests to stub all kernel behaviour, like in the container package. Signed-off-by: Ophestra <cat@gensokyo.uk>
31 lines
1.1 KiB
Go
31 lines
1.1 KiB
Go
package system
|
|
|
|
import "hakurei.app/system/acl"
|
|
|
|
// syscallDispatcher provides methods that make state-dependent system calls as part of their behaviour.
|
|
// syscallDispatcher is embedded in [I], so all methods must be unexported.
|
|
type syscallDispatcher interface {
|
|
// new starts a goroutine with a new instance of syscallDispatcher.
|
|
// A syscallDispatcher must never be used in any goroutine other than the one owning it,
|
|
// just synchronising access is not enough, as this is for test instrumentation.
|
|
new(f func(k syscallDispatcher))
|
|
|
|
// aclUpdate provides [acl.Update].
|
|
aclUpdate(name string, uid int, perms ...acl.Perm) error
|
|
|
|
verbose(v ...any)
|
|
verbosef(format string, v ...any)
|
|
}
|
|
|
|
// direct implements syscallDispatcher on the current kernel.
|
|
type direct struct{}
|
|
|
|
func (k direct) new(f func(k syscallDispatcher)) { go f(k) }
|
|
|
|
func (k direct) aclUpdate(name string, uid int, perms ...acl.Perm) error {
|
|
return acl.Update(name, uid, perms...)
|
|
}
|
|
|
|
func (direct) verbose(v ...any) { msg.Verbose(v...) }
|
|
func (direct) verbosef(format string, v ...any) { msg.Verbosef(format, v...) }
|