Make tests public. Rewrite most tests. Add tests.
[pintos-anon] / src / tests / threads / alarm.pm
1 sub check_alarm {
2     my ($iterations) = @_;
3     our ($test);
4
5     @output = read_text_file ("$test.output");
6     common_checks (@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;