aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2018-11-20 17:42:45 -0600
committerRob Landley <rob@landley.net>2018-11-20 17:42:45 -0600
commit0a75914fb787b47cb358ff7a64d749062c14aed2 (patch)
treea3d11580be22e9addedbd773692f402d5adb43ae /tests
parent42f8b18bc27b0143edee8fd598eee853d6ca47f9 (diff)
downloadtoybox-0a75914fb787b47cb358ff7a64d749062c14aed2.tar.gz
Fix up some tests for running as a normal user.
Diffstat (limited to 'tests')
-rwxr-xr-xtests/cksum.test4
-rwxr-xr-xtests/groupadd.test7
-rwxr-xr-xtests/groupdel.test7
-rwxr-xr-xtests/hostname.test19
4 files changed, 25 insertions, 12 deletions
diff --git a/tests/cksum.test b/tests/cksum.test
index 01938f43..d69f0cb4 100755
--- a/tests/cksum.test
+++ b/tests/cksum.test
@@ -16,8 +16,8 @@ rm -f one two
# Check the length suppression, both calculate the CRC on 'abc' but the second
# option has length suppression on and has the length concatenated to 'abc'.
-testing "on abc including length" "echo -n 'abc' | cksum" "1219131554 3\n" "" ""
-testing "on abc excluding length" "echo -ne 'abc\x3' | cksum -N" "1219131554 4\n" "" ""
+testing "on abc including length" "cksum" "1219131554 3\n" "" 'abc'
+testing "on abc excluding length" "cksum -N" "1219131554\n" "" 'abc\x3'
# cksum on no contents gives 0xffffffff (=4294967295)
testing "on no data post-inversion" "echo -n "" | cksum" "4294967295 0\n" "" ""
diff --git a/tests/groupadd.test b/tests/groupadd.test
index 091dccf7..6161ee2f 100755
--- a/tests/groupadd.test
+++ b/tests/groupadd.test
@@ -4,6 +4,13 @@
[ -f testing.sh ] && . testing.sh
+if [ "$(id -u)" -ne 0 ]
+then
+ echo "$SHOWSKIP: groupadd (not root)"
+ continue 2>/dev/null
+ exit
+fi
+
# 70 characters long string; hereafter, we will use it as per our need.
_s70="abcdefghijklmnopqrstuvwxyz123456789abcdefghijklmnopqrstuvwxyz123456789"
diff --git a/tests/groupdel.test b/tests/groupdel.test
index ea9ee9ad..94edcf90 100755
--- a/tests/groupdel.test
+++ b/tests/groupdel.test
@@ -5,6 +5,13 @@
[ -f testing.sh ] && . testing.sh
+if [ "$(id -u)" -ne 0 ]
+then
+ echo "$SHOWSKIP: groupdel (not root)"
+ continue 2>/dev/null
+ exit
+fi
+
# Redirecting all output to /dev/null for grep and delgroup
arg="&>/dev/null"
diff --git a/tests/hostname.test b/tests/hostname.test
index 5107ce22..80f94405 100755
--- a/tests/hostname.test
+++ b/tests/hostname.test
@@ -1,18 +1,17 @@
#!/bin/bash
-# Copyright 2014 Divya Kothari <divya.s.kothari@gmail.com>
-# Copyright 2014 Naha Maggu <maggu.neha@gmail.com>
-
[ -f testing.sh ] && . testing.sh
#testing "name" "command" "result" "infile" "stdin"
-# Get system hostname
-hostnameExe=`which hostname`
-hostnameOut=`$hostnameExe`
+HOST="$(cat /proc/sys/kernel/hostname)"
+testing "get" "hostname" "$HOST\n" "" ""
-# New hostname
-NewHostname="NewHostName.system"
+if [ "$(id -u)" -ne 0 ]
+then
+ echo "$SHOWSKIP: groupdel (not root)"
+ continue 2>/dev/null
+ exit
+fi
-testing "get" "hostname" "$hostnameOut\n" "" ""
-testing "set, Get and then Reset" "hostname $NewHostname; hostname; hostname $hostnameOut; hostname" "$NewHostname\n$hostnameOut\n" "" ""
+testing "set" 'hostname "2>&1 | tee"; hostname; hostname "$HOST"' "2>&1 | tee\n" "" ""