• Home
  • Raw
  • Download

Lines Matching +full:cache +full:- +full:to

4  * Permission is hereby granted, free of charge, to any person obtaining a
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24 /* A collection of unit tests for cache.c */
41 #include "util/mesa-sha1.h"
66 * This is equivalent to "rm -rf <dir>" with one bit of protection
67 * that the directory name must begin with "." to ensure we don't
70 * Returns 0 on success, -1 on any error.
76 return -1; in rmrf_local()
90 if (stat(full_path, &sb) != -1 && S_ISDIR(sb.st_mode)) in check_directories_created()
98 does_cache_contain(struct disk_cache *cache, const cache_key key) in does_cache_contain() argument
102 result = disk_cache_get(cache, key, NULL); in does_cache_contain()
113 cache_exists(struct disk_cache *cache) in cache_exists() argument
118 if (!cache) in cache_exists()
121 disk_cache_compute_key(cache, data, sizeof(data), key); in cache_exists()
122 disk_cache_put(cache, key, data, sizeof(data), NULL); in cache_exists()
123 disk_cache_wait_for_idle(cache); in cache_exists()
124 void *result = disk_cache_get(cache, key, NULL); in cache_exists()
125 disk_cache_remove(cache, key); in cache_exists()
132 poll_disk_cache_get(struct disk_cache *cache, in poll_disk_cache_get() argument
139 result = disk_cache_get(cache, key, size); in poll_disk_cache_get()
149 #define CACHE_TEST_TMP "./cache-test-tmp"
155 struct disk_cache *cache; in test_disk_cache_create() local
159 * MESA_SHADER_CACHE_DISABLE set to true, that disk_cache_create returns NO-OP cache. in test_disk_cache_create()
162 cache = disk_cache_create("test", driver_id, 0); in test_disk_cache_create()
163 … EXPECT_EQ(cache->type, DISK_CACHE_NONE) << "disk_cache_create with MESA_SHADER_CACHE_DISABLE set"; in test_disk_cache_create()
164 disk_cache_destroy(cache); in test_disk_cache_create()
170 * MESA_SHADER_CACHE_DISABLE set to nothing, disk_cache_create returns NO-OP cache. in test_disk_cache_create()
173 cache = disk_cache_create("test", driver_id, 0); in test_disk_cache_create()
174 EXPECT_EQ(cache->type, DISK_CACHE_NONE) in test_disk_cache_create()
177 disk_cache_destroy(cache); in test_disk_cache_create()
179 /* For remaining tests, ensure that the cache is enabled. */ in test_disk_cache_create()
184 * variables to test creation of cache in home directory. in test_disk_cache_create()
189 cache = disk_cache_create("test", driver_id, 0); in test_disk_cache_create()
190 EXPECT_NE(cache, nullptr) << "disk_cache_create with no environment variables"; in test_disk_cache_create()
192 disk_cache_destroy(cache); in test_disk_cache_create()
195 /* Android doesn't try writing to disk (just calls the cache callbacks), so in test_disk_cache_create()
202 setenv("XDG_CACHE_HOME", CACHE_TEST_TMP "/xdg-cache-home", 1); in test_disk_cache_create()
203 cache = disk_cache_create("test", driver_id, 0); in test_disk_cache_create()
204 EXPECT_FALSE(cache_exists(cache)) in test_disk_cache_create()
205 << "disk_cache_create with XDG_CACHE_HOME set with a non-existing parent directory"; in test_disk_cache_create()
212 disk_cache_destroy(cache); in test_disk_cache_create()
214 cache = disk_cache_create("test", driver_id, 0); in test_disk_cache_create()
215 EXPECT_TRUE(cache_exists(cache)) in test_disk_cache_create()
219 mem_ctx, "%s%s", CACHE_TEST_TMP "/xdg-cache-home/", cache_dir_name); in test_disk_cache_create()
222 disk_cache_destroy(cache); in test_disk_cache_create()
228 setenv("MESA_SHADER_CACHE_DIR", CACHE_TEST_TMP "/mesa-shader-cache-dir", 1); in test_disk_cache_create()
229 cache = disk_cache_create("test", driver_id, 0); in test_disk_cache_create()
230 EXPECT_TRUE(cache_exists(cache)) in test_disk_cache_create()
231 << "disk_cache_create with MESA_SHADER_CACHE_DIR set with a non-existing parent directory"; in test_disk_cache_create()
233 disk_cache_destroy(cache); in test_disk_cache_create()
243 cache = disk_cache_create("test", driver_id, 0); in test_disk_cache_create()
244 …EXPECT_TRUE(cache_exists(cache)) << "disk_cache_create with MESA_SHADER_CACHE_DIR set with existin… in test_disk_cache_create()
247 mem_ctx, "%s%s", CACHE_TEST_TMP "/mesa-shader-cache-dir/", cache_dir_name); in test_disk_cache_create()
250 disk_cache_destroy(cache); in test_disk_cache_create()
256 struct disk_cache *cache; in test_put_and_get() local
257 char blob[] = "This is a blob of thirty-seven bytes"; in test_put_and_get()
259 char string[] = "While this string has thirty-four"; in test_put_and_get()
271 cache = disk_cache_create("test", driver_id, 0); in test_put_and_get()
273 disk_cache_compute_key(cache, blob, sizeof(blob), blob_key); in test_put_and_get()
276 result = (char *) disk_cache_get(cache, blob_key, &size); in test_put_and_get()
277 EXPECT_EQ(result, nullptr) << "disk_cache_get with non-existent item (pointer)"; in test_put_and_get()
278 EXPECT_EQ(size, 0) << "disk_cache_get with non-existent item (size)"; in test_put_and_get()
281 disk_cache_put(cache, blob_key, blob, sizeof(blob), NULL); in test_put_and_get()
283 /* disk_cache_put() hands things off to a thread so wait for it. */ in test_put_and_get()
284 disk_cache_wait_for_idle(cache); in test_put_and_get()
286 result = (char *) disk_cache_get(cache, blob_key, &size); in test_put_and_get()
293 disk_cache_compute_key(cache, string, sizeof(string), string_key); in test_put_and_get()
294 disk_cache_put(cache, string_key, string, sizeof(string), NULL); in test_put_and_get()
296 /* disk_cache_put() hands things off to a thread so wait for it. */ in test_put_and_get()
297 disk_cache_wait_for_idle(cache); in test_put_and_get()
299 result = (char *) disk_cache_get(cache, string_key, &size); in test_put_and_get()
305 /* Set the cache size to 1KB and add a 1KB item to force an eviction. */ in test_put_and_get()
306 disk_cache_destroy(cache); in test_put_and_get()
312 cache = disk_cache_create("test", driver_id, 0); in test_put_and_get()
316 /* Obviously the SHA-1 hash of 1024 zero bytes isn't particularly in test_put_and_get()
317 * interesting. But we do have want to take some special care with in test_put_and_get()
319 * (with only three files in the cache), the probability is good in test_put_and_get()
327 * implemented, (which expects to only evict once things are more in test_put_and_get()
330 * For this test, we force this signature to land in the same in test_put_and_get()
331 * directory as the original blob first written to the cache. in test_put_and_get()
333 disk_cache_compute_key(cache, one_KB, 1024, one_KB_key); in test_put_and_get()
336 disk_cache_put(cache, one_KB_key, one_KB, 1024, NULL); in test_put_and_get()
340 /* disk_cache_put() hands things off to a thread so wait for it. */ in test_put_and_get()
341 disk_cache_wait_for_idle(cache); in test_put_and_get()
343 result = (char *) disk_cache_get(cache, one_KB_key, &size); in test_put_and_get()
350 * cache itesm were evicted. in test_put_and_get()
354 if (does_cache_contain(cache, blob_key)) in test_put_and_get()
357 if (does_cache_contain(cache, string_key)) in test_put_and_get()
360 if (does_cache_contain(cache, one_KB_key)) { in test_put_and_get()
369 /* Now increase the size to 1M, add back both items, and ensure all in test_put_and_get()
372 disk_cache_destroy(cache); in test_put_and_get()
375 cache = disk_cache_create("test", driver_id, 0); in test_put_and_get()
377 disk_cache_put(cache, blob_key, blob, sizeof(blob), NULL); in test_put_and_get()
378 disk_cache_put(cache, string_key, string, sizeof(string), NULL); in test_put_and_get()
380 /* disk_cache_put() hands things off to a thread so wait for it. */ in test_put_and_get()
381 disk_cache_wait_for_idle(cache); in test_put_and_get()
384 if (does_cache_contain(cache, blob_key)) in test_put_and_get()
387 if (does_cache_contain(cache, string_key)) in test_put_and_get()
390 if (does_cache_contain(cache, one_KB_key)) in test_put_and_get()
398 disk_cache_compute_key(cache, one_MB, 1024 * 1024, one_MB_key); in test_put_and_get()
401 disk_cache_put(cache, one_MB_key, one_MB, 1024 * 1024, NULL); in test_put_and_get()
405 /* disk_cache_put() hands things off to a thread so wait for it. */ in test_put_and_get()
406 disk_cache_wait_for_idle(cache); in test_put_and_get()
410 if (does_cache_contain(cache, blob_key)) in test_put_and_get()
413 if (does_cache_contain(cache, string_key)) in test_put_and_get()
416 if (does_cache_contain(cache, one_KB_key)) in test_put_and_get()
419 if (does_cache_contain(cache, one_MB_key)) { in test_put_and_get()
428 disk_cache_destroy(cache); in test_put_and_get()
434 struct disk_cache *cache; in test_put_key_and_get_key() local
449 cache = disk_cache_create("test", driver_id, 0); in test_put_key_and_get_key()
452 result = disk_cache_has_key(cache, key_a); in test_put_key_and_get_key()
456 disk_cache_put_key(cache, key_a); in test_put_key_and_get_key()
457 result = disk_cache_has_key(cache, key_a); in test_put_key_and_get_key()
460 disk_cache_put_key(cache, key_b); in test_put_key_and_get_key()
461 result = disk_cache_has_key(cache, key_b); in test_put_key_and_get_key()
467 disk_cache_put_key(cache, key_a_collide); in test_put_key_and_get_key()
468 result = disk_cache_has_key(cache, key_a_collide); in test_put_key_and_get_key()
469 EXPECT_EQ(result, 1) << "put_key of a colliding key lands in the cache"; in test_put_key_and_get_key()
471 result = disk_cache_has_key(cache, key_a); in test_put_key_and_get_key()
472 EXPECT_EQ(result, 0) << "put_key of a colliding key evicts from the cache"; in test_put_key_and_get_key()
474 /* And finally test that we can re-add the original key to re-evict in test_put_key_and_get_key()
477 disk_cache_put_key(cache, key_a); in test_put_key_and_get_key()
478 result = disk_cache_has_key(cache, key_a); in test_put_key_and_get_key()
481 result = disk_cache_has_key(cache, key_a_collide); in test_put_key_and_get_key()
484 disk_cache_destroy(cache); in test_put_key_and_get_key()
487 /* To make sure we are not just using the inmemory cache index for the single
488 * file cache we test adding and retriving cache items between two different
489 * cache instances.
494 char blob[] = "This is a blob of thirty-seven bytes"; in test_put_and_get_between_instances()
496 char string[] = "While this string has thirty-four"; in test_put_and_get_between_instances()
514 EXPECT_EQ(result, nullptr) << "disk_cache_get(cache1) with non-existent item (pointer)"; in test_put_and_get_between_instances()
515 EXPECT_EQ(size, 0) << "disk_cache_get(cach1) with non-existent item (size)"; in test_put_and_get_between_instances()
518 EXPECT_EQ(result, nullptr) << "disk_cache_get(cache2) with non-existent item (pointer)"; in test_put_and_get_between_instances()
519 EXPECT_EQ(size, 0) << "disk_cache_get(cache2) with non-existent item (size)"; in test_put_and_get_between_instances()
524 /* disk_cache_put() hands things off to a thread so wait for it. */ in test_put_and_get_between_instances()
537 /* disk_cache_put() hands things off to a thread so wait for it. */ in test_put_and_get_between_instances()
554 struct disk_cache *cache[2]; in test_put_and_get_between_instances_with_eviction() local
567 cache[0] = disk_cache_create("test_between_instances_with_eviction", driver_id, 0); in test_put_and_get_between_instances_with_eviction()
568 cache[1] = disk_cache_create("test_between_instances_with_eviction", driver_id, 0); in test_put_and_get_between_instances_with_eviction()
574 disk_cache_put(cache[0], two_KB_key, two_KB, sizeof(two_KB), NULL); in test_put_and_get_between_instances_with_eviction()
575 disk_cache_wait_for_idle(cache[0]); in test_put_and_get_between_instances_with_eviction()
578 size_big -= sizeof(struct cache_entry_file_data); in test_put_and_get_between_instances_with_eviction()
579 size_big -= mesa_cache_db_file_entry_size(); in test_put_and_get_between_instances_with_eviction()
580 size_big -= cache[0]->driver_keys_blob_size; in test_put_and_get_between_instances_with_eviction()
581 size_big -= 4 + 8; /* cache_item_metadata size + room for alignment */ in test_put_and_get_between_instances_with_eviction()
587 disk_cache_compute_key(cache[0], big, size_big, big_key[i]); in test_put_and_get_between_instances_with_eviction()
588 disk_cache_put(cache[0], big_key[i], big, size_big, NULL); in test_put_and_get_between_instances_with_eviction()
589 disk_cache_wait_for_idle(cache[0]); in test_put_and_get_between_instances_with_eviction()
591 result = (char *) disk_cache_get(cache[0], big_key[i], &size); in test_put_and_get_between_instances_with_eviction()
600 size_small -= sizeof(struct cache_entry_file_data); in test_put_and_get_between_instances_with_eviction()
601 size_small -= mesa_cache_db_file_entry_size(); in test_put_and_get_between_instances_with_eviction()
602 size_small -= cache[1]->driver_keys_blob_size; in test_put_and_get_between_instances_with_eviction()
603 size_small -= 4 + 8; /* cache_item_metadata size + room for alignment */ in test_put_and_get_between_instances_with_eviction()
609 disk_cache_compute_key(cache[1], small, size_small, small_key[i]); in test_put_and_get_between_instances_with_eviction()
610 disk_cache_put(cache[1], small_key[i], small, size_small, NULL); in test_put_and_get_between_instances_with_eviction()
611 disk_cache_wait_for_idle(cache[1]); in test_put_and_get_between_instances_with_eviction()
614 * At first we added two 1000KB entries to cache[0]. Now, when first in test_put_and_get_between_instances_with_eviction()
618 * All four 256KB entries stay in the cache. in test_put_and_get_between_instances_with_eviction()
620 for (k = 0; k < ARRAY_SIZE(cache); k++) { in test_put_and_get_between_instances_with_eviction()
622 result = (char *) disk_cache_get(cache[k], big_key[0], &size); in test_put_and_get_between_instances_with_eviction()
623 EXPECT_EQ(result, nullptr) << "disk_cache_get with non-existent item (pointer)"; in test_put_and_get_between_instances_with_eviction()
624 EXPECT_EQ(size, 0) << "disk_cache_get with non-existent item (size)"; in test_put_and_get_between_instances_with_eviction()
627 result = (char *) disk_cache_get(cache[k], big_key[1], &size); in test_put_and_get_between_instances_with_eviction()
628 EXPECT_EQ(result, nullptr) << "disk_cache_get with non-existent item (pointer)"; in test_put_and_get_between_instances_with_eviction()
629 EXPECT_EQ(size, 0) << "disk_cache_get with non-existent item (size)"; in test_put_and_get_between_instances_with_eviction()
632 result = (char *) disk_cache_get(cache[k], small_key[n], &size); in test_put_and_get_between_instances_with_eviction()
637 result = (char *) disk_cache_get(cache[k], small_key[n], &size); in test_put_and_get_between_instances_with_eviction()
652 disk_cache_compute_key(cache[0], small, size_small, small_key2); in test_put_and_get_between_instances_with_eviction()
653 disk_cache_put(cache[0], small_key2, small, size_small, NULL); in test_put_and_get_between_instances_with_eviction()
654 disk_cache_wait_for_idle(cache[0]); in test_put_and_get_between_instances_with_eviction()
658 for (k = 0; k < ARRAY_SIZE(cache); k++) { in test_put_and_get_between_instances_with_eviction()
659 result = (char *) disk_cache_get(cache[k], small_key2, &size); in test_put_and_get_between_instances_with_eviction()
665 for (i = 0, k = 0; k < ARRAY_SIZE(cache); k++) { in test_put_and_get_between_instances_with_eviction()
667 result = (char *) disk_cache_get(cache[k], small_key[n], &size); in test_put_and_get_between_instances_with_eviction()
674 EXPECT_EQ(i, 10) << "2x disk_cache_get with 5 non-existent 256KB items"; in test_put_and_get_between_instances_with_eviction()
676 disk_cache_destroy(cache[0]); in test_put_and_get_between_instances_with_eviction()
677 disk_cache_destroy(cache[1]); in test_put_and_get_between_instances_with_eviction()
681 class Cache : public ::testing::Test { class
685 Cache() { in Cache() function in Cache
688 ~Cache() { in ~Cache()
693 TEST_F(Cache, MultiFile) in TEST_F() argument
724 TEST_F(Cache, SingleFile) in TEST_F() argument
743 /* We skip testing cache size limit as the single file cache currently in TEST_F()
744 * doesn't have any functionality to enforce cache size limits. in TEST_F()
764 TEST_F(Cache, Database) in TEST_F() argument
776 /* We skip testing cache size limit as the single file cache compresses in TEST_F()
777 * data much better than the multi-file cache, which results in the in TEST_F()
778 * failing tests of the cache eviction function. We we will test the in TEST_F()
804 TEST_F(Cache, Combined) in TEST_F() argument
829 /* Enable Fossilize read-write cache. */ in TEST_F()
834 /* Create Fossilize writable cache. */ in TEST_F()
843 EXPECT_EQ(result, nullptr) << "disk_cache_get with non-existent item (pointer)"; in TEST_F()
844 EXPECT_EQ(size, 0) << "disk_cache_get with non-existent item (size)"; in TEST_F()
846 /* Put blob entry to the cache. */ in TEST_F()
855 /* Rename file foz_cache.foz -> ro_cache.foz */ in TEST_F()
856 sprintf(foz_rw_file, "%s/foz_cache.foz", cache_sf_wr->path); in TEST_F()
857 sprintf(foz_ro_file, "%s/ro_cache.foz", cache_sf_wr->path); in TEST_F()
860 /* Rename file foz_cache_idx.foz -> ro_cache_idx.foz */ in TEST_F()
861 sprintf(foz_rw_idx_file, "%s/foz_cache_idx.foz", cache_sf_wr->path); in TEST_F()
862 sprintf(foz_ro_idx_file, "%s/ro_cache_idx.foz", cache_sf_wr->path); in TEST_F()
867 /* Disable Fossilize read-write cache. */ in TEST_F()
870 /* Set up Fossilize read-only cache. */ in TEST_F()
874 /* Create FOZ cache that fetches the RO cache. Note that this produces in TEST_F()
875 * empty RW cache files. */ in TEST_F()
888 /* Remove empty FOZ RW cache files created above. We only need RO cache. */ in TEST_F()
895 /* Create MESA-DB cache with enabled retrieval from the read-only in TEST_F()
896 * cache. */ in TEST_F()
900 /* Dummy entry must not present in any of the caches. Foz cache in TEST_F()
901 * reloads index if cache entry is missing. This is a sanity-check in TEST_F()
903 * FOZ RW cache. */ in TEST_F()
905 EXPECT_EQ(result, nullptr) << "disk_cache_get with non-existent item (pointer)"; in TEST_F()
906 EXPECT_EQ(size, 0) << "disk_cache_get with non-existent item (size)"; in TEST_F()
909 * read-only cache. */ in TEST_F()
917 EXPECT_EQ(result, nullptr) << "disk_cache_get with non-existent item (pointer)"; in TEST_F()
918 EXPECT_EQ(size, 0) << "disk_cache_get with non-existent item (size)"; in TEST_F()
920 /* Put blob2 entry to the cache. */ in TEST_F()
925 * read-write cache. */ in TEST_F()
933 /* Disable read-only cache. */ in TEST_F()
936 /* Create MESA-DB cache with disabled retrieval from the in TEST_F()
937 * read-only cache. */ in TEST_F()
941 * MESA-DB cache. */ in TEST_F()
949 /* Create MESA-DB cache with disabled retrieval from the read-only in TEST_F()
950 * cache. */ in TEST_F()
953 /* Blob entry must not present in the cache because we disable the in TEST_F()
954 * read-only cache. */ in TEST_F()
956 EXPECT_EQ(result, nullptr) << "disk_cache_get with non-existent item (pointer)"; in TEST_F()
957 EXPECT_EQ(size, 0) << "disk_cache_get with non-existent item (size)"; in TEST_F()
961 /* Create default multi-file cache. */ in TEST_F()
964 /* Enable read-only cache. */ in TEST_F()
967 /* Create multi-file cache with enabled retrieval from the in TEST_F()
968 * read-only cache. */ in TEST_F()
973 * read-only cache. */ in TEST_F()
981 EXPECT_EQ(result, nullptr) << "disk_cache_get with non-existent item (pointer)"; in TEST_F()
982 EXPECT_EQ(size, 0) << "disk_cache_get with non-existent item (size)"; in TEST_F()
984 /* Put blob2 entry to the cache. */ in TEST_F()
989 * read-write cache. */ in TEST_F()
997 /* Disable read-only cache. */ in TEST_F()
1001 /* Create multi-file cache with disabled retrieval from the in TEST_F()
1002 * read-only cache. */ in TEST_F()
1005 /* Blob entry must not present in the cache because we disabled the in TEST_F()
1006 * read-only cache. */ in TEST_F()
1008 EXPECT_EQ(result, nullptr) << "disk_cache_get with non-existent item (pointer)"; in TEST_F()
1009 EXPECT_EQ(size, 0) << "disk_cache_get with non-existent item (size)"; in TEST_F()
1012 * read-write cache. */ in TEST_F()
1025 TEST_F(Cache, DISABLED_List) in TEST_F() argument
1052 /* Create Fossilize writable cache. */ in TEST_F()
1061 << "disk_cache_get with non-existent item (pointer)"; in TEST_F()
1062 EXPECT_EQ(size, 0) << "disk_cache_get with non-existent item (size)"; in TEST_F()
1064 /* Put blob entry to the cache. */ in TEST_F()
1073 /* Rename file foz_cache.foz -> ro_cache.foz */ in TEST_F()
1074 sprintf(foz_rw_file, "%s/foz_cache.foz", cache_sf_wr->path); in TEST_F()
1075 sprintf(foz_ro_file, "%s/ro_cache.foz", cache_sf_wr->path); in TEST_F()
1079 /* Rename file foz_cache_idx.foz -> ro_cache_idx.foz */ in TEST_F()
1080 sprintf(foz_rw_idx_file, "%s/foz_cache_idx.foz", cache_sf_wr->path); in TEST_F()
1081 sprintf(foz_ro_idx_file, "%s/ro_cache_idx.foz", cache_sf_wr->path); in TEST_F()
1095 /* Create Fossilize writable cache. */ in TEST_F()
1113 /* Create Fossilize writable cache. */ in TEST_F()
1119 << "disk_cache_get with non-existent item (pointer)"; in TEST_F()
1120 EXPECT_EQ(size, 0) << "disk_cache_get with non-existent item (size)"; in TEST_F()
1122 /* Add ro_cache to list file for loading */ in TEST_F()
1127 /* Poll result to give time for updater to load ro cache */ in TEST_F()
1144 /* Create Fossilize writable cache. */ in TEST_F()
1150 << "disk_cache_get with non-existent item (pointer)"; in TEST_F()
1151 EXPECT_EQ(size, 0) << "disk_cache_get with non-existent item (size)"; in TEST_F()
1153 /* Add non-existant list files for loading */ in TEST_F()
1158 /* Add ro_cache to list file for loading */ in TEST_F()
1162 /* Poll result to give time for updater to load ro cache */ in TEST_F()
1197 struct disk_cache *cache = disk_cache_create("test", driver_id, 0); in test_multipart_eviction() local
1200 entry_file_size -= sizeof(struct cache_entry_file_data); in test_multipart_eviction()
1201 entry_file_size -= mesa_cache_db_file_entry_size(); in test_multipart_eviction()
1202 entry_file_size -= cache->driver_keys_blob_size; in test_multipart_eviction()
1203 entry_file_size -= 4 + 8; /* cache_item_metadata size + room for alignment */ in test_multipart_eviction()
1206 * 1. Allocate 3KB cache in 3 parts, each part is 1KB in test_multipart_eviction()
1207 * 2. Fill up cache with six 512K entries in test_multipart_eviction()
1209 * of the first two cache entries in test_multipart_eviction()
1211 * 5. Check that second entry of the second part gone due to eviction and in test_multipart_eviction()
1215 /* Fill up cache with six 512K entries. */ in test_multipart_eviction()
1219 disk_cache_compute_key(cache, blobs[i], entry_file_size, keys[i]); in test_multipart_eviction()
1220 disk_cache_put(cache, keys[i], blobs[i], entry_file_size, NULL); in test_multipart_eviction()
1221 disk_cache_wait_for_idle(cache); in test_multipart_eviction()
1223 result = (char *) disk_cache_get(cache, keys[i], &size); in test_multipart_eviction()
1228 /* Ensure that cache entries will have distinct last_access_time in test_multipart_eviction()
1237 result = (char *) disk_cache_get(cache, keys[i], &size); in test_multipart_eviction()
1245 disk_cache_compute_key(cache, blobs[6], entry_file_size, keys[6]); in test_multipart_eviction()
1246 disk_cache_put(cache, keys[6], blobs[6], entry_file_size, NULL); in test_multipart_eviction()
1247 disk_cache_wait_for_idle(cache); in test_multipart_eviction()
1251 result = (char *) disk_cache_get(cache, keys[i], &size); in test_multipart_eviction()
1253 EXPECT_EQ(result, nullptr) << "disk_cache_get with non-existent item (pointer)"; in test_multipart_eviction()
1261 disk_cache_destroy(cache); in test_multipart_eviction()
1264 TEST_F(Cache, DatabaseMultipartEviction) in TEST_F() argument
1289 struct disk_cache *cache; in test_put_and_get_disabled() local
1290 char blob[] = "This is a blob of thirty-seven bytes"; in test_put_and_get_disabled()
1295 cache = disk_cache_create("test", driver_id, 0); in test_put_and_get_disabled()
1297 disk_cache_compute_key(cache, blob, sizeof(blob), blob_key); in test_put_and_get_disabled()
1300 result = (char *) disk_cache_get(cache, blob_key, &size); in test_put_and_get_disabled()
1301 EXPECT_EQ(result, nullptr) << "disk_cache_get with non-existent item (pointer)"; in test_put_and_get_disabled()
1302 EXPECT_EQ(size, 0) << "disk_cache_get with non-existent item (size)"; in test_put_and_get_disabled()
1305 disk_cache_put(cache, blob_key, blob, sizeof(blob), NULL); in test_put_and_get_disabled()
1307 /* disk_cache_put() hands things off to a thread so wait for it. */ in test_put_and_get_disabled()
1308 disk_cache_wait_for_idle(cache); in test_put_and_get_disabled()
1310 result = (char *) disk_cache_get(cache, blob_key, &size); in test_put_and_get_disabled()
1314 disk_cache_destroy(cache); in test_put_and_get_disabled()
1317 TEST_F(Cache, Disabled) in TEST_F() argument