OSDN Git Service

Merge remote-tracking branch 'toybox/master' into HEAD am: f37062b46d am: a949b8829c...
[android-x86/external-toybox.git] / tests / pkill.test
index 0bea32a..c98b6a4 100755 (executable)
@@ -46,10 +46,10 @@ testing "-f pattern (multiple)" "pkill -f yes && sleep 1 &&
    (pgrep yes || echo 'yes')" "yes\n" "" ""
 killall yes >/dev/null 2>&1
 
-yes >/dev/null &
+yes this-is-unlikely-to-appear-otherwise >/dev/null &
 sleep 1
-testing "-s 0 -f pattern (regexp)" "pkill -s 0 -f ye* && sleep 1 &&
-   (pgrep yes || echo 'yes')" "yes\n" "" ""
+testing "-s 0 -f pattern (regexp)" "pkill -s 0 -f .*-unlikely-.*-otherwise &&
+   sleep 1 && (pgrep yes || echo 'yes')" "yes\n" "" ""
 killall yes >/dev/null 2>&1
 
 yes >/dev/null &
@@ -85,17 +85,23 @@ killall yes >/dev/null 2>&1
 
 yes >/dev/null &
 proc=$!
-proc_p=`cat /proc/${proc}/stat | awk '{ print $4 }'`
+proc_p=`cat /proc/${proc}/stat | cut -d' ' -f4`
 sleep 1
 testing "-P parent_prodId pattern" "pkill -P $proc_p yes && sleep 1 &&
    (pgrep yes || echo 'yes')" "yes\n" "" ""
 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" "" ""
+