From e794647d2ac93a968c25491fe3681a9613c410e6 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Sun, 22 Sep 2019 09:45:30 -0500 Subject: Avoid spurious test failures when fork() coincides with signal being sent, then pgrep finds child that hasn't exec("sleep") yet. So add 1/10 sec sleep to let exec() happen before pgrep. While we're there fix spurious "terminated" messages and reorder test file creation so it fits in 80 columns. --- tests/killall.test | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/tests/killall.test b/tests/killall.test index b15dbf0f..7b2cee33 100644 --- a/tests/killall.test +++ b/tests/killall.test @@ -4,21 +4,18 @@ #testing "name" "command" "result" "infile" "stdin" -echo "#!$(which sh) -while true; do - sleep 0.1 -done" > toybox.killall.test.script -chmod a+x toybox.killall.test.script -cp toybox.killall.test.script toybox.test +echo -e "#!$(which sh)\nwhile true; do sleep 0.1; done" > toybox.test +chmod a+x toybox.test +cp toybox.test toybox.killall.test.script tst=toybox.test -./$tst & -testing "short name" "killall -w $tst && echo killed ; \ +(./$tst 2>/dev/null &) +testing "short name" "killall -w $tst && echo killed ; sleep 0.1; \ pgrep -l $tst || echo really" "killed\nreally\n" "" "" tst=toybox.killall.test.script -./$tst & -testing "long name" "killall -w $tst && echo killed ; \ +(./$tst 2>/dev/null &) +testing "long name" "killall -w $tst && echo killed ; sleep 0.1; \ pgrep -l $tst || echo really" "killed\nreally\n" "" "" rm -f toybox.killall.test.script toybox.test -- cgit v1.2.3