3 # Test script for buildrun.
5 # Can be used with my original inotify-based implementation too,
6 # provided you pass --old on the command line.
11 # The inotify-based version wouldn't cope if the control file didn't
12 # exist to begin with. Create an empty one.
13 if test "x--old" = "x$1"; then touch testctl
; fi
15 testwrite
() { # usage: testwrite <identifier> <exitstatus>
16 buildrun
-w testctl sh
-c
"echo write start $1 >> testlog; sleep 2; echo write end $1 returning $2 >> testlog; exit $2"
18 testread
() { # usage: testread <identifier>
19 echo read start
$1 >> testlog
20 buildrun
-r testctl sh
-c
"echo read end $1 >> testlog"
23 # Test 1: start buildrun -w first, then buildrun -r. The former
24 # completes successfully, and the latter should then finish.
29 # Test 2: same, but this time the first -w fails and we need a second
31 ( testwrite
2a
1; sleep 0.5; testwrite
2b
0 ) &
35 # Test 3: this time we arrange a failure, and then start up a buildrun
36 # -r while no -w is running at all, demonstrating that it can block
37 # even when there's nothing to block on.
44 # Test 4: same, but again we have a failure before a success.
48 testwrite
4a
1; sleep 0.5; testwrite
4b
0
51 # Test 5: now that no -w run is active and the last one was
52 # successful, do a -r run on its own and check that it returns success
56 if diff -u testout.txt testlog
; then
57 # Files match. Report success and clear up.
62 # They don't match. Leave the temporary files lying around and