aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2019-07-26 10:59:39 -0700
committerRob Landley <rob@landley.net>2019-07-26 21:17:42 -0500
commit26f3ca413c7fa7b1ba380f3c951004c109a47294 (patch)
tree1140e65c94c65581984d6a19845f4caf1cf8e130 /tests
parent903f06c7780880ca07036d0ff9ea6c2e28dfdb00 (diff)
downloadtoybox-26f3ca413c7fa7b1ba380f3c951004c109a47294.tar.gz
hostname: fix tests for non-root on Android.
On Android you can't even get the hostname unless you're root, to avoid device fingerprinting/tracking. Also modernize by using skipnot, which fixes the incorrect test name in the SKIP: output.
Diffstat (limited to 'tests')
-rwxr-xr-xtests/hostname.test11
1 files changed, 3 insertions, 8 deletions
diff --git a/tests/hostname.test b/tests/hostname.test
index ba65a398..d94f480a 100755
--- a/tests/hostname.test
+++ b/tests/hostname.test
@@ -4,14 +4,9 @@
#testing "name" "command" "result" "infile" "stdin"
-HOST="$(cat /proc/sys/kernel/hostname)"
+HOST="$(cat /proc/sys/kernel/hostname 2>/dev/null)"
+skipnot [ $? -eq 0 ]
testing "get" "hostname" "$HOST\n" "" ""
-if [ "$(id -u)" -ne 0 ]
-then
- echo "$SHOWSKIP: groupdel (not root)"
- return 2>/dev/null
- exit
-fi
-
+skipnot [ $(id -u) -eq 0 ]
testing "set" 'hostname "2>&1 | tee"; hostname; hostname "$HOST"' "2>&1 | tee\n" "" ""