diff --git a/tests/lib/subdir.am b/tests/lib/subdir.am index 6c897b132e..62b194439f 100644 --- a/tests/lib/subdir.am +++ b/tests/lib/subdir.am @@ -148,7 +148,7 @@ check_PROGRAMS += tests/lib/test_checksum tests_lib_test_checksum_CFLAGS = $(TESTS_CFLAGS) tests_lib_test_checksum_CPPFLAGS = $(TESTS_CPPFLAGS) tests_lib_test_checksum_LDADD = $(ALL_TESTS_LDADD) -tests_lib_test_checksum_SOURCES = tests/lib/test_checksum.c +tests_lib_test_checksum_SOURCES = tests/lib/test_checksum.c tests/helpers/c/prng.c check_PROGRAMS += tests/lib/test_graph diff --git a/tests/lib/test_checksum.c b/tests/lib/test_checksum.c index 0eedb96a5e..9a7f2b1472 100644 --- a/tests/lib/test_checksum.c +++ b/tests/lib/test_checksum.c @@ -24,6 +24,7 @@ #include "checksum.h" #include "network.h" +#include "prng.h" struct thread_master *master; @@ -468,24 +469,19 @@ int main(int argc, char **argv) uint8_t buffer[BUFSIZE]; int exercise = 0; #define EXERCISESTEP 257 - srandom(time(NULL)); + struct prng *prng = prng_new(0); while (1) { uint16_t ospfd, isisd, lib, in_csum, in_csum_res, in_csum_rfc; - int i, j; + int i; exercise += EXERCISESTEP; exercise %= MAXDATALEN; printf("\rexercising length %d\033[K", exercise); - for (i = 0; i < exercise; i += sizeof(long int)) { - long int rand = frr_weak_random(); - - for (j = sizeof(long int); j > 0; j--) - buffer[i + (sizeof(long int) - j)] = - (rand >> (j * 8)) & 0xff; - } + for (i = 0; i < exercise; i++) + buffer[i] = prng_rand(prng); in_csum = in_cksum(buffer, exercise); in_csum_res = in_cksum_optimized(buffer, exercise); @@ -537,6 +533,9 @@ int main(int argc, char **argv) iov[2].iov_len, in_csum_iov, in_csum); } + if (exercise >= FLETCHER_CHECKSUM_VALIDATE) + continue; + ospfd = ospfd_checksum(buffer, exercise + sizeof(uint16_t), exercise); if (verify(buffer, exercise + sizeof(uint16_t)))