summaryrefslogtreecommitdiff
path: root/src/tests/ecore_cxx
diff options
context:
space:
mode:
authorVincent Torri <vincent dot torri at gmail dot com>2016-02-04 14:17:31 +0100
committerTom Hacohen <tom@stosb.com>2016-02-16 12:41:06 +0000
commit563f616b7c0cf67ee546f0b2939e81f19fbea27a (patch)
tree063285107269946bcd80742eafbf2c17f7fac78b /src/tests/ecore_cxx
parentb772a46437ff9d97285f0ec811725395b79e04a7 (diff)
Test rework #3: Ecore_Cxx
Diffstat (limited to 'src/tests/ecore_cxx')
-rw-r--r--src/tests/ecore_cxx/ecore_cxx_suite.cc103
-rw-r--r--src/tests/ecore_cxx/ecore_cxx_suite.h11
-rw-r--r--src/tests/ecore_cxx/ecore_cxx_test_safe_call.cc11
3 files changed, 27 insertions, 98 deletions
diff --git a/src/tests/ecore_cxx/ecore_cxx_suite.cc b/src/tests/ecore_cxx/ecore_cxx_suite.cc
index 4d2e721d43..33ed9b6fe6 100644
--- a/src/tests/ecore_cxx/ecore_cxx_suite.cc
+++ b/src/tests/ecore_cxx/ecore_cxx_suite.cc
@@ -2,107 +2,26 @@
2# include <config.h> 2# include <config.h>
3#endif 3#endif
4 4
5#include "Ecore.hh" 5#include "ecore_cxx_suite.h"
6#include "../efl_check.h"
6 7
7#include <cassert> 8static const Efl_Test_Case etc[] = {
8#include <algorithm> 9 { "Safe_Call", ecore_cxx_test_safe_call },
9
10#include <check.h>
11
12void ecore_test_safe_call(TCase* tc);
13
14typedef struct _Ecore_Test_Case Ecore_Test_Case;
15struct _Ecore_Test_Case
16{
17 const char *test_case;
18 void (*build)(TCase *tc);
19};
20
21static const Ecore_Test_Case etc[] = {
22 { "Safe_Call", ecore_test_safe_call },
23 { NULL, NULL } 10 { NULL, NULL }
24}; 11};
25 12
26static void 13int
27_list_tests(void) 14main(int argc, char* argv[])
28{ 15{
29 const Ecore_Test_Case *itr = etc; 16 int failed_count;
30 fputs("Available Test Cases:\n", stderr);
31 for (; itr->test_case; itr++)
32 fprintf(stderr, "\t%s\n", itr->test_case);
33}
34 17
35static Eina_Bool 18 if (!_efl_test_option_disp(argc, argv, etc))
36_use_test(int argc, const char **argv, const char *test_case) 19 return 0;
37{
38 if (argc < 1)
39 return 1;
40
41 for (; argc > 0; argc--, argv++)
42 if (strcmp(test_case, *argv) == 0)
43 return 1;
44
45 return 0;
46}
47
48Suite *
49ecore_build_suite(int argc, const char **argv)
50{
51 TCase *tc;
52 Suite *s;
53 int i;
54
55 s = suite_create("Ecore");
56
57 for (i = 0; etc[i].test_case; ++i)
58 {
59 if (!_use_test(argc, argv, etc[i].test_case))
60 continue;
61
62 tc = tcase_create(etc[i].test_case);
63#ifndef _WIN32
64 tcase_set_timeout(tc, 0);
65#endif
66
67 etc[i].build(tc);
68 suite_add_tcase(s, tc);
69 }
70
71 return s;
72}
73
74int main(int argc, char* argv[])
75{
76 Suite *s;
77 SRunner *sr;
78 int i, failed_count;
79
80 for (i = 1; i < argc; i++)
81 if ((strcmp(argv[i], "-h") == 0) ||
82 (strcmp(argv[i], "--help") == 0))
83 {
84 fprintf(stderr, "Usage:\n\t%s [test_case1 .. [test_caseN]]\n",
85 argv[0]);
86 _list_tests();
87 return 0;
88 }
89 else if ((strcmp(argv[i], "-l") == 0) ||
90 (strcmp(argv[i], "--list") == 0))
91 {
92 _list_tests();
93 return 0;
94 }
95 20
96 putenv(const_cast<char*>("EFL_RUN_IN_TREE=1")); 21 putenv(const_cast<char*>("EFL_RUN_IN_TREE=1"));
97 22
98 s = ecore_build_suite(argc - 1, (const char **)argv + 1); 23 failed_count = _efl_suite_build_and_run(argc - 1, (const char **)argv + 1,
99 sr = srunner_create(s); 24 "Ecore C++", etc);
100
101 srunner_set_xml(sr, TESTS_BUILD_DIR "/check-results.xml");
102
103 srunner_run_all(sr, CK_ENV);
104 failed_count = srunner_ntests_failed(sr);
105 srunner_free(sr);
106 25
107 return (failed_count == 0) ? 0 : 255; 26 return (failed_count == 0) ? 0 : 255;
108} 27}
diff --git a/src/tests/ecore_cxx/ecore_cxx_suite.h b/src/tests/ecore_cxx/ecore_cxx_suite.h
new file mode 100644
index 0000000000..34343317fc
--- /dev/null
+++ b/src/tests/ecore_cxx/ecore_cxx_suite.h
@@ -0,0 +1,11 @@
1#ifndef _ECORE_CXX_SUITE_H
2#define _ECORE_CXX_SUITE_H
3
4#include <cassert>
5#include <algorithm>
6
7#include <check.h>
8
9void ecore_cxx_test_safe_call(TCase* tc);
10
11#endif /* _ECORE_CXX_SUITE_H */
diff --git a/src/tests/ecore_cxx/ecore_cxx_test_safe_call.cc b/src/tests/ecore_cxx/ecore_cxx_test_safe_call.cc
index 1425041e55..72020873c5 100644
--- a/src/tests/ecore_cxx/ecore_cxx_test_safe_call.cc
+++ b/src/tests/ecore_cxx/ecore_cxx_test_safe_call.cc
@@ -2,14 +2,13 @@
2# include <config.h> 2# include <config.h>
3#endif 3#endif
4 4
5#include "Ecore.hh"
6#include "Eina.hh"
7
8#include <algorithm> 5#include <algorithm>
9
10#include <iostream> 6#include <iostream>
11 7
12#include <check.h> 8#include <Eina.hh>
9#include <Ecore.hh>
10
11#include "ecore_cxx_suite.h"
13 12
14void call_async(efl::eina::mutex& mutex, efl::eina::condition_variable& cond, int& done) 13void call_async(efl::eina::mutex& mutex, efl::eina::condition_variable& cond, int& done)
15{ 14{
@@ -260,7 +259,7 @@ START_TEST(ecore_cxx_safe_call_sync)
260END_TEST 259END_TEST
261 260
262void 261void
263ecore_test_safe_call(TCase* tc) 262ecore_cxx_test_safe_call(TCase* tc)
264{ 263{
265 tcase_add_test(tc, ecore_cxx_safe_call_async); 264 tcase_add_test(tc, ecore_cxx_safe_call_async);
266 tcase_add_test(tc, ecore_cxx_safe_call_sync); 265 tcase_add_test(tc, ecore_cxx_safe_call_sync);