From 047b59d9345076fa927b7af747b4b90da31637eb Mon Sep 17 00:00:00 2001 From: Vincent Torri Date: Tue, 18 Aug 2020 05:04:09 +0000 Subject: [PATCH] eet test: use eina_file_mkstemp, fix include for vc++ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: João Paulo Taylor Ienczak Zanette Reviewed-by: Stefan Schmidt Differential Revision: https://phab.enlightenment.org/D12108 --- src/tests/eet/eet_test_cache.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/tests/eet/eet_test_cache.c b/src/tests/eet/eet_test_cache.c index 6dee39142c..36acb414db 100644 --- a/src/tests/eet/eet_test_cache.c +++ b/src/tests/eet/eet_test_cache.c @@ -3,7 +3,11 @@ #endif #include -#include +#ifdef _WIN32 +# include /* close(), unlink() */ +#else +# include /* close(), unlink() */ +#endif #include #include @@ -46,33 +50,33 @@ _open_close_worker(void *path, Eina_Thread tid EINA_UNUSED) EFL_START_TEST(eet_test_cache_concurrency) { - char *file; const char *buffer = "test data"; Eet_File *ef; void *thread_ret; unsigned int n; Eina_Thread thread; + Eina_Tmpstr *tmpfile = NULL; Eina_Bool r; int tmpfd; - file = strdup("/tmp/eet_suite_testXXXXXX"); - eina_threads_init(); eina_lock_new(&open_worker_mutex); eina_condition_new(&open_worker_cond, &open_worker_mutex); /* create a file to test with */ - fail_if(-1 == (tmpfd = mkstemp(file))); + /* tmpfile will be created in temporary directory (with eina_environment_tmp) */ + tmpfd = eina_file_mkstemp("eet_suite_testXXXXXX", &tmpfile); + fail_if(-1 == tmpfd); fail_if(!!close(tmpfd)); - ef = eet_open(file, EET_FILE_MODE_WRITE); + ef = eet_open(tmpfile, EET_FILE_MODE_WRITE); fail_if(!ef); fail_if(!eet_write(ef, "keys/tests", buffer, strlen(buffer) + 1, 0)); eina_lock_take(&open_worker_mutex); /* start a thread that repeatedly opens and closes a file */ open_worker_stop = 0; - r = eina_thread_create(&thread, EINA_THREAD_NORMAL, -1, _open_close_worker, file); + r = eina_thread_create(&thread, EINA_THREAD_NORMAL, -1, _open_close_worker, tmpfile); fail_unless(r); eina_condition_wait(&open_worker_cond); @@ -91,9 +95,10 @@ EFL_START_TEST(eet_test_cache_concurrency) eet_close(ef); - fail_if(unlink(file) != 0); + fail_if(unlink(tmpfile) != 0); eina_threads_shutdown(); + eina_tmpstr_del(tmpfile); } EFL_END_TEST