diff options
Diffstat (limited to 'tests/threads/alarm.pm')
| -rw-r--r-- | tests/threads/alarm.pm | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/threads/alarm.pm b/tests/threads/alarm.pm new file mode 100644 index 0000000..84b3b7f --- /dev/null +++ b/tests/threads/alarm.pm | |||
| @@ -0,0 +1,32 @@ | |||
| 1 | sub check_alarm { | ||
| 2 | my ($iterations) = @_; | ||
| 3 | our ($test); | ||
| 4 | |||
| 5 | @output = read_text_file ("$test.output"); | ||
| 6 | common_checks ("run", @output); | ||
| 7 | |||
| 8 | my (@products); | ||
| 9 | for (my ($i) = 0; $i < $iterations; $i++) { | ||
| 10 | for (my ($t) = 0; $t < 5; $t++) { | ||
| 11 | push (@products, ($i + 1) * ($t + 1) * 10); | ||
| 12 | } | ||
| 13 | } | ||
| 14 | @products = sort {$a <=> $b} @products; | ||
| 15 | |||
| 16 | local ($_); | ||
| 17 | foreach (@output) { | ||
| 18 | fail $_ if /out of order/i; | ||
| 19 | |||
| 20 | my ($p) = /product=(\d+)$/; | ||
| 21 | next if !defined $p; | ||
| 22 | |||
| 23 | my ($q) = shift (@products); | ||
| 24 | fail "Too many wakeups.\n" if !defined $q; | ||
| 25 | fail "Out of order wakeups ($p vs. $q).\n" if $p != $q; # FIXME | ||
| 26 | } | ||
| 27 | fail scalar (@products) . " fewer wakeups than expected.\n" | ||
| 28 | if @products != 0; | ||
| 29 | pass; | ||
| 30 | } | ||
| 31 | |||
| 32 | 1; | ||
