summaryrefslogtreecommitdiff
path: root/tests/priv-check
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2001-08-05 08:42:53 +0000
committerJim Meyering <jim@meyering.net>2001-08-05 08:42:53 +0000
commit273c2c5fbc2a5d59aa73ec7423ab244b289b765b (patch)
treed3019bca95ad11405e1757967c518b077014d7b6 /tests/priv-check
parent8e47db95c6ad3fc44f0611d16075863e22513fcc (diff)
downloadcoreutils-273c2c5fbc2a5d59aa73ec7423ab244b289b765b.tar.xz
Renamed from root-only.
Diffstat (limited to 'tests/priv-check')
-rw-r--r--tests/priv-check27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/priv-check b/tests/priv-check
new file mode 100644
index 000000000..31e60dcbd
--- /dev/null
+++ b/tests/priv-check
@@ -0,0 +1,27 @@
+# -*- sh -*-
+# Source this file at the beginning of a test that works
+# only when run as root or as non-root.
+
+case $1 in
+ require-root) who='as root';;
+ require-non-root) who='by an unprivileged user';;
+ *) echo "Usage: $0 require-root|require-non-root" 1>&2; exit 1;;
+esac
+
+root_check_temp=root-check.$$
+touch $root_check_temp || framework_failure=1
+chmod a-w $root_check_temp || framework_failure=1
+
+(echo foo >> $root_check_temp) >/dev/null 2>&1 || {
+ cat <<EOF
+***************************
+NOTICE:
+$0: This test is being skipped, since it works only
+when run $who.
+***************************
+EOF
+ rm -f $root_check_temp
+ (exit 77); exit
+}
+
+rm -f $root_check_temp