16
#include "eet_test_common.h"
18
static Eina_Bool open_worker_stop;
19
static Eina_Condition open_worker_cond;
20
static Eina_Lock open_worker_mutex;
23
_open_close_worker(void *path, Eina_Thread tid EINA_UNUSED)
25
static Eina_Bool first = EINA_TRUE;
27
while (!open_worker_stop)
29
Eet_File *ef = eet_open((char const *)path, EET_FILE_MODE_READ);
31
return "eet_open() failed";
34
Eet_Error err_code = eet_close(ef);
35
if (err_code != EET_ERROR_NONE)
36
return "eet_close() failed";
41
eina_lock_take(&open_worker_mutex);
42
eina_condition_broadcast(&open_worker_cond);
43
eina_lock_release(&open_worker_mutex);
51
EFL_START_TEST(eet_test_cache_concurrency)
53
const char *buffer = "test data";
58
Eina_Tmpstr *tmpfile = NULL;
64
eina_lock_new(&open_worker_mutex);
65
eina_condition_new(&open_worker_cond, &open_worker_mutex);
69
tmpfd = eina_file_mkstemp("eet_suite_testXXXXXX", &tmpfile);
71
fail_if(!!close(tmpfd));
72
ef = eet_open(tmpfile, EET_FILE_MODE_WRITE);
74
fail_if(!eet_write(ef, "keys/tests", buffer, strlen(buffer) + 1, 0));
76
eina_lock_take(&open_worker_mutex);
79
r = eina_thread_create(&thread, EINA_THREAD_NORMAL, -1, _open_close_worker, tmpfile);
82
eina_condition_wait(&open_worker_cond);
83
eina_lock_release(&open_worker_mutex);
86
for (n = 0; n < 20000; ++n)
93
thread_ret = eina_thread_join(thread);
94
fail_unless(thread_ret == NULL, (char const *)thread_ret);
98
fail_if(unlink(tmpfile) != 0);
100
eina_threads_shutdown();
101
eina_tmpstr_del(tmpfile);
105
void eet_test_cache(TCase *tc)
107
tcase_add_test(tc, eet_test_cache_concurrency);