mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
util: virfilecache: Introduce virFileCacheClear for usage in tests
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>
This commit is contained in:
parent
3c02b1e810
commit
6ac7e0a06f
@ -2354,6 +2354,7 @@ virFindFileInPath;
|
||||
|
||||
|
||||
# util/virfilecache.h
|
||||
virFileCacheClear;
|
||||
virFileCacheGetPriv;
|
||||
virFileCacheInsertData;
|
||||
virFileCacheLookup;
|
||||
|
@ -407,3 +407,19 @@ virFileCacheInsertData(virFileCache *cache,
|
||||
|
||||
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);
|
||||
}
|
||||
|
@ -135,3 +135,7 @@ int
|
||||
virFileCacheInsertData(virFileCache *cache,
|
||||
const char *name,
|
||||
void *data);
|
||||
|
||||
/* for testing usage */
|
||||
void
|
||||
virFileCacheClear(virFileCache *cache);
|
||||
|
Loading…
x
Reference in New Issue
Block a user