[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH 15/24] 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.
---
 tests/Makefile.am                                     | 17 +++++++++--------
 tests/{virmacmapmock.c => virdeterministichashmock.c} |  0
 tests/virmacmaptest.c                                 |  2 +-
 3 files changed, 10 insertions(+), 9 deletions(-)
 rename tests/{virmacmapmock.c => virdeterministichashmock.c} (100%)

diff --git a/tests/Makefile.am b/tests/Makefile.am
index 5be81d221..a2a9ebec9 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1198,22 +1198,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 = \
diff --git a/tests/virmacmapmock.c b/tests/virdeterministichashmock.c
similarity index 100%
rename from tests/virmacmapmock.c
rename to tests/virdeterministichashmock.c
diff --git a/tests/virmacmaptest.c b/tests/virmacmaptest.c
index 35e312771..0627fb37a 100644
--- a/tests/virmacmaptest.c
+++ b/tests/virmacmaptest.c
@@ -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")
-- 
2.13.2


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]