Re: [Mesa-dev] [PATCH 3/7] glsl/tests: move utility functions in cache_test

2018-01-31 Thread Emil Velikov
On 31 January 2018 at 07:17, Tapani Pälli  wrote:
> Patch moves functions higher so that we can utilize them from
> test_disk_cache_create which is modified by next patch.
>
> Signed-off-by: Tapani Pälli 
> ---
I realise you're just moving stuff, so feel free to ignore the nits.

>  src/compiler/glsl/tests/cache_test.c | 70 
> ++--
>  1 file changed, 35 insertions(+), 35 deletions(-)
>
> diff --git a/src/compiler/glsl/tests/cache_test.c 
> b/src/compiler/glsl/tests/cache_test.c
> index 75319f1160..dd11fd5944 100644
> --- a/src/compiler/glsl/tests/cache_test.c
> +++ b/src/compiler/glsl/tests/cache_test.c
> @@ -147,6 +147,41 @@ check_directories_created(const char *cache_dir)
> expect_true(sub_dirs_created, "create sub dirs");
>  }
>
> +static bool
> +does_cache_contain(struct disk_cache *cache, const cache_key key)
> +{
> +   void *result;
> +
> +   result = disk_cache_get(cache, key, NULL);
> +
> +   if (result) {
> +  free(result);
> +  return true;
> +   }
> +
> +   return false;
> +}
Nit:

void *result = disk_cache_get(cache, key, NULL);

if (!result)
   return false;

free(result);

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


[Mesa-dev] [PATCH 3/7] glsl/tests: move utility functions in cache_test

2018-01-30 Thread Tapani Pälli
Patch moves functions higher so that we can utilize them from
test_disk_cache_create which is modified by next patch.

Signed-off-by: Tapani Pälli 
---
 src/compiler/glsl/tests/cache_test.c | 70 ++--
 1 file changed, 35 insertions(+), 35 deletions(-)

diff --git a/src/compiler/glsl/tests/cache_test.c 
b/src/compiler/glsl/tests/cache_test.c
index 75319f1160..dd11fd5944 100644
--- a/src/compiler/glsl/tests/cache_test.c
+++ b/src/compiler/glsl/tests/cache_test.c
@@ -147,6 +147,41 @@ check_directories_created(const char *cache_dir)
expect_true(sub_dirs_created, "create sub dirs");
 }
 
+static bool
+does_cache_contain(struct disk_cache *cache, const cache_key key)
+{
+   void *result;
+
+   result = disk_cache_get(cache, key, NULL);
+
+   if (result) {
+  free(result);
+  return true;
+   }
+
+   return false;
+}
+
+static void
+wait_until_file_written(struct disk_cache *cache, const cache_key key)
+{
+   struct timespec req;
+   struct timespec rem;
+
+   /* Set 100ms delay */
+   req.tv_sec = 0;
+   req.tv_nsec = 1;
+
+   unsigned retries = 0;
+   while (retries++ < 20) {
+  if (does_cache_contain(cache, key)) {
+ break;
+  }
+
+  nanosleep(, );
+   }
+}
+
 #define CACHE_TEST_TMP "./cache-test-tmp"
 
 static void
@@ -209,41 +244,6 @@ test_disk_cache_create(void)
disk_cache_destroy(cache);
 }
 
-static bool
-does_cache_contain(struct disk_cache *cache, const cache_key key)
-{
-   void *result;
-
-   result = disk_cache_get(cache, key, NULL);
-
-   if (result) {
-  free(result);
-  return true;
-   }
-
-   return false;
-}
-
-static void
-wait_until_file_written(struct disk_cache *cache, const cache_key key)
-{
-   struct timespec req;
-   struct timespec rem;
-
-   /* Set 100ms delay */
-   req.tv_sec = 0;
-   req.tv_nsec = 1;
-
-   unsigned retries = 0;
-   while (retries++ < 20) {
-  if (does_cache_contain(cache, key)) {
- break;
-  }
-
-  nanosleep(, );
-   }
-}
-
 static void
 test_put_and_get(void)
 {
-- 
2.13.6

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