]>
Commit | Line | Data |
---|---|---|
f52207a4 GS |
1 | #!/bin/sh |
2 | ||
3 | test_description='Testing the various Bloom filter computations in bloom.c' | |
4 | . ./test-lib.sh | |
5 | ||
6 | test_expect_success 'compute unseeded murmur3 hash for empty string' ' | |
7 | cat >expect <<-\EOF && | |
8 | Murmur3 Hash with seed=0:0x00000000 | |
9 | EOF | |
10 | test-tool bloom get_murmur3 "" >actual && | |
11 | test_cmp expect actual | |
12 | ' | |
13 | ||
14 | test_expect_success 'compute unseeded murmur3 hash for test string 1' ' | |
15 | cat >expect <<-\EOF && | |
16 | Murmur3 Hash with seed=0:0x627b0c2c | |
17 | EOF | |
18 | test-tool bloom get_murmur3 "Hello world!" >actual && | |
19 | test_cmp expect actual | |
20 | ' | |
21 | ||
22 | test_expect_success 'compute unseeded murmur3 hash for test string 2' ' | |
23 | cat >expect <<-\EOF && | |
24 | Murmur3 Hash with seed=0:0x2e4ff723 | |
25 | EOF | |
26 | test-tool bloom get_murmur3 "The quick brown fox jumps over the lazy dog" >actual && | |
27 | test_cmp expect actual | |
28 | ' | |
29 | ||
f1294eaf GS |
30 | test_expect_success 'compute bloom key for empty string' ' |
31 | cat >expect <<-\EOF && | |
32 | Hashes:0x5615800c|0x5b966560|0x61174ab4|0x66983008|0x6c19155c|0x7199fab0|0x771ae004| | |
33 | Filter_Length:2 | |
34 | Filter_Data:11|11| | |
35 | EOF | |
36 | test-tool bloom generate_filter "" >actual && | |
37 | test_cmp expect actual | |
38 | ' | |
39 | ||
40 | test_expect_success 'compute bloom key for whitespace' ' | |
41 | cat >expect <<-\EOF && | |
42 | Hashes:0xf178874c|0x5f3d6eb6|0xcd025620|0x3ac73d8a|0xa88c24f4|0x16510c5e|0x8415f3c8| | |
43 | Filter_Length:2 | |
44 | Filter_Data:51|55| | |
45 | EOF | |
46 | test-tool bloom generate_filter " " >actual && | |
47 | test_cmp expect actual | |
48 | ' | |
49 | ||
50 | test_expect_success 'compute bloom key for test string 1' ' | |
51 | cat >expect <<-\EOF && | |
52 | Hashes:0xb270de9b|0x1bb6f26e|0x84fd0641|0xee431a14|0x57892de7|0xc0cf41ba|0x2a15558d| | |
53 | Filter_Length:2 | |
54 | Filter_Data:92|6c| | |
55 | EOF | |
56 | test-tool bloom generate_filter "Hello world!" >actual && | |
57 | test_cmp expect actual | |
58 | ' | |
59 | ||
60 | test_expect_success 'compute bloom key for test string 2' ' | |
61 | cat >expect <<-\EOF && | |
62 | Hashes:0x20ab385b|0xf5237fe2|0xc99bc769|0x9e140ef0|0x728c5677|0x47049dfe|0x1b7ce585| | |
63 | Filter_Length:2 | |
64 | Filter_Data:a5|4a| | |
65 | EOF | |
66 | test-tool bloom generate_filter "file.txt" >actual && | |
67 | test_cmp expect actual | |
68 | ' | |
69 | ||
ed591feb GS |
70 | test_expect_success 'get bloom filters for commit with no changes' ' |
71 | git init && | |
72 | git commit --allow-empty -m "c0" && | |
73 | cat >expect <<-\EOF && | |
59f0d507 TB |
74 | Filter_Length:1 |
75 | Filter_Data:00| | |
ed591feb GS |
76 | EOF |
77 | test-tool bloom get_filter_for_commit "$(git rev-parse HEAD)" >actual && | |
78 | test_cmp expect actual | |
79 | ' | |
80 | ||
81 | test_expect_success 'get bloom filter for commit with 10 changes' ' | |
82 | rm actual && | |
83 | rm expect && | |
84 | mkdir smallDir && | |
85 | for i in $(test_seq 0 9) | |
86 | do | |
db5875aa | 87 | echo $i >smallDir/$i || return 1 |
ed591feb GS |
88 | done && |
89 | git add smallDir && | |
90 | git commit -m "commit with 10 changes" && | |
91 | cat >expect <<-\EOF && | |
65c1a28b DS |
92 | Filter_Length:14 |
93 | Filter_Data:02|b3|c4|a0|34|e7|fe|eb|cb|47|fe|a0|e8|72| | |
ed591feb GS |
94 | EOF |
95 | test-tool bloom get_filter_for_commit "$(git rev-parse HEAD)" >actual && | |
96 | test_cmp expect actual | |
97 | ' | |
98 | ||
99 | test_expect_success EXPENSIVE 'get bloom filter for commit with 513 changes' ' | |
100 | rm actual && | |
101 | rm expect && | |
102 | mkdir bigDir && | |
2f6775f0 | 103 | for i in $(test_seq 0 511) |
ed591feb | 104 | do |
db5875aa | 105 | echo $i >bigDir/$i || return 1 |
ed591feb GS |
106 | done && |
107 | git add bigDir && | |
108 | git commit -m "commit with 513 changes" && | |
109 | cat >expect <<-\EOF && | |
59f0d507 TB |
110 | Filter_Length:1 |
111 | Filter_Data:ff| | |
ed591feb GS |
112 | EOF |
113 | test-tool bloom get_filter_for_commit "$(git rev-parse HEAD)" >actual && | |
114 | test_cmp expect actual | |
115 | ' | |
116 | ||
066b70ae | 117 | test_done |