]> granicus.if.org Git - strace/commitdiff
tests/sched.test: use heredoc in order to avoid spawning of subprocess
authorEugene Syromyatnikov <evgsyr@gmail.com>
Mon, 13 Mar 2017 16:52:41 +0000 (17:52 +0100)
committerDmitry V. Levin <ldv@altlinux.org>
Wed, 15 Mar 2017 01:10:51 +0000 (01:10 +0000)
Pipelined commands executed in subprocesses (some shells have special
provision for last command in the pipeline, but it is not guaranteed
and not POSIX), so exit codes of these subprocesses can be lost.
In order to avoid creating subprocesses, input for read commands
is better to supply via heredoc and not pipe.

* tests/sched.test: Move test cases to heredoc.

tests/sched.test

index c334660a8f9226d2076a4397d909247cf550cd36..5d891f6c1135a934c83d191ca4ba4ae7d22585bf 100755 (executable)
@@ -41,32 +41,32 @@ try_run_prog()
        }
 }
 
-SCHED_TESTS='28 sched_xetaffinity
+while read w i
+do
+       try_run_prog "./$i" || continue
+       run_strace -a$w -e%sched ./$i > "$EXP"
+       match_diff "$LOG" "$EXP"
+done << EOF
+28 sched_xetaffinity
 23 sched_xetparam
 31 sched_rr_get_interval
 33 sched_get_priority_mxx
 29 sched_xetattr
 22 sched_xetscheduler
-14 sched_yield'
-
-NON_SCHED_TESTS='11 fchdir
-28 futex
-10 fsync'
-
-echo "$SCHED_TESTS" | while read w i
-do
-       try_run_prog "./$i" || continue
-       run_strace -a$w -e%sched ./$i > "$EXP"
-       match_diff "$LOG" "$EXP"
-done
+14 sched_yield
+EOF
 
 echo '+++ exited with 0 +++' > "$EXP"
 
-echo "$NON_SCHED_TESTS" | while read w i
+while read w i
 do
        try_run_prog "./$i" || continue
        run_strace -a$w -e%sched ./$i > /dev/null
        match_diff "$LOG" "$EXP"
-done
+done << EOF
+11 fchdir
+28 futex
+10 fsync
+EOF
 
 rm "$EXP"