summaryrefslogtreecommitdiff
path: root/src/tests/eet/eet_suite.c
diff options
context:
space:
mode:
authorCedric Bail <cedric.bail@samsung.com>2013-07-02 13:45:30 +0900
committerCedric Bail <cedric.bail@samsung.com>2013-07-02 13:45:30 +0900
commit2fdc05863d1d2b97890005157d44f09db4e82bc4 (patch)
tree74b497c2ede33af110401243f01b75fc35b23ae8 /src/tests/eet/eet_suite.c
parentb6aaef651b2ade983a5ecac22bce0c57273d1f9a (diff)
eet: force thread to always run during eet_cache_concurrency test.
Diffstat (limited to '')
-rw-r--r--src/tests/eet/eet_suite.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/tests/eet/eet_suite.c b/src/tests/eet/eet_suite.c
index dec16ed492..5067208ec5 100644
--- a/src/tests/eet/eet_suite.c
+++ b/src/tests/eet/eet_suite.c
@@ -1843,10 +1843,14 @@ START_TEST(eet_cipher_decipher_simple)
1843END_TEST 1843END_TEST
1844 1844
1845static Eina_Bool open_worker_stop; 1845static Eina_Bool open_worker_stop;
1846static Eina_Condition open_worker_cond;
1847static Eina_Lock open_worker_mutex;
1846 1848
1847static void * 1849static void *
1848open_close_worker(void *path, Eina_Thread tid EINA_UNUSED) 1850open_close_worker(void *path, Eina_Thread tid EINA_UNUSED)
1849{ 1851{
1852 static Eina_Bool first = EINA_TRUE;
1853
1850 while (!open_worker_stop) 1854 while (!open_worker_stop)
1851 { 1855 {
1852 Eet_File *ef = eet_open((char const *)path, EET_FILE_MODE_READ); 1856 Eet_File *ef = eet_open((char const *)path, EET_FILE_MODE_READ);
@@ -1858,6 +1862,14 @@ open_close_worker(void *path, Eina_Thread tid EINA_UNUSED)
1858 if (err_code != EET_ERROR_NONE) 1862 if (err_code != EET_ERROR_NONE)
1859 return "eet_close() failed"; 1863 return "eet_close() failed";
1860 } 1864 }
1865
1866 if (first)
1867 {
1868 eina_lock_take(&open_worker_mutex);
1869 eina_condition_broadcast(&open_worker_cond);
1870 eina_lock_release(&open_worker_mutex);
1871 first = EINA_FALSE;
1872 }
1861 } 1873 }
1862 1874
1863 return NULL; 1875 return NULL;
@@ -1876,17 +1888,24 @@ START_TEST(eet_cache_concurrency)
1876 eet_init(); 1888 eet_init();
1877 eina_threads_init(); 1889 eina_threads_init();
1878 1890
1891 eina_lock_new(&open_worker_mutex);
1892 eina_condition_new(&open_worker_cond, &open_worker_mutex);
1893
1879 /* create a file to test with */ 1894 /* create a file to test with */
1880 fail_if(!(file = tmpnam(file))); 1895 fail_if(!(file = tmpnam(file)));
1881 ef = eet_open(file, EET_FILE_MODE_WRITE); 1896 ef = eet_open(file, EET_FILE_MODE_WRITE);
1882 fail_if(!ef); 1897 fail_if(!ef);
1883 fail_if(!eet_write(ef, "keys/tests", buffer, strlen(buffer) + 1, 0)); 1898 fail_if(!eet_write(ef, "keys/tests", buffer, strlen(buffer) + 1, 0));
1884 1899
1900 eina_lock_take(&open_worker_mutex);
1885 /* start a thread that repeatedly opens and closes a file */ 1901 /* start a thread that repeatedly opens and closes a file */
1886 open_worker_stop = 0; 1902 open_worker_stop = 0;
1887 r = eina_thread_create(&thread, EINA_THREAD_NORMAL, -1, open_close_worker, file); 1903 r = eina_thread_create(&thread, EINA_THREAD_NORMAL, -1, open_close_worker, file);
1888 fail_unless(r); 1904 fail_unless(r);
1889 1905
1906 eina_condition_wait(&open_worker_cond);
1907 eina_lock_release(&open_worker_mutex);
1908
1890 /* clear the cache repeatedly in this thread */ 1909 /* clear the cache repeatedly in this thread */
1891 for (n = 0; n < 20000; ++n) 1910 for (n = 0; n < 20000; ++n)
1892 { 1911 {