In tests we need to be able to populate the cache with a deterministic
set of entries. This means we need to drop the contents of the cache
between runs to prevent spillage between test cases.
virFileCacheClear drops all entries from the hash table used for the
cache.
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
# util/virfilecache.h
+virFileCacheClear;
virFileCacheGetPriv;
virFileCacheInsertData;
virFileCacheLookup;
return ret;
}
+
+
+/**
+ * virFileCacheClear:
+ * @cache: existing cache object
+ *
+ * Drops all entries from the cache. This is useful in tests to clean out
+ * previous usage.
+ */
+void
+virFileCacheClear(virFileCache *cache)
+{
+ virObjectLock(cache);
+ virHashRemoveAll(cache->table);
+ virObjectUnlock(cache);
+}
virFileCacheInsertData(virFileCache *cache,
const char *name,
void *data);
+
+/* for testing usage */
+void
+virFileCacheClear(virFileCache *cache);