summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorEgor Tensin <egor@tensin.name>2026-09-27 15:44:02 +0500
committerEgor Tensin <egor@tensin.name>2026-09-27 15:49:11 +0500
commitefe1c237e7c0cb72d5b4f15821dae397aa270ebc (patch)
treee419e252ac41393a928e72645b541a302cad9c27
parenttest/local/ -> test/ (diff)
downloadconfig-links-2.1.5.tar.gz
config-links-2.1.5.zip
test: add tst-root.shv2.1.5
-rw-r--r--test/tst-root.sh42
1 files changed, 42 insertions, 0 deletions
diff --git a/test/tst-root.sh b/test/tst-root.sh
new file mode 100644
index 0000000..e31661e
--- /dev/null
+++ b/test/tst-root.sh
@@ -0,0 +1,42 @@
+if [ -z "${CI+y}" ] || [ "$EUID" -ne 0 ]; then
+ test_should_fail=y
+fi
+
+test_run() {
+ if [ -z "${CI+y}" ]; then
+ fail "Don't run this test locally, it'll mess up your /"
+ return 1
+ fi
+ if [ "$EUID" -ne 0 ]; then
+ fail "This test requires root privileges"
+ return 1
+ fi
+
+ test_root_dir="$( mktemp -d )"
+ # mktemp returns /var/..., which is actually in /private/var/... on macOS.
+ test_root_dir="$( readlink -e -- "$test_root_dir" )"
+
+ test_src_dir="$test_root_dir/src"
+
+ mkdir -p -- "$test_src_dir/%CONFIG_LINKS_ROOT%/foo"
+ mkdir /foo
+ chmod 0777 /foo
+ touch -- "$test_src_dir/%CONFIG_LINKS_ROOT%/foo/bar.txt"
+
+ test_run_update
+
+ log "Checking /foo/bar.txt..."
+
+ local actual
+ actual="$( readlink -e -- "/foo/bar.txt" )"
+
+ local expected
+ expected="$test_src_dir/%CONFIG_LINKS_ROOT%/foo/bar.txt"
+
+ if [ "$actual" != "$expected" ]; then
+ fail "There was a problem with symlink /foo/bar.txt:"
+ fail_details "Expected target: $expected"
+ fail_details "Actual target: $actual"
+ return 1
+ fi
+}