}
}
+static void *
+cache_exists(struct disk_cache *cache)
+{
+ uint8_t dummy_key[20];
+ char *data = "some test data";
+
+ if (!cache)
+ return NULL;
+
+ disk_cache_put(cache, dummy_key, data, sizeof(data), NULL);
+ wait_until_file_written(cache, dummy_key);
+ return disk_cache_get(cache, dummy_key, NULL);
+}
+
#define CACHE_TEST_TMP "./cache-test-tmp"
static void
/* Test with XDG_CACHE_HOME set */
setenv("XDG_CACHE_HOME", CACHE_TEST_TMP "/xdg-cache-home", 1);
cache = disk_cache_create("test", "make_check", 0);
- expect_null(cache, "disk_cache_create with XDG_CACHE_HOME set with"
- "a non-existing parent directory");
+ expect_null(cache_exists(cache), "disk_cache_create with XDG_CACHE_HOME set "
+ "with a non-existing parent directory");
mkdir(CACHE_TEST_TMP, 0755);
cache = disk_cache_create("test", "make_check", 0);
- expect_non_null(cache, "disk_cache_create with XDG_CACHE_HOME set");
+ expect_non_null(cache_exists(cache), "disk_cache_create with XDG_CACHE_HOME "
+ "set");
check_directories_created(CACHE_TEST_TMP "/xdg-cache-home/"
CACHE_DIR_NAME);
setenv("MESA_GLSL_CACHE_DIR", CACHE_TEST_TMP "/mesa-glsl-cache-dir", 1);
cache = disk_cache_create("test", "make_check", 0);
- expect_null(cache, "disk_cache_create with MESA_GLSL_CACHE_DIR set with"
- "a non-existing parent directory");
+ expect_null(cache_exists(cache), "disk_cache_create with MESA_GLSL_CACHE_DIR"
+ " set with a non-existing parent directory");
mkdir(CACHE_TEST_TMP, 0755);
cache = disk_cache_create("test", "make_check", 0);
- expect_non_null(cache, "disk_cache_create with MESA_GLSL_CACHE_DIR set");
+ expect_non_null(cache_exists(cache), "disk_cache_create with "
+ "MESA_GLSL_CACHE_DIR set");
check_directories_created(CACHE_TEST_TMP "/mesa-glsl-cache-dir/"
CACHE_DIR_NAME);