diff options
author | Tapani Pälli <[email protected]> | 2018-01-30 11:42:55 +0200 |
---|---|---|
committer | Tapani Pälli <[email protected]> | 2018-02-07 14:45:34 +0200 |
commit | 83c81b6cce761ea6f202f222bde568f0bc006f3f (patch) | |
tree | 00c8fadf0697b9560bb72a6cf8567b7dbaf742e8 /src/compiler | |
parent | 6f5b57093b3462a54e9c7c6188db37e46993cee7 (diff) |
glsl/tests: move utility functions in cache_test
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 <[email protected]>
Reviewed-by: Jordan Justen <[email protected]>
Reviewed-by: Emil Velikov <[email protected]>
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/glsl/tests/cache_test.c | 70 |
1 files changed, 35 insertions, 35 deletions
diff --git a/src/compiler/glsl/tests/cache_test.c b/src/compiler/glsl/tests/cache_test.c index 75319f1160e..dd11fd5944f 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 = 100000000; + + unsigned retries = 0; + while (retries++ < 20) { + if (does_cache_contain(cache, key)) { + break; + } + + nanosleep(&req, &rem); + } +} + #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 = 100000000; - - unsigned retries = 0; - while (retries++ < 20) { - if (does_cache_contain(cache, key)) { - break; - } - - nanosleep(&req, &rem); - } -} - static void test_put_and_get(void) { |