Problem with current approach is that if qemuSecuritySetAllLabel() fails, then the @chown_paths and @xattr_paths hash tables are not freed and preserve values already stored there into the next test case. Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx> --- tests/qemusecuritymock.c | 14 ++++++++++++-- tests/qemusecuritytest.c | 1 + tests/qemusecuritytest.h | 2 ++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/tests/qemusecuritymock.c b/tests/qemusecuritymock.c index e52a41067a..815bd44d76 100644 --- a/tests/qemusecuritymock.c +++ b/tests/qemusecuritymock.c @@ -411,13 +411,23 @@ int checkPaths(void) ret = 0; cleanup: - virHashRemoveAll(chown_paths); - virHashRemoveAll(xattr_paths); virMutexUnlock(&m); return ret; } +void freePaths(void) +{ + virMutexLock(&m); + init_hash(); + + virHashFree(chown_paths); + virHashFree(xattr_paths); + chown_paths = xattr_paths = NULL; + virMutexUnlock(&m); +} + + int virProcessRunInFork(virProcessForkCallback cb, void *opaque) diff --git a/tests/qemusecuritytest.c b/tests/qemusecuritytest.c index 79d4f744b6..9ac953f388 100644 --- a/tests/qemusecuritytest.c +++ b/tests/qemusecuritytest.c @@ -125,6 +125,7 @@ testDomain(const void *opaque) unsetenv(ENVVAR); virObjectUnref(vm); virObjectUnref(securityManager); + freePaths(); return ret; } diff --git a/tests/qemusecuritytest.h b/tests/qemusecuritytest.h index a26014b5dc..29c6a9c998 100644 --- a/tests/qemusecuritytest.h +++ b/tests/qemusecuritytest.h @@ -23,4 +23,6 @@ extern int checkPaths(void); +extern void freePaths(void); + #endif /* LIBVIRT_QEMUSECURITYTEST_H */ -- 2.21.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list