stefan pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=047b59d9345076fa927b7af747b4b90da31637eb

commit 047b59d9345076fa927b7af747b4b90da31637eb
Author: Vincent Torri <[email protected]>
Date:   Tue Aug 18 05:04:09 2020 +0000

    eet test: use eina_file_mkstemp, fix include for vc++
    
    Reviewed-by: João Paulo Taylor Ienczak Zanette 
<[email protected]>
    Reviewed-by: Stefan Schmidt <[email protected]>
    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 <stdlib.h>
-#include <unistd.h>
+#ifdef _WIN32
+# include <io.h> /* close(), unlink() */
+#else
+# include <unistd.h> /* close(), unlink() */
+#endif
 
 #include <Eina.h>
 #include <Eet.h>
@@ -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
 

-- 


Reply via email to