summaryrefslogtreecommitdiff
path: root/src/tests/eet/eet_suite.c
diff options
context:
space:
mode:
authorGustavo Sverzut Barbieri <barbieri@gmail.com>2012-12-31 16:14:40 +0000
committerGustavo Sverzut Barbieri <barbieri@gmail.com>2012-12-31 16:14:40 +0000
commit4668d04f0493b26a4cce4d307a9ed1277553c082 (patch)
tree854c9af550983aafa5c8ae2f6030911940120ab8 /src/tests/eet/eet_suite.c
parent12e06024520c4d783380ceb0e6ec5d8e40dab6ae (diff)
efl: cleanup HAVE_THREADS and pthread usage outside of eina.
Eina now abstracts threads, so use that. the touched files had the EFL_HAVE_THREADS as it's mandatory now. SVN revision: 81935
Diffstat (limited to 'src/tests/eet/eet_suite.c')
-rw-r--r--src/tests/eet/eet_suite.c72
1 files changed, 9 insertions, 63 deletions
diff --git a/src/tests/eet/eet_suite.c b/src/tests/eet/eet_suite.c
index 13fc8e3dcf..f1b0dd9e69 100644
--- a/src/tests/eet/eet_suite.c
+++ b/src/tests/eet/eet_suite.c
@@ -13,13 +13,6 @@
13 13
14#include <Eina.h> 14#include <Eina.h>
15 15
16#ifdef EINA_HAVE_THREADS
17#if ((!defined(_WIN32_WCE)) && (!defined(_WIN32)))
18# include <pthread.h>
19# define _EET_INCLUDED_PTHREAD
20#endif
21#endif /* ifdef EINA_HAVE_THREADS */
22
23#include <check.h> 16#include <check.h>
24 17
25#include "eet_suite.h" 18#include "eet_suite.h"
@@ -1849,53 +1842,26 @@ START_TEST(eet_cipher_decipher_simple)
1849 1842
1850END_TEST 1843END_TEST
1851 1844
1852#ifdef EINA_HAVE_THREADS
1853
1854static Eina_Bool open_worker_stop; 1845static Eina_Bool open_worker_stop;
1855 1846
1856# ifdef _EET_INCLUDED_PTHREAD
1857
1858static void * 1847static void *
1859open_close_worker(void *path) 1848open_close_worker(void *path, Eina_Thread tid EINA_UNUSED)
1860{ 1849{
1861 while (!open_worker_stop) 1850 while (!open_worker_stop)
1862 { 1851 {
1863 Eet_File *ef = eet_open((char const *)path, EET_FILE_MODE_READ); 1852 Eet_File *ef = eet_open((char const *)path, EET_FILE_MODE_READ);
1864 if (ef == NULL) 1853 if (ef == NULL)
1865 pthread_exit("eet_open() failed"); 1854 return "eet_open() failed";
1866 else 1855 else
1867 { 1856 {
1868 Eet_Error err_code = eet_close(ef); 1857 Eet_Error err_code = eet_close(ef);
1869 if (err_code != EET_ERROR_NONE) 1858 if (err_code != EET_ERROR_NONE)
1870 pthread_exit("eet_close() failed"); 1859 return "eet_close() failed";
1871 } 1860 }
1872 } 1861 }
1873 1862
1874 pthread_exit(NULL); 1863 return NULL;
1875} /* open_close_worker */ 1864}
1876
1877# else /* ifdef _EET_INCLUDED_PTHREAD */
1878
1879static unsigned int __stdcall
1880open_close_worker(void *path)
1881{
1882 while (!open_worker_stop)
1883 {
1884 Eet_File *ef = eet_open((char const *)path, EET_FILE_MODE_READ);
1885 if (ef == NULL)
1886 _endthreadex(-1);
1887 else
1888 {
1889 Eet_Error err_code = eet_close(ef);
1890 if (err_code != EET_ERROR_NONE)
1891 _endthreadex(-2);
1892 }
1893 }
1894
1895 _endthreadex(0);
1896} /* open_close_worker */
1897
1898# endif /* ifdef _EET_INCLUDED_PTHREAD */
1899 1865
1900START_TEST(eet_cache_concurrency) 1866START_TEST(eet_cache_concurrency)
1901{ 1867{
@@ -1904,13 +1870,7 @@ START_TEST(eet_cache_concurrency)
1904 Eet_File *ef; 1870 Eet_File *ef;
1905 void *thread_ret; 1871 void *thread_ret;
1906 unsigned int n; 1872 unsigned int n;
1907# ifdef _EET_INCLUDED_PTHREAD 1873 Eina_Thread thread;
1908 pthread_t thread;
1909# else /* ifdef _EET_INCLUDED_PTHREAD */
1910 uintptr_t thread;
1911 unsigned int thread_id;
1912 DWORD ret;
1913# endif /* ifdef _EET_INCLUDED_PTHREAD */
1914 1874
1915 eet_init(); 1875 eet_init();
1916 eina_threads_init(); 1876 eina_threads_init();
@@ -1923,11 +1883,8 @@ START_TEST(eet_cache_concurrency)
1923 1883
1924 /* start a thread that repeatedly opens and closes a file */ 1884 /* start a thread that repeatedly opens and closes a file */
1925 open_worker_stop = 0; 1885 open_worker_stop = 0;
1926# ifdef _EET_INCLUDED_PTHREAD 1886 eina_thread_create(&thread, EINA_THREAD_NORMAL, -1, open_close_worker, file);
1927 pthread_create(&thread, NULL, open_close_worker, file); 1887
1928# else /* ifdef _EET_INCLUDED_PTHREAD */
1929 thread = _beginthreadex(NULL, 0, open_close_worker, file, 0, &thread_id);
1930# endif /* ifdef _EET_INCLUDED_PTHREAD */
1931 /* clear the cache repeatedly in this thread */ 1888 /* clear the cache repeatedly in this thread */
1932 for (n = 0; n < 20000; ++n) 1889 for (n = 0; n < 20000; ++n)
1933 { 1890 {
@@ -1936,15 +1893,8 @@ START_TEST(eet_cache_concurrency)
1936 1893
1937 /* join the other thread, and fail if it returned an error message */ 1894 /* join the other thread, and fail if it returned an error message */
1938 open_worker_stop = 1; 1895 open_worker_stop = 1;
1939# ifdef _EET_INCLUDED_PTHREAD 1896 thread_ret = eina_thread_join(thread);
1940 fail_if(pthread_join(thread, &thread_ret) != 0);
1941 fail_unless(thread_ret == NULL, (char const *)thread_ret); 1897 fail_unless(thread_ret == NULL, (char const *)thread_ret);
1942# else /* ifdef _EET_INCLUDED_PTHREAD */
1943 ret = WaitForSingleObject((HANDLE)thread, INFINITE);
1944 fail_if(ret != WAIT_OBJECT_0);
1945 fail_if(GetExitCodeThread((HANDLE)thread, &ret) == FALSE);
1946 fail_if(ret != 0);
1947# endif /* ifdef _EET_INCLUDED_PTHREAD */
1948 1898
1949 eet_close(ef); 1899 eet_close(ef);
1950 1900
@@ -1955,8 +1905,6 @@ START_TEST(eet_cache_concurrency)
1955} 1905}
1956END_TEST 1906END_TEST
1957 1907
1958#endif /* EINA_HAVE_THREADS */
1959
1960typedef struct _Eet_Connection_Data Eet_Connection_Data; 1908typedef struct _Eet_Connection_Data Eet_Connection_Data;
1961struct _Eet_Connection_Data 1909struct _Eet_Connection_Data
1962{ 1910{
@@ -2746,11 +2694,9 @@ eet_suite(void)
2746 suite_add_tcase(s, tc); 2694 suite_add_tcase(s, tc);
2747#endif /* ifdef HAVE_CIPHER */ 2695#endif /* ifdef HAVE_CIPHER */
2748 2696
2749#ifdef EINA_HAVE_THREADS
2750 tc = tcase_create("Eet Cache"); 2697 tc = tcase_create("Eet Cache");
2751 tcase_add_test(tc, eet_cache_concurrency); 2698 tcase_add_test(tc, eet_cache_concurrency);
2752 suite_add_tcase(s, tc); 2699 suite_add_tcase(s, tc);
2753#endif /* ifdef EFL_HAVE_THREADS */
2754 2700
2755 tc = tcase_create("Eet Connection"); 2701 tc = tcase_create("Eet Connection");
2756 tcase_add_test(tc, eet_connection_check); 2702 tcase_add_test(tc, eet_connection_check);