aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2016-06-04 09:26:14 -0700
committerRob Landley <rob@landley.net>2016-06-04 16:57:18 -0500
commit5d2619774ea77b02e4642401fb3c1dbd02253011 (patch)
treeb2f7cef9aa900111c6696d74e0feb54c38b2eff1 /tests
parent5352bb64b619aad69598fda69cccc591e8f16710 (diff)
downloadtoybox-5d2619774ea77b02e4642401fb3c1dbd02253011.tar.gz
Basic success/failure return from pgrep/pkill.
The man page says they also return 2 for syntax errors and 3 for "fatal error: out of memory etc", but I don't know how to implement that and don't need it (or have any reason to believe anyone needs it). Bug: 29092208
Diffstat (limited to 'tests')
-rwxr-xr-xtests/pgrep.test4
-rwxr-xr-xtests/pkill.test10
2 files changed, 12 insertions, 2 deletions
diff --git a/tests/pgrep.test b/tests/pgrep.test
index 753a55ab..3319c79a 100755
--- a/tests/pgrep.test
+++ b/tests/pgrep.test
@@ -29,5 +29,9 @@ testing "-o pattern" "pgrep -o yes" "$proc\n" "" ""
testing "-s" "pgrep -s $session_id yes" "$proc\n" "" ""
testing "-P" "pgrep -P $proc_parent yes" "$proc\n" "" ""
+testing "return success" "pgrep yes && echo success" "$proc\nsuccess\n" "" ""
+testing "return failure" "pgrep almost-certainly-not || echo failure" \
+ "failure\n" "" ""
+
#Clean-up
killall yes >/dev/null 2>&1
diff --git a/tests/pkill.test b/tests/pkill.test
index 0bea32ab..3f20d260 100755
--- a/tests/pkill.test
+++ b/tests/pkill.test
@@ -92,10 +92,16 @@ testing "-P parent_prodId pattern" "pkill -P $proc_p yes && sleep 1 &&
killall yes >/dev/null 2>&1
yes >/dev/null &
-proc=$!
-proc_parent=`cat /proc/${proc}/stat | awk '{ print $4 }'`
sleep 1
testing "-9 pattern" "pkill -9 yes && sleep 1 &&
(pgrep yes || echo 'yes')" "yes\n" "" ""
killall yes >/dev/null 2>&1
+yes >/dev/null &
+sleep 1
+testing "return success" "pkill yes && echo success" "success\n" "" ""
+killall yes >/dev/null 2>&1
+
+testing "return failure" "pkill almost-certainly-not || echo failure" \
+ "failure\n" "" ""
+