Skip to content

Commit 175208a

Browse files
neuschaefervaintroub
authored andcommitted
Improve crc32 test data
Previously, the buffer used to check that long CRC32 produce the right results, was initialized with the same value repeated in every byte. This is subobtimal as it can't detect bugs in which a 8-byte SIMD unit of data is loaded and processed in the wrong endianness. Improve the test by initializing the buffer with a pattern that does not repeat along power-of-two boundaries. 251 was picked as the highest prime number that fits in a byte.
1 parent 40e55f9 commit 175208a

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

unittest/mysys/crc32-t.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@ int main(int argc __attribute__((unused)),char *argv[])
136136
DO_TEST_CRC32C(0,STR,(sizeof(STR)-1));
137137
ok(0 == my_crc32c(0, NULL, 0), "crc32c data = NULL, length = 0");
138138

139-
memset(buf, 0x5a, sizeof buf);
139+
for (size_t i = 0; i < sizeof buf; i++)
140+
buf[i] = i % 251;
140141
ok(0 == test_buf(my_checksum, crc32), "crc32 with various lengths");
141142
ok(0 == test_buf(my_crc32c, crc32c), "crc32c with various lengths");
142143

0 commit comments

Comments
 (0)