From 26f3ca413c7fa7b1ba380f3c951004c109a47294 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Fri, 26 Jul 2019 10:59:39 -0700 Subject: 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. --- tests/hostname.test | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'tests') 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" "" "" -- cgit v1.2.3