Make tests public. Rewrite most tests. Add tests.
[pintos-anon] / src / tests / vm / mmap-shuffle.ck
1 # -*- perl -*-
2 use strict;
3 use warnings;
4 use tests::tests;
5 use tests::cksum;
6 use tests::lib;
7
8 my ($init, @shuffle);
9 if (1) {
10     # Use precalculated values.
11     $init = 3115322833;
12     @shuffle = (1691062564, 1973575879, 1647619479, 96566261, 3885786467,
13                 3022003332, 3614934266, 2704001777, 735775156, 1864109763);
14 } else {
15     # Recalculate values.
16     my ($buf) = "";
17     for my $i (0...128 * 1024 - 1) {
18         $buf .= chr (($i * 257) & 0xff);
19     }
20     $init = cksum ($buf);
21
22     random_init (0);
23     for my $i (1...10) {
24         $buf = shuffle ($buf, length ($buf), 1);
25         push (@shuffle, cksum ($buf));
26     }
27 }
28
29 check_expected (IGNORE_EXIT_CODES => 1, [<<EOF]);
30 (mmap-shuffle) begin
31 (mmap-shuffle) create "buffer"
32 (mmap-shuffle) open "buffer"
33 (mmap-shuffle) mmap "buffer"
34 (mmap-shuffle) init: cksum=$init
35 (mmap-shuffle) shuffle 0: cksum=$shuffle[0]
36 (mmap-shuffle) shuffle 1: cksum=$shuffle[1]
37 (mmap-shuffle) shuffle 2: cksum=$shuffle[2]
38 (mmap-shuffle) shuffle 3: cksum=$shuffle[3]
39 (mmap-shuffle) shuffle 4: cksum=$shuffle[4]
40 (mmap-shuffle) shuffle 5: cksum=$shuffle[5]
41 (mmap-shuffle) shuffle 6: cksum=$shuffle[6]
42 (mmap-shuffle) shuffle 7: cksum=$shuffle[7]
43 (mmap-shuffle) shuffle 8: cksum=$shuffle[8]
44 (mmap-shuffle) shuffle 9: cksum=$shuffle[9]
45 (mmap-shuffle) end
46 EOF