aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/sandbox
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-09-14 15:12:09 +0900
committerOphestra <cat@gensokyo.uk>2025-09-14 15:12:51 +0900
commit83c4f8b767c31734a7e465e49ee0e23487ac22ca (patch)
treee00012559d901442b3942aa569057940a1370dfa /test/sandbox
parentd0ddd7193407af4162312469f19bd02af4d4bce1 (diff)
test/sandbox: check extra writable paths
This is not always obvious from mountinfo. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'test/sandbox')
-rw-r--r--test/sandbox/assert.go28
-rw-r--r--test/sandbox/case/mapuid.nix2
-rw-r--r--test/sandbox/case/pd.nix2
-rw-r--r--test/sandbox/case/pdlike.nix2
-rw-r--r--test/sandbox/case/preset.nix2
-rw-r--r--test/sandbox/case/tty.nix2
6 files changed, 28 insertions, 10 deletions
diff --git a/test/sandbox/assert.go b/test/sandbox/assert.go
index 6dbb53b7..82c928b0 100644
--- a/test/sandbox/assert.go
+++ b/test/sandbox/assert.go
@@ -17,6 +17,7 @@ import (
"log"
"net"
"os"
+ "path"
"syscall"
)
@@ -52,12 +53,29 @@ func (t *T) MustCheckFile(wantFilePath string) {
t.MustCheck(want)
}
+func mustAbs(s string) string {
+ if !path.IsAbs(s) {
+ fatalf("[FAIL] %q is not absolute", s)
+ panic("unreachable")
+ }
+ return s
+}
+
func (t *T) MustCheck(want *TestCase) {
- // check /dev/shm writable
- if err := os.WriteFile("/dev/shm/.hakurei-check", make([]byte, 1<<8), 0600); err != nil {
- fatalf("[FAIL] %s", err)
- } else {
- printf("[ OK ] /dev/shm is writable")
+ checkWritableDirPaths := []string{
+ "/dev/shm",
+ "/tmp",
+ os.Getenv("XDG_RUNTIME_DIR"),
+ }
+ for _, a := range checkWritableDirPaths {
+ pathname := path.Join(mustAbs(a), ".hakurei-check")
+ if err := os.WriteFile(pathname, make([]byte, 1<<8), 0600); err != nil {
+ fatalf("[FAIL] %s", err)
+ } else if err = os.Remove(pathname); err != nil {
+ fatalf("[FAIL] %s", err)
+ } else {
+ printf("[ OK ] %s is writable", a)
+ }
}
if want.Env != nil {
diff --git a/test/sandbox/case/mapuid.nix b/test/sandbox/case/mapuid.nix
index 1c39fc19..d5072321 100644
--- a/test/sandbox/case/mapuid.nix
+++ b/test/sandbox/case/mapuid.nix
@@ -73,7 +73,7 @@ in
ptmx = fs "80001ff" null null;
pts = fs "800001ed" { ptmx = fs "42001b6" null null; } null;
random = fs "42001b6" null null;
- shm = fs "801001ff" { ".hakurei-check" = fs "180" null null; } null;
+ shm = fs "801001ff" { } null;
stderr = fs "80001ff" null null;
stdin = fs "80001ff" null null;
stdout = fs "80001ff" null null;
diff --git a/test/sandbox/case/pd.nix b/test/sandbox/case/pd.nix
index ea07922e..f98254f1 100644
--- a/test/sandbox/case/pd.nix
+++ b/test/sandbox/case/pd.nix
@@ -36,7 +36,7 @@
ptmx = fs "80001ff" null null;
pts = fs "800001ed" { ptmx = fs "42001b6" null null; } null;
random = fs "42001b6" null null;
- shm = fs "801001ff" { ".hakurei-check" = fs "180" null null; } null;
+ shm = fs "801001ff" { } null;
stderr = fs "80001ff" null null;
stdin = fs "80001ff" null null;
stdout = fs "80001ff" null null;
diff --git a/test/sandbox/case/pdlike.nix b/test/sandbox/case/pdlike.nix
index 9233a117..b34c2b81 100644
--- a/test/sandbox/case/pdlike.nix
+++ b/test/sandbox/case/pdlike.nix
@@ -71,7 +71,7 @@ in
ptmx = fs "80001ff" null null;
pts = fs "800001ed" { ptmx = fs "42001b6" null null; } null;
random = fs "42001b6" null null;
- shm = fs "801001ff" { ".hakurei-check" = fs "180" null null; } null;
+ shm = fs "801001ff" { } null;
stderr = fs "80001ff" null null;
stdin = fs "80001ff" null null;
stdout = fs "80001ff" null null;
diff --git a/test/sandbox/case/preset.nix b/test/sandbox/case/preset.nix
index 46cab69e..e6594b34 100644
--- a/test/sandbox/case/preset.nix
+++ b/test/sandbox/case/preset.nix
@@ -70,7 +70,7 @@ in
ptmx = fs "80001ff" null null;
pts = fs "800001ed" { ptmx = fs "42001b6" null null; } null;
random = fs "42001b6" null null;
- shm = fs "801001ff" { ".hakurei-check" = fs "180" null null; } null;
+ shm = fs "801001ff" { } null;
stderr = fs "80001ff" null null;
stdin = fs "80001ff" null null;
stdout = fs "80001ff" null null;
diff --git a/test/sandbox/case/tty.nix b/test/sandbox/case/tty.nix
index 93b057c8..5ee7f643 100644
--- a/test/sandbox/case/tty.nix
+++ b/test/sandbox/case/tty.nix
@@ -75,7 +75,7 @@ in
ptmx = fs "80001ff" null null;
pts = fs "800001ed" { ptmx = fs "42001b6" null null; } null;
random = fs "42001b6" null null;
- shm = fs "801001ff" { ".hakurei-check" = fs "180" null null; } null;
+ shm = fs "801001ff" { } null;
stderr = fs "80001ff" null null;
stdin = fs "80001ff" null null;
stdout = fs "80001ff" null null;