diff options
author | Rob Landley <rob@landley.net> | 2019-10-11 15:40:08 -0500 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2019-10-11 15:40:08 -0500 |
commit | c8400d7f82adbf1716244e136121ab59a4b075fb (patch) | |
tree | 35aedbed8392028f8ae5592c784ede7f13e886bc /tests | |
parent | 35666e7336d7f2918283d518bc7c05e6d5f7fd0c (diff) | |
download | toybox-c8400d7f82adbf1716244e136121ab59a4b075fb.tar.gz |
Fix same spurious test failures that were affecting killall,
and silence "killed" messages from the shell by forking in a subshell.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/pidof.test | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/tests/pidof.test b/tests/pidof.test index 7de31fc2..1d0ea567 100644 --- a/tests/pidof.test +++ b/tests/pidof.test @@ -8,26 +8,22 @@ # pidof (unlike killall) doesn't match argv[1] unless you supply -x. # -echo "#!$(which sh) -while true; do - sleep 0.1 -done" > toybox.pidof.test.script -chmod a+x toybox.pidof.test.script -cp toybox.pidof.test.script pidof.test - -./pidof.test & -pid=$! -testcmd "short argv[1]" "pidof.test" "" "" "" -testcmd "short argv[1] -x" "-x pidof.test" "$pid\n" "" "" +echo -e "#!$(which sh)\nread i < /proc/self/fd/1" > pidof-$$.test +chmod a+x pidof-$$.test +cp pidof-$$.test toybox.pidof-$$.test.script +(./pidof-$$.test & echo $! > pid.txt) +pid=$(cat pid.txt) +testcmd "short argv[1]" "pidof-$$.test" "" "" "" +testcmd "short argv[1] -x" "-x pidof-$$.test" "$pid\n" "" "" kill $pid -./toybox.pidof.test.script & -pid=$! -testcmd "long argv[1]" "toybox.pidof.test.script" "" "" "" -testcmd "long argv[1] -x" "-x toybox.pidof.test.script" "$pid\n" "" "" +(./toybox.pidof-$$.test.script & echo $! > pid.txt) +pid=$(cat pid.txt) +testcmd "long argv[1]" "toybox.pidof-$$.test.script" "" "" "" +testcmd "long argv[1] -x" "-x toybox.pidof-$$.test.script" "$pid\n" "" "" kill $pid -rm -f toybox.pidof.test.script toybox.test +rm -f toybox.pidof-$$.test.script pidof-$$.test pid.txt # pidof (unlike killall) will match itself. testcmd "pidof pidof" "pidof > /dev/null && echo found" "found\n" "" "" |