test: Add reset to CuckooCache

Add a method that clears and resets CuckooCache, intended for
use in tests only. Without this, fuzz tests may reuse the cache
across iterations, resulting in instability.
This commit is contained in:
Eugene Siegel
2026-08-26 17:18:38 +01:00
committed by marcofleon
parent 67efced1fc
commit 40add915be

View File

@@ -329,7 +329,7 @@ public:
/** setup initializes the container to store no more than new_size
* elements and no less than 2 elements.
*
* setup should only be called once.
* setup should only be called once. TestOnlyReset() is the exception.
*
* @param new_size the desired number of elements to store
* @returns the maximum number of elements storable
@@ -483,6 +483,14 @@ public:
}
return false;
}
/** Empty the cache and re-run setup(). */
void TestOnlyReset()
{
table.clear();
epoch_flags.clear();
setup(0);
}
};
} // namespace CuckooCache