Re: [Mesa-dev] [PATCH v2] glsl/tests: changes to test_disk_cache_create test

2018-02-05 Thread Emil Velikov
On 5 February 2018 at 07:02, Tapani Pälli  wrote:
> Next patch will allow disk_cache instance to be created without
> path set for it, modify some test cases that assume disk_cache
> creation to fail with invalid path. Creation should succeed but
> simple put/get test fail.
>
> v2: leave tests as is but check that both cache struct exists
> and try simple put/get that should fail with invalid path set
> (Emil)
>
Perfect, thank you.

Ideally (but optional) with an assert in 5/7 the whole series is
Reviewed-by: Emil Velikov 

-Emil
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH v2] glsl/tests: changes to test_disk_cache_create test

2018-02-04 Thread Tapani Pälli
Next patch will allow disk_cache instance to be created without
path set for it, modify some test cases that assume disk_cache
creation to fail with invalid path. Creation should succeed but
simple put/get test fail.

v2: leave tests as is but check that both cache struct exists
and try simple put/get that should fail with invalid path set
(Emil)

Signed-off-by: Tapani Pälli 
Reviewed-by: Jordan Justen  (v1)
---
 src/compiler/glsl/tests/cache_test.c | 28 ++--
 1 file changed, 22 insertions(+), 6 deletions(-)

diff --git a/src/compiler/glsl/tests/cache_test.c 
b/src/compiler/glsl/tests/cache_test.c
index dd11fd5944..3edd88b06a 100644
--- a/src/compiler/glsl/tests/cache_test.c
+++ b/src/compiler/glsl/tests/cache_test.c
@@ -182,6 +182,20 @@ wait_until_file_written(struct disk_cache *cache, const 
cache_key key)
}
 }
 
+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
@@ -213,12 +227,13 @@ test_disk_cache_create(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);
@@ -231,12 +246,13 @@ test_disk_cache_create(void)
 
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);
-- 
2.14.3

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev