summaryrefslogtreecommitdiff
path: root/src/tests/eio
diff options
context:
space:
mode:
authorVincent Torri <vincent dot torri at gmail dot com>2016-02-04 14:51:07 +0100
committerTom Hacohen <tom@stosb.com>2016-02-16 12:41:06 +0000
commite15c61beb37d39c3420a9c2fcc78c99424b24f94 (patch)
treea30ab64a7f247b1b1a50cef325bd8329213f7a5f /src/tests/eio
parentdce4a966ad862f19ff59d2f0ebeeadc739b016d6 (diff)
Test rework #12: Eio
Diffstat (limited to 'src/tests/eio')
-rw-r--r--src/tests/eio/eio_model_test_file.c10
-rw-r--r--src/tests/eio/eio_model_test_monitor_add.c10
-rw-r--r--src/tests/eio/eio_suite.c94
-rw-r--r--src/tests/eio/eio_test_file.c3
-rw-r--r--src/tests/eio/eio_test_monitor.c14
-rw-r--r--src/tests/eio/eio_test_xattr.c2
6 files changed, 26 insertions, 107 deletions
diff --git a/src/tests/eio/eio_model_test_file.c b/src/tests/eio/eio_model_test_file.c
index 270cb870ad..c6aa8d8639 100644
--- a/src/tests/eio/eio_model_test_file.c
+++ b/src/tests/eio/eio_model_test_file.c
@@ -4,14 +4,15 @@
4# include <config.h> 4# include <config.h>
5#endif 5#endif
6 6
7#include <stdio.h>
8
7#include <Eo.h> 9#include <Eo.h>
8#include <Eio.h>
9#include <Ecore.h> 10#include <Ecore.h>
10#include <Efl.h> 11#include <Efl.h>
12#include <Eio.h>
11#include <eio_model.h> 13#include <eio_model.h>
12#include <stdio.h>
13 14
14#include <check.h> 15#include "eio_suite.h"
15 16
16#define EFL_MODEL_TEST_FILENAME_PATH "/tmp" 17#define EFL_MODEL_TEST_FILENAME_PATH "/tmp"
17#define EFL_MODEL_MAX_TEST_CHILDS 16 18#define EFL_MODEL_MAX_TEST_CHILDS 16
@@ -176,7 +177,7 @@ START_TEST(eio_model_test_test_file)
176 handler = ecore_event_handler_add(ECORE_EVENT_SIGNAL_EXIT, exit_func, NULL); 177 handler = ecore_event_handler_add(ECORE_EVENT_SIGNAL_EXIT, exit_func, NULL);
177 178
178 ecore_main_loop_begin(); 179 ecore_main_loop_begin();
179 180
180 eo_do(filemodel, status = efl_model_property_get("filename", &value_prop)); 181 eo_do(filemodel, status = efl_model_property_get("filename", &value_prop));
181 str = eina_value_to_string(value_prop); 182 str = eina_value_to_string(value_prop);
182 printf("efl_model_test filename %s, load status %d\n", str, status); 183 printf("efl_model_test filename %s, load status %d\n", str, status);
@@ -216,4 +217,3 @@ eio_model_test_file(TCase *tc)
216{ 217{
217 tcase_add_test(tc, eio_model_test_test_file); 218 tcase_add_test(tc, eio_model_test_test_file);
218} 219}
219
diff --git a/src/tests/eio/eio_model_test_monitor_add.c b/src/tests/eio/eio_model_test_monitor_add.c
index 8230ec2f26..a0ad69ef7d 100644
--- a/src/tests/eio/eio_model_test_monitor_add.c
+++ b/src/tests/eio/eio_model_test_monitor_add.c
@@ -4,14 +4,15 @@
4# include <config.h> 4# include <config.h>
5#endif 5#endif
6 6
7#include <stdio.h>
8
7#include <Eo.h> 9#include <Eo.h>
8#include <Eio.h>
9#include <Ecore.h> 10#include <Ecore.h>
10#include <Efl.h> 11#include <Efl.h>
12#include <Eio.h>
11#include <eio_model.h> 13#include <eio_model.h>
12#include <stdio.h>
13 14
14#include <check.h> 15#include "eio_suite.h"
15 16
16Eina_Bool children_added = EINA_FALSE; 17Eina_Bool children_added = EINA_FALSE;
17Eina_Tmpstr* temp_filename = NULL; 18Eina_Tmpstr* temp_filename = NULL;
@@ -123,7 +124,7 @@ START_TEST(eio_model_test_test_monitor_add)
123 fail_if(!eio_init(), "ERROR: Cannot init EIO!\n"); 124 fail_if(!eio_init(), "ERROR: Cannot init EIO!\n");
124 125
125 tmpdir = eina_environment_tmp_get(); 126 tmpdir = eina_environment_tmp_get();
126 127
127 filemodel = eo_add(EIO_MODEL_CLASS, NULL, eio_model_path_set(tmpdir)); 128 filemodel = eo_add(EIO_MODEL_CLASS, NULL, eio_model_path_set(tmpdir));
128 fail_if(!filemodel, "ERROR: Cannot init model!\n"); 129 fail_if(!filemodel, "ERROR: Cannot init model!\n");
129 130
@@ -150,4 +151,3 @@ eio_model_test_monitor_add(TCase *tc)
150{ 151{
151 tcase_add_test(tc, eio_model_test_test_monitor_add); 152 tcase_add_test(tc, eio_model_test_test_monitor_add);
152} 153}
153
diff --git a/src/tests/eio/eio_suite.c b/src/tests/eio/eio_suite.c
index 4dfdbfbc5a..39ce8f769a 100644
--- a/src/tests/eio/eio_suite.c
+++ b/src/tests/eio/eio_suite.c
@@ -2,22 +2,10 @@
2# include <config.h> 2# include <config.h>
3#endif 3#endif
4 4
5#include <stdlib.h>
6#include <stdio.h>
7
8#include <Eio.h>
9
10#include "eio_suite.h" 5#include "eio_suite.h"
6#include "../efl_check.h"
11 7
12typedef struct _Eio_Test_Case Eio_Test_Case; 8static const Efl_Test_Case etc[] = {
13
14struct _Eio_Test_Case
15{
16 const char *test_case;
17 void (*build)(TCase *tc);
18};
19
20static const Eio_Test_Case etc[] = {
21 {"Eio_Monitor", eio_test_monitor}, 9 {"Eio_Monitor", eio_test_monitor},
22 {"Eio Model", eio_model_test_file}, 10 {"Eio Model", eio_model_test_file},
23 {"Eio Model Monitor", eio_model_test_monitor_add}, 11 {"Eio Model Monitor", eio_model_test_monitor_add},
@@ -28,86 +16,18 @@ static const Eio_Test_Case etc[] = {
28 {NULL, NULL} 16 {NULL, NULL}
29}; 17};
30 18
31static void
32_list_tests(void)
33{
34 const Eio_Test_Case *itr;
35
36 itr = etc;
37 fputs("Available Test Cases:\n", stderr);
38 for (; itr->test_case; itr++)
39 fprintf(stderr, "\t%s\n", itr->test_case);
40}
41
42static Eina_Bool
43_use_test(int argc, const char **argv, const char *test_case)
44{
45 if (argc < 1)
46 return 1;
47
48 for (; argc > 0; argc--, argv++)
49 if (strcmp(test_case, *argv) == 0)
50 return 1;
51 return 0;
52}
53
54static Suite *
55eio_suite_build(int argc, const char **argv)
56{
57 TCase *tc;
58 Suite *s;
59 int i;
60
61 s = suite_create("Eio");
62
63 for (i = 0; etc[i].test_case; ++i)
64 {
65 if (!_use_test(argc, argv, etc[i].test_case)) continue;
66 tc = tcase_create(etc[i].test_case);
67
68 etc[i].build(tc);
69
70 suite_add_tcase(s, tc);
71 tcase_set_timeout(tc, 0);
72 }
73
74 return s;
75}
76
77
78int 19int
79main(int argc, char **argv) 20main(int argc, char **argv)
80{ 21{
81 Suite *s; 22 int failed_count;
82 SRunner *sr;
83 int i, failed_count;
84 23
85 for (i = 1; i < argc; i++) 24 if (!_efl_test_option_disp(argc, argv, etc))
86 if ((strcmp(argv[i], "-h") == 0) || 25 return 0;
87 (strcmp(argv[i], "--help") == 0))
88 {
89 fprintf(stderr, "Usage:\n\t%s [test_case1 .. [test_caseN]]\n",
90 argv[0]);
91 _list_tests();
92 return 0;
93 }
94 else if ((strcmp(argv[i], "-l") == 0) ||
95 (strcmp(argv[i], "--list") == 0))
96 {
97 _list_tests();
98 return 0;
99 }
100 26
101 putenv("EFL_RUN_IN_TREE=1"); 27 putenv("EFL_RUN_IN_TREE=1");
102 28
103 s = eio_suite_build(argc - 1, (const char **)argv + 1); 29 failed_count = _efl_suite_build_and_run(argc - 1, (const char **)argv + 1,
104 sr = srunner_create(s); 30 "Eio", etc);
105
106 srunner_set_xml(sr, TESTS_BUILD_DIR "/check-results.xml");
107
108 srunner_run_all(sr, CK_ENV);
109 failed_count = srunner_ntests_failed(sr);
110 srunner_free(sr);
111 31
112 return (failed_count == 0) ? 0 : 255; 32 return (failed_count == 0) ? 0 : 255;
113} 33}
diff --git a/src/tests/eio/eio_test_file.c b/src/tests/eio/eio_test_file.c
index c17246ec26..5513e9013a 100644
--- a/src/tests/eio/eio_test_file.c
+++ b/src/tests/eio/eio_test_file.c
@@ -8,9 +8,9 @@
8#include <sys/stat.h> 8#include <sys/stat.h>
9#include <fcntl.h> 9#include <fcntl.h>
10 10
11#include <Eio.h>
12#include <Ecore.h> 11#include <Ecore.h>
13#include <Ecore_File.h> 12#include <Ecore_File.h>
13#include <Eio.h>
14 14
15#include "eio_suite.h" 15#include "eio_suite.h"
16 16
@@ -374,4 +374,3 @@ eio_test_file(TCase *tc)
374 tcase_add_test(tc, eio_file_test_ls); 374 tcase_add_test(tc, eio_file_test_ls);
375 tcase_add_test(tc, eio_file_test_file); 375 tcase_add_test(tc, eio_file_test_file);
376} 376}
377
diff --git a/src/tests/eio/eio_test_monitor.c b/src/tests/eio/eio_test_monitor.c
index daf2a3fd0d..fbf813486b 100644
--- a/src/tests/eio/eio_test_monitor.c
+++ b/src/tests/eio/eio_test_monitor.c
@@ -6,9 +6,9 @@
6#include <unistd.h> 6#include <unistd.h>
7#include <string.h> 7#include <string.h>
8 8
9#include <Eio.h>
10#include <Ecore.h> 9#include <Ecore.h>
11#include <Ecore_File.h> 10#include <Ecore_File.h>
11#include <Eio.h>
12 12
13#include "eio_suite.h" 13#include "eio_suite.h"
14 14
@@ -147,9 +147,9 @@ START_TEST(eio_test_monitor_add_and_remove)
147 147
148 //monitor directory 148 //monitor directory
149 monitor = eio_monitor_add(filename); 149 monitor = eio_monitor_add(filename);
150 150
151 usleep(500000); 151 usleep(500000);
152 152
153 eio_monitor_del(monitor); 153 eio_monitor_del(monitor);
154 154
155 _common_shutdown(dirname); 155 _common_shutdown(dirname);
@@ -172,9 +172,9 @@ START_TEST(eio_test_monitor_add_remove_add)
172 //monitor directory 172 //monitor directory
173 monitor1 = eio_monitor_add(filename); 173 monitor1 = eio_monitor_add(filename);
174 eio_monitor_del(monitor1); 174 eio_monitor_del(monitor1);
175 175
176 usleep(500000); 176 usleep(500000);
177 177
178 monitor2 = eio_monitor_add(filename); 178 monitor2 = eio_monitor_add(filename);
179 eio_monitor_del(monitor2); 179 eio_monitor_del(monitor2);
180 180
@@ -199,7 +199,7 @@ START_TEST(eio_test_monitor_add_add_remove_remove)
199 usleep(500000); 199 usleep(500000);
200 200
201 //monitor directory 201 //monitor directory
202 monitor1 = eio_monitor_add(filename1); 202 monitor1 = eio_monitor_add(filename1);
203 monitor2 = eio_monitor_add(filename2); 203 monitor2 = eio_monitor_add(filename2);
204 usleep(500000); 204 usleep(500000);
205 eio_monitor_del(monitor2); 205 eio_monitor_del(monitor2);
@@ -727,7 +727,7 @@ void eio_test_monitor(TCase *tc)
727 tcase_add_test(tc, eio_test_monitor_add_and_remove); 727 tcase_add_test(tc, eio_test_monitor_add_and_remove);
728 tcase_add_test(tc, eio_test_monitor_add_remove_add); 728 tcase_add_test(tc, eio_test_monitor_add_remove_add);
729 tcase_add_test(tc, eio_test_monitor_add_add_remove_remove); 729 tcase_add_test(tc, eio_test_monitor_add_add_remove_remove);
730 730
731 tcase_add_test(tc, eio_test_monitor_directory_file_created_notify); 731 tcase_add_test(tc, eio_test_monitor_directory_file_created_notify);
732 tcase_add_test(tc, eio_test_monitor_directory_file_deleted_notify); 732 tcase_add_test(tc, eio_test_monitor_directory_file_deleted_notify);
733 tcase_add_test(tc, eio_test_monitor_directory_file_modified_notify); 733 tcase_add_test(tc, eio_test_monitor_directory_file_modified_notify);
diff --git a/src/tests/eio/eio_test_xattr.c b/src/tests/eio/eio_test_xattr.c
index 6f15fac44c..0b1b298cb8 100644
--- a/src/tests/eio/eio_test_xattr.c
+++ b/src/tests/eio/eio_test_xattr.c
@@ -7,9 +7,9 @@
7#include <string.h> 7#include <string.h>
8#include <fcntl.h> 8#include <fcntl.h>
9 9
10#include <Eio.h>
11#include <Ecore.h> 10#include <Ecore.h>
12#include <Ecore_File.h> 11#include <Ecore_File.h>
12#include <Eio.h>
13 13
14#include "eio_suite.h" 14#include "eio_suite.h"
15 15