Author: pjd
Date: Sun Jan 26 11:03:45 2020
New Revision: 357142
URL: https://svnweb.freebsd.org/changeset/base/357142

Log:
  Implement tests for the newly added -o flag.
  
  Sponsored by: Fudo Security

Modified:
  head/bin/pwait/tests/pwait_test.sh

Modified: head/bin/pwait/tests/pwait_test.sh
==============================================================================
--- head/bin/pwait/tests/pwait_test.sh  Sun Jan 26 11:02:51 2020        
(r357141)
+++ head/bin/pwait/tests/pwait_test.sh  Sun Jan 26 11:03:45 2020        
(r357142)
@@ -232,6 +232,85 @@ timeout_many_cleanup()
        wait $p1 $p5 $p10 >/dev/null 2>&1
 }
 
+atf_test_case or_flag
+or_flag_head()
+{
+       atf_set "descr" "Test OR flag"
+}
+
+or_flag_body()
+{
+       sleep 2 &
+       p2=$!
+
+       sleep 4 &
+       p4=$!
+
+       sleep 6 &
+       p6=$!
+
+       atf_check \
+               -o inline:"$p2: exited with status 0.\n" \
+               -e empty \
+               -s exit:0 \
+               timeout --preserve-status 15 pwait -o -v $p2 $p4 $p6
+
+       atf_check \
+               -o empty \
+               -e inline:"pwait: $p2: No such process\n" \
+               -s exit:0 \
+               timeout --preserve-status 15 pwait -o $p2 $p4 $p6
+
+       atf_check \
+               -o empty \
+               -e empty \
+               -s exit:0 \
+               timeout --preserve-status 15 pwait -o $p4 $p6
+
+       atf_check \
+               -o empty \
+               -e inline:"pwait: $p4: No such process\n" \
+               -s exit:0 \
+               timeout --preserve-status 15 pwait -o $p4 $p6
+
+       atf_check \
+               -o inline:"$p6: exited with status 0.\n" \
+               -e empty \
+               -s exit:0 \
+               timeout --preserve-status 15 pwait -o -v $p6
+
+       atf_check \
+               -o empty \
+               -e inline:"pwait: $p6: No such process\n" \
+               -s exit:0 \
+               timeout --preserve-status 15 pwait -o $p6
+
+       atf_check \
+               -o empty \
+               -e inline:"kill: $p2: No such process\n" \
+               -s exit:1 \
+               kill -0 $p2
+
+       atf_check \
+               -o empty \
+               -e inline:"kill: $p4: No such process\n" \
+               -s exit:1 \
+               kill -0 $p4
+
+       atf_check \
+               -o empty \
+               -e inline:"kill: $p6: No such process\n" \
+               -s exit:1 \
+               kill -0 $p6
+
+}
+
+or_flag_cleanup()
+{
+       kill $p2 $p4 $p6 >/dev/null 2>&1
+       wait $p2 $p4 $p6 >/dev/null 2>&1
+}
+
 atf_init_test_cases()
 {
        atf_add_test_case basic
@@ -239,4 +318,5 @@ atf_init_test_cases()
        atf_add_test_case timeout_trigger_timeout
        atf_add_test_case timeout_no_timeout
        atf_add_test_case timeout_many
+       atf_add_test_case or_flag
 }
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to