commit: f4704a48ca14f1d05d2cf1d325c8085900fd2d53
parent 2b1563aa26fec9d85764ba5abc72e48d7cc53ca5
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Tue, 15 Mar 2022 02:33:38 +0100
test-sbin/memsys: Add
Diffstat:
3 files changed, 43 insertions(+), 0 deletions(-)
diff --git a/Kyuafile b/Kyuafile
@@ -3,3 +3,4 @@ syntax(2)
test_suite("utils")
include("test-bin/Kyuafile")
+include("test-sbin/Kyuafile")
diff --git a/test-sbin/Kyuafile b/test-sbin/Kyuafile
@@ -0,0 +1,8 @@
+syntax(2)
+
+test_suite("utils")
+
+basedir = fs.dirname(fs.dirname(current_kyuafile()))
+
+-- 7,$|LC_ALL=C.UTF-8 sort
+atf_test_program{name="memsys", required_files=basedir.."/sbin/memsys", timeout=1}
diff --git a/test-sbin/memsys b/test-sbin/memsys
@@ -0,0 +1,34 @@
+#!/usr/bin/env atf-sh
+
+atf_test_case basic cleanup
+basic_body() {
+ command -v bwrap >/dev/null 2>/dev/null || atf_skip "'bwrap' command not found"
+
+ atf_check touch ./tmp-memsys
+ atf_check -- bwrap --bind / / --bind ./tmp-memsys /sys/power/state ../sbin/memsys
+ atf_check -o 'inline:mem' cat tmp-memsys
+}
+basic_cleanup() {
+ rm -f tmp-memsys
+}
+
+atf_test_case chmod_000 cleanup
+chmod_000_body() {
+ command -v bwrap >/dev/null 2>/dev/null || atf_skip "'bwrap' command not found"
+
+ atf_check touch ./tmp-memsys.000
+ atf_check chmod 000 ./tmp-memsys.000
+ atf_check -s exit:1 -e 'inline:memsys: open("/sys/power/state"): Permission denied\n' -- bwrap --bind / / --bind ./tmp-memsys.000 /sys/power/state ../sbin/memsys
+ atf_check chmod 600 ./tmp-memsys.000
+ atf_check -o empty cat tmp-memsys.000
+}
+chmod_000_cleanup() {
+ rm -f tmp-memsys.000
+}
+
+atf_init_test_cases() {
+ cd "$(atf_get_srcdir)" || exit 1
+
+ atf_add_test_case basic
+ atf_add_test_case chmod_000
+}