tests: Extract mock library for making hash table deterministic

virHashNew calls virRandomBits to initialize seed for the hashing
function. If a test uses iteration through the hash table to produce
results they may/will be non-deterministic. Extract the mock library
which was used for mac address mapping to be universal.

Reviewed-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
Peter Krempa 2017-07-26 10:02:21 +02:00
parent 0175dc6ea0
commit 4983368367
3 changed files with 10 additions and 9 deletions

View File

@ -1206,22 +1206,23 @@ else ! WITH_NSS
EXTRA_DIST += nsstest.c nssmock.c nsslinktest.c
endif ! WITH_NSS
if WITH_YAJL
virmacmapmock_la_SOURCES = \
virmacmapmock.c
virmacmapmock_la_CFLAGS = $(AM_CFLAGS)
virmacmapmock_la_LDFLAGS = $(MOCKLIBS_LDFLAGS)
virmacmapmock_la_LIBADD = $(MOCKLIBS_LIBS)
virdeterministichashmock_la_SOURCES = \
virdeterministichashmock.c
virdeterministichashmock_la_CFLAGS = $(AM_CFLAGS)
virdeterministichashmock_la_LDFLAGS = $(MOCKLIBS_LDFLAGS)
virdeterministichashmock_la_LIBADD = $(MOCKLIBS_LIBS)
test_libraries += virdeterministichashmock.la
if WITH_YAJL
virmacmaptest_SOURCES = \
virmacmaptest.c testutils.h testutils.c
virmacmaptest_CLFAGS = $(AM_CFLAGS)
virmacmaptest_LDADD = $(LDADDS)
test_libraries += virmacmapmock.la
test_programs += virmacmaptest
else ! WITH_YAJL
EXTRA_DIST += virmacmapmock.c virmacmaptest.c
EXTRA_DIST += virmacmaptest.c
endif ! WITH_YAJL
virnetdevtest_SOURCES = \

View File

@ -234,4 +234,4 @@ mymain(void)
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
}
VIR_TEST_MAIN_PRELOAD(mymain, abs_builddir "/.libs/virmacmapmock.so")
VIR_TEST_MAIN_PRELOAD(mymain, abs_builddir "/.libs/virdeterministichashmock.so")