Skip to content

Commit fb76210

Browse files
committed
crc32: add test case to cover simd implemetation
pclmul folding block size: 16, parallel folding 4 blocks: 64. The size covered below, 16, 16+3, 32, 32+3, 48, 48+3, 64, 64+3, 80, 80+3, 128, 128+3, 144, 144+3 Signed-off-by: Frank Du <[email protected]>
1 parent 9883fec commit fb76210

File tree

2 files changed

+113
-1
lines changed

2 files changed

+113
-1
lines changed

ext/hash/tests/crc32.phpt

Lines changed: 85 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,20 @@ echo hash('crc32', 'message digest'), "\n";
1010
echo hash('crc32', 'abcdefghijklmnopqrstuvwxyz'), "\n";
1111
echo hash('crc32', 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'), "\n";
1212
echo hash('crc32', '12345678901234567890123456789012345678901234567890123456789012345678901234567890'), "\n";
13+
echo hash('crc32', '1234567890123456'), "\n";
14+
echo hash('crc32', '1234567890123456abc'), "\n";
15+
echo hash('crc32', '12345678901234561234567890123456'), "\n";
16+
echo hash('crc32', '12345678901234561234567890123456abc'), "\n";
17+
echo hash('crc32', '123456789012345612345678901234561234567890123456'), "\n";
18+
echo hash('crc32', '123456789012345612345678901234561234567890123456abc'), "\n";
19+
echo hash('crc32', '1234567890123456123456789012345612345678901234561234567890123456'), "\n";
20+
echo hash('crc32', '1234567890123456123456789012345612345678901234561234567890123456abc'), "\n";
21+
echo hash('crc32', '12345678901234561234567890123456123456789012345612345678901234561234567890123456'), "\n";
22+
echo hash('crc32', '12345678901234561234567890123456123456789012345612345678901234561234567890123456abc'), "\n";
23+
echo hash('crc32', '12345678901234561234567890123456123456789012345612345678901234561234567890123456123456789012345612345678901234561234567890123456'), "\n";
24+
echo hash('crc32', '12345678901234561234567890123456123456789012345612345678901234561234567890123456123456789012345612345678901234561234567890123456abc'), "\n";
25+
echo hash('crc32', '123456789012345612345678901234561234567890123456123456789012345612345678901234561234567890123456123456789012345612345678901234561234567890123456'), "\n";
26+
echo hash('crc32', '123456789012345612345678901234561234567890123456123456789012345612345678901234561234567890123456123456789012345612345678901234561234567890123456abc'), "\n";
1327

1428
echo "crc32b\n";
1529
echo hash('crc32b', ''), "\n";
@@ -19,6 +33,20 @@ echo hash('crc32b', 'message digest'), "\n";
1933
echo hash('crc32b', 'abcdefghijklmnopqrstuvwxyz'), "\n";
2034
echo hash('crc32b', 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'), "\n";
2135
echo hash('crc32b', '12345678901234567890123456789012345678901234567890123456789012345678901234567890'), "\n";
36+
echo hash('crc32b', '1234567890123456'), "\n";
37+
echo hash('crc32b', '1234567890123456abc'), "\n";
38+
echo hash('crc32b', '12345678901234561234567890123456'), "\n";
39+
echo hash('crc32b', '12345678901234561234567890123456abc'), "\n";
40+
echo hash('crc32b', '123456789012345612345678901234561234567890123456'), "\n";
41+
echo hash('crc32b', '123456789012345612345678901234561234567890123456abc'), "\n";
42+
echo hash('crc32b', '1234567890123456123456789012345612345678901234561234567890123456'), "\n";
43+
echo hash('crc32b', '1234567890123456123456789012345612345678901234561234567890123456abc'), "\n";
44+
echo hash('crc32b', '12345678901234561234567890123456123456789012345612345678901234561234567890123456'), "\n";
45+
echo hash('crc32b', '12345678901234561234567890123456123456789012345612345678901234561234567890123456abc'), "\n";
46+
echo hash('crc32b', '12345678901234561234567890123456123456789012345612345678901234561234567890123456123456789012345612345678901234561234567890123456'), "\n";
47+
echo hash('crc32b', '12345678901234561234567890123456123456789012345612345678901234561234567890123456123456789012345612345678901234561234567890123456abc'), "\n";
48+
echo hash('crc32b', '123456789012345612345678901234561234567890123456123456789012345612345678901234561234567890123456123456789012345612345678901234561234567890123456'), "\n";
49+
echo hash('crc32b', '123456789012345612345678901234561234567890123456123456789012345612345678901234561234567890123456123456789012345612345678901234561234567890123456abc'), "\n";
2250

2351
echo "crc32c\n";
2452
echo hash('crc32c', ''), "\n";
@@ -59,6 +87,20 @@ echo hash('crc32c', "Even if I could be Shakespeare, I think I should still choo
5987
echo hash('crc32c', "The fugacity of a constituent in a mixture of gases at a given temperature is proportional to its mole fraction. Lewis-Randall Rule"), "\n";
6088
echo hash('crc32c', "How can you write a big system without C++? -Paul Glick"), "\n";
6189
echo hash('crc32c', "\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n\v\f\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !\"#\$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\x7f\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff"), "\n";
90+
echo hash('crc32c', '1234567890123456'), "\n";
91+
echo hash('crc32c', '1234567890123456abc'), "\n";
92+
echo hash('crc32c', '12345678901234561234567890123456'), "\n";
93+
echo hash('crc32c', '12345678901234561234567890123456abc'), "\n";
94+
echo hash('crc32c', '123456789012345612345678901234561234567890123456'), "\n";
95+
echo hash('crc32c', '123456789012345612345678901234561234567890123456abc'), "\n";
96+
echo hash('crc32c', '1234567890123456123456789012345612345678901234561234567890123456'), "\n";
97+
echo hash('crc32c', '1234567890123456123456789012345612345678901234561234567890123456abc'), "\n";
98+
echo hash('crc32c', '12345678901234561234567890123456123456789012345612345678901234561234567890123456'), "\n";
99+
echo hash('crc32c', '12345678901234561234567890123456123456789012345612345678901234561234567890123456abc'), "\n";
100+
echo hash('crc32c', '12345678901234561234567890123456123456789012345612345678901234561234567890123456123456789012345612345678901234561234567890123456'), "\n";
101+
echo hash('crc32c', '12345678901234561234567890123456123456789012345612345678901234561234567890123456123456789012345612345678901234561234567890123456abc'), "\n";
102+
echo hash('crc32c', '123456789012345612345678901234561234567890123456123456789012345612345678901234561234567890123456123456789012345612345678901234561234567890123456'), "\n";
103+
echo hash('crc32c', '123456789012345612345678901234561234567890123456123456789012345612345678901234561234567890123456123456789012345612345678901234561234567890123456abc'), "\n";
62104

63105
?>
64106
--EXPECT--
@@ -70,6 +112,20 @@ crc32
70112
9693bf77
71113
882174a0
72114
96790816
115+
98b0e78d
116+
a6f33d71
117+
900a1d38
118+
396978fe
119+
adfc6afe
120+
d3ef9388
121+
c53911dc
122+
37006f1b
123+
4a54af3a
124+
98d05c71
125+
5a26f5b4
126+
b9108715
127+
cc684112
128+
b2ac45af
73129
crc32b
74130
00000000
75131
e8b7be43
@@ -78,6 +134,20 @@ e8b7be43
78134
4c2750bd
79135
1fc2e6d2
80136
7ca94a72
137+
1e5fcdb7
138+
70b54c2f
139+
094fb11e
140+
38210c49
141+
7399c6ef
142+
83e98d04
143+
1f26a94e
144+
e2e8634a
145+
0642542d
146+
43b42c9b
147+
262e1ded
148+
b7a463c4
149+
dfa1bbae
150+
4022d57a
81151
crc32c
82152
00000000
83153
c1d04330
@@ -116,4 +186,18 @@ de2e65c5
116186
297a88ed
117187
66ed1d8b
118188
dcded527
119-
9c44184b
189+
9c44184b
190+
9aa4287f
191+
ab2761c5
192+
cd486b4b
193+
c19c4a41
194+
1ea5b441
195+
36d20512
196+
31d11ffa
197+
65d5bb9e
198+
a0e3e317
199+
8dc10a7c
200+
7ab04135
201+
c292a38d
202+
e3e558ec
203+
b6c5e13e

ext/standard/tests/strings/crc32.phpt

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,37 @@ $input = array("foo", "bar", "baz", "grldsajkopallkjasd");
66
foreach($input AS $i) {
77
printf("%u\n", crc32($i));
88
}
9+
printf("%u\n", crc32("1234567890123456"));
10+
printf("%u\n", crc32("1234567890123456abc"));
11+
printf("%u\n", crc32("12345678901234561234567890123456"));
12+
printf("%u\n", crc32("12345678901234561234567890123456abc"));
13+
printf("%u\n", crc32("123456789012345612345678901234561234567890123456"));
14+
printf("%u\n", crc32("123456789012345612345678901234561234567890123456abc"));
15+
printf("%u\n", crc32("1234567890123456123456789012345612345678901234561234567890123456"));
16+
printf("%u\n", crc32("1234567890123456123456789012345612345678901234561234567890123456abc"));
17+
printf("%u\n", crc32("12345678901234561234567890123456123456789012345612345678901234561234567890123456"));
18+
printf("%u\n", crc32("12345678901234561234567890123456123456789012345612345678901234561234567890123456abc"));
19+
printf("%u\n", crc32("12345678901234561234567890123456123456789012345612345678901234561234567890123456123456789012345612345678901234561234567890123456"));
20+
printf("%u\n", crc32("12345678901234561234567890123456123456789012345612345678901234561234567890123456123456789012345612345678901234561234567890123456abc"));
21+
printf("%u\n", crc32("123456789012345612345678901234561234567890123456123456789012345612345678901234561234567890123456123456789012345612345678901234561234567890123456"));
22+
printf("%u\n", crc32("123456789012345612345678901234561234567890123456123456789012345612345678901234561234567890123456123456789012345612345678901234561234567890123456abc"));
923
?>
1024
--EXPECT--
1125
2356372769
1226
1996459178
1327
2015626392
1428
824412087
29+
509595063
30+
1890929711
31+
156217630
32+
941689929
33+
1939457775
34+
2213121284
35+
522627406
36+
3806880586
37+
105010221
38+
1135881371
39+
640556525
40+
3081003972
41+
3751918510
42+
1076024698

0 commit comments

Comments
 (0)