aboutsummaryrefslogtreecommitdiffhomepage
path: root/container/inittmpfs_test.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-08-21 21:59:07 +0900
committerOphestra <cat@gensokyo.uk>2025-08-22 19:27:31 +0900
commit09d284498109b847da0da1e2c5f883268a7f2d46 (patch)
tree3784dee4b4e4ec97a95cb222c70d05463ae640ef /container/inittmpfs_test.go
parentd500d6e55917e12a3f98b39cf0d29b6c96de9667 (diff)
container/init: wrap syscall helper functions
This allows tests to stub all kernel behaviour, enabling measurement of all function call arguments and error injection. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'container/inittmpfs_test.go')
-rw-r--r--container/inittmpfs_test.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/container/inittmpfs_test.go b/container/inittmpfs_test.go
index c9245869..8110f446 100644
--- a/container/inittmpfs_test.go
+++ b/container/inittmpfs_test.go
@@ -1,11 +1,34 @@
package container
import (
+ "io/fs"
+ "os"
"syscall"
"testing"
)
func TestMountTmpfsOp(t *testing.T) {
+ checkOpBehaviour(t, []opBehaviourTestCase{
+ {"size oob", new(Params), &MountTmpfsOp{
+ Size: -1,
+ }, nil, nil, nil, msg.WrapErr(fs.ErrInvalid, "size -1 out of bounds")},
+
+ {"success", new(Params), &MountTmpfsOp{
+ FSName: "ephemeral",
+ Path: MustAbs("/run/user/1000/"),
+ Size: 1 << 10,
+ Perm: 0700,
+ }, nil, nil, []kexpect{
+ {"mountTmpfs", expectArgs{
+ "ephemeral", // fsname
+ "/sysroot/run/user/1000", // target
+ uintptr(0), // flags
+ 0x400, // size
+ os.FileMode(0700), // perm
+ }, nil, nil},
+ }, nil},
+ })
+
checkOpsValid(t, []opValidTestCase{
{"nil", (*MountTmpfsOp)(nil), false},
{"zero", new(MountTmpfsOp), false},