• Home
  • Raw
  • Download

Lines Matching full:cache

24 /* A collection of unit tests for cache.c */
96 does_cache_contain(struct disk_cache *cache, const cache_key key) in does_cache_contain() argument
100 result = disk_cache_get(cache, key, NULL); in does_cache_contain()
111 cache_exists(struct disk_cache *cache) in cache_exists() argument
116 if (!cache) in cache_exists()
119 disk_cache_compute_key(cache, data, sizeof(data), key); in cache_exists()
120 disk_cache_put(cache, key, data, sizeof(data), NULL); in cache_exists()
121 disk_cache_wait_for_idle(cache); in cache_exists()
122 void *result = disk_cache_get(cache, key, NULL); in cache_exists()
128 #define CACHE_TEST_TMP "./cache-test-tmp"
133 struct disk_cache *cache; in test_disk_cache_create() local
140 cache = disk_cache_create("test", "make_check", 0); in test_disk_cache_create()
141 EXPECT_EQ(cache, nullptr) << "disk_cache_create with MESA_SHADER_CACHE_DISABLE set"; in test_disk_cache_create()
150 cache = disk_cache_create("test", "make_check", 0); in test_disk_cache_create()
151 EXPECT_EQ(cache, nullptr) in test_disk_cache_create()
155 /* For remaining tests, ensure that the cache is enabled. */ in test_disk_cache_create()
160 * variables to test creation of cache in home directory. in test_disk_cache_create()
165 cache = disk_cache_create("test", "make_check", 0); in test_disk_cache_create()
166 EXPECT_NE(cache, nullptr) << "disk_cache_create with no environment variables"; in test_disk_cache_create()
168 disk_cache_destroy(cache); in test_disk_cache_create()
171 /* Android doesn't try writing to disk (just calls the cache callbacks), so in test_disk_cache_create()
178 setenv("XDG_CACHE_HOME", CACHE_TEST_TMP "/xdg-cache-home", 1); in test_disk_cache_create()
179 cache = disk_cache_create("test", "make_check", 0); in test_disk_cache_create()
180 EXPECT_FALSE(cache_exists(cache)) in test_disk_cache_create()
188 disk_cache_destroy(cache); in test_disk_cache_create()
190 cache = disk_cache_create("test", "make_check", 0); in test_disk_cache_create()
191 EXPECT_TRUE(cache_exists(cache)) in test_disk_cache_create()
195 mem_ctx, "%s%s", CACHE_TEST_TMP "/xdg-cache-home/", cache_dir_name); in test_disk_cache_create()
198 disk_cache_destroy(cache); in test_disk_cache_create()
204 setenv("MESA_SHADER_CACHE_DIR", CACHE_TEST_TMP "/mesa-shader-cache-dir", 1); in test_disk_cache_create()
205 cache = disk_cache_create("test", "make_check", 0); in test_disk_cache_create()
206 EXPECT_FALSE(cache_exists(cache)) in test_disk_cache_create()
214 disk_cache_destroy(cache); in test_disk_cache_create()
216 cache = disk_cache_create("test", "make_check", 0); in test_disk_cache_create()
217 EXPECT_TRUE(cache_exists(cache)) << "disk_cache_create with MESA_SHADER_CACHE_DIR set"; in test_disk_cache_create()
220 mem_ctx, "%s%s", CACHE_TEST_TMP "/mesa-shader-cache-dir/", cache_dir_name); in test_disk_cache_create()
223 disk_cache_destroy(cache); in test_disk_cache_create()
229 struct disk_cache *cache; in test_put_and_get() local
244 cache = disk_cache_create("test", "make_check", 0); in test_put_and_get()
246 disk_cache_compute_key(cache, blob, sizeof(blob), blob_key); in test_put_and_get()
249 result = (char *) disk_cache_get(cache, blob_key, &size); in test_put_and_get()
254 disk_cache_put(cache, blob_key, blob, sizeof(blob), NULL); in test_put_and_get()
257 disk_cache_wait_for_idle(cache); in test_put_and_get()
259 result = (char *) disk_cache_get(cache, blob_key, &size); in test_put_and_get()
266 disk_cache_compute_key(cache, string, sizeof(string), string_key); in test_put_and_get()
267 disk_cache_put(cache, string_key, string, sizeof(string), NULL); in test_put_and_get()
270 disk_cache_wait_for_idle(cache); in test_put_and_get()
272 result = (char *) disk_cache_get(cache, string_key, &size); in test_put_and_get()
278 /* Set the cache size to 1KB and add a 1KB item to force an eviction. */ in test_put_and_get()
279 disk_cache_destroy(cache); in test_put_and_get()
285 cache = disk_cache_create("test", "make_check", 0); in test_put_and_get()
292 * (with only three files in the cache), the probability is good in test_put_and_get()
304 * directory as the original blob first written to the cache. in test_put_and_get()
306 disk_cache_compute_key(cache, one_KB, 1024, one_KB_key); in test_put_and_get()
309 disk_cache_put(cache, one_KB_key, one_KB, 1024, NULL); in test_put_and_get()
314 disk_cache_wait_for_idle(cache); in test_put_and_get()
316 result = (char *) disk_cache_get(cache, one_KB_key, &size); in test_put_and_get()
323 * cache itesm were evicted. in test_put_and_get()
327 if (does_cache_contain(cache, blob_key)) in test_put_and_get()
330 if (does_cache_contain(cache, string_key)) in test_put_and_get()
333 if (does_cache_contain(cache, one_KB_key)) { in test_put_and_get()
345 disk_cache_destroy(cache); in test_put_and_get()
348 cache = disk_cache_create("test", "make_check", 0); in test_put_and_get()
350 disk_cache_put(cache, blob_key, blob, sizeof(blob), NULL); in test_put_and_get()
351 disk_cache_put(cache, string_key, string, sizeof(string), NULL); in test_put_and_get()
354 disk_cache_wait_for_idle(cache); in test_put_and_get()
357 if (does_cache_contain(cache, blob_key)) in test_put_and_get()
360 if (does_cache_contain(cache, string_key)) in test_put_and_get()
363 if (does_cache_contain(cache, one_KB_key)) in test_put_and_get()
371 disk_cache_compute_key(cache, one_MB, 1024 * 1024, one_MB_key); in test_put_and_get()
374 disk_cache_put(cache, one_MB_key, one_MB, 1024 * 1024, NULL); in test_put_and_get()
379 disk_cache_wait_for_idle(cache); in test_put_and_get()
383 if (does_cache_contain(cache, blob_key)) in test_put_and_get()
386 if (does_cache_contain(cache, string_key)) in test_put_and_get()
389 if (does_cache_contain(cache, one_KB_key)) in test_put_and_get()
392 if (does_cache_contain(cache, one_MB_key)) { in test_put_and_get()
401 disk_cache_destroy(cache); in test_put_and_get()
407 struct disk_cache *cache; in test_put_key_and_get_key() local
422 cache = disk_cache_create("test", "make_check", 0); in test_put_key_and_get_key()
425 result = disk_cache_has_key(cache, key_a); in test_put_key_and_get_key()
429 disk_cache_put_key(cache, key_a); in test_put_key_and_get_key()
430 result = disk_cache_has_key(cache, key_a); in test_put_key_and_get_key()
433 disk_cache_put_key(cache, key_b); in test_put_key_and_get_key()
434 result = disk_cache_has_key(cache, key_b); in test_put_key_and_get_key()
440 disk_cache_put_key(cache, key_a_collide); in test_put_key_and_get_key()
441 result = disk_cache_has_key(cache, key_a_collide); in test_put_key_and_get_key()
442 EXPECT_EQ(result, 1) << "put_key of a colliding key lands in the cache"; in test_put_key_and_get_key()
444 result = disk_cache_has_key(cache, key_a); in test_put_key_and_get_key()
445 EXPECT_EQ(result, 0) << "put_key of a colliding key evicts from the cache"; in test_put_key_and_get_key()
450 disk_cache_put_key(cache, key_a); in test_put_key_and_get_key()
451 result = disk_cache_has_key(cache, key_a); in test_put_key_and_get_key()
454 result = disk_cache_has_key(cache, key_a_collide); in test_put_key_and_get_key()
457 disk_cache_destroy(cache); in test_put_key_and_get_key()
460 /* To make sure we are not just using the inmemory cache index for the single
461 * file cache we test adding and retriving cache items between two different
462 * cache instances.
524 class Cache : public ::testing::Test { class
528 Cache() { in Cache() function in Cache
531 ~Cache() { in ~Cache()
536 TEST_F(Cache, MultiFile) in TEST_F() argument
552 TEST_F(Cache, SingleFile) in TEST_F() argument
561 /* We skip testing cache size limit as the single file cache currently in TEST_F()
562 * doesn't have any functionality to enforce cache size limits. in TEST_F()