summaryrefslogtreecommitdiffstats
path: root/src/compiler/glsl/tests/cache_test.c
diff options
context:
space:
mode:
authorAlan Swanson <[email protected]>2017-03-06 16:17:31 +0000
committerTimothy Arceri <[email protected]>2017-03-15 11:15:11 +1100
commitf1e96714424f516ec3ee7a341fb10068340b0411 (patch)
tree0b7d3db44aecc4ce9b50ad9a5ba746e39bc0d6ca /src/compiler/glsl/tests/cache_test.c
parentaf09b867329bcc5d50c22c2e634f5c5deb51e184 (diff)
util/disk_cache: actually enforce cache size
Currently only a one in one out eviction so if at max_size and cache files were to constantly increase in size then so would the cache. Restrict to limit of 8 evictions per new cache entry. V2: (Timothy Arceri) fix make check tests Reviewed-by: Grazvydas Ignotas <[email protected]>
Diffstat (limited to 'src/compiler/glsl/tests/cache_test.c')
-rw-r--r--src/compiler/glsl/tests/cache_test.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/compiler/glsl/tests/cache_test.c b/src/compiler/glsl/tests/cache_test.c
index 61ee630395a..832693e1039 100644
--- a/src/compiler/glsl/tests/cache_test.c
+++ b/src/compiler/glsl/tests/cache_test.c
@@ -350,9 +350,10 @@ test_put_and_get(void)
free(result);
- /* Ensure eviction happened by checking that only one of the two
- * previously-added items can still be fetched.
+ /* Ensure eviction happened by checking that both of the previous
+ * cache itesm were evicted.
*/
+ bool contains_1KB_file = false;
count = 0;
if (does_cache_contain(cache, blob_key))
count++;
@@ -360,6 +361,13 @@ test_put_and_get(void)
if (does_cache_contain(cache, string_key))
count++;
+ if (does_cache_contain(cache, one_KB_key)) {
+ count++;
+ contains_1KB_file = true;
+ }
+
+ expect_true(contains_1KB_file,
+ "disk_cache_put eviction last file == MAX_SIZE (1KB)");
expect_equal(count, 1, "disk_cache_put eviction with MAX_SIZE=1K");
/* Now increase the size to 1M, add back both items, and ensure all
@@ -406,6 +414,7 @@ test_put_and_get(void)
*/
wait_until_file_written(cache, one_MB_key);
+ bool contains_1MB_file = false;
count = 0;
if (does_cache_contain(cache, blob_key))
count++;
@@ -416,7 +425,14 @@ test_put_and_get(void)
if (does_cache_contain(cache, one_KB_key))
count++;
- expect_equal(count, 2, "eviction after overflow with MAX_SIZE=1M");
+ if (does_cache_contain(cache, one_MB_key)) {
+ count++;
+ contains_1MB_file = true;
+ }
+
+ expect_true(contains_1MB_file,
+ "disk_cache_put eviction last file == MAX_SIZE (1MB)");
+ expect_equal(count, 1, "eviction after overflow with MAX_SIZE=1M");
disk_cache_destroy(cache);
}