summaryrefslogtreecommitdiff
path: root/src/tests/evil
diff options
context:
space:
mode:
authorVincent Torri <vincent.torri@gmail.com>2018-02-01 20:28:57 +0100
committerCedric BAIL <cedric@osg.samsung.com>2018-02-01 13:28:36 -0800
commitd4fcff7ed43bf5b4e6e44767c9f9a1acf5535137 (patch)
tree5e0ae30f03d6d3f5152d2975d27c30011f411b35 /src/tests/evil
parenta89c9e037aeda8cddc132072675a5bbdea089ad7 (diff)
evil: final step : remove completely the binary, useless now that the unit test is theree
Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
Diffstat (limited to 'src/tests/evil')
-rw-r--r--src/tests/evil/evil_suite.c5
-rw-r--r--src/tests/evil/evil_suite.h5
-rw-r--r--src/tests/evil/evil_test_unistd.c120
3 files changed, 122 insertions, 8 deletions
diff --git a/src/tests/evil/evil_suite.c b/src/tests/evil/evil_suite.c
index 454a217e64..36d86ac8e5 100644
--- a/src/tests/evil/evil_suite.c
+++ b/src/tests/evil/evil_suite.c
@@ -27,13 +27,10 @@
27#include "../efl_check.h" 27#include "../efl_check.h"
28 28
29static const Efl_Test_Case etc[] = { 29static const Efl_Test_Case etc[] = {
30 /* { "Dirent", evil_test_dirent }, */
31 { "Dlfcn", evil_test_dlfcn }, 30 { "Dlfcn", evil_test_dlfcn },
32 /* { "Fcntl", evil_test_fcntl }, */ 31 /* { "Fcntl", evil_test_fcntl }, */
33 /* { "Fnmatch", evil_test_fnmatch }, */ 32 /* { "Fnmatch", evil_test_fnmatch }, */
34 /* { "Inet", evil_test_inet }, */
35 /* { "Langinfo", evil_test_langinfo }, */ 33 /* { "Langinfo", evil_test_langinfo }, */
36 /* { "Link", evil_test_link }, */
37 { "Libgen", evil_test_libgen }, 34 { "Libgen", evil_test_libgen },
38 { "Main", evil_test_main }, 35 { "Main", evil_test_main },
39 /* { "Mman", evil_test_mman }, */ 36 /* { "Mman", evil_test_mman }, */
@@ -42,7 +39,7 @@ static const Efl_Test_Case etc[] = {
42 { "Stdlib", evil_test_stdlib }, 39 { "Stdlib", evil_test_stdlib },
43 /* { "String", evil_test_string }, */ 40 /* { "String", evil_test_string }, */
44 /* { "Time", evil_test_time }, */ 41 /* { "Time", evil_test_time }, */
45 /* { "Unistd", evil_test_unistd }, */ 42 { "Unistd", evil_test_unistd },
46 /* { "Util", evil_test_util }, */ 43 /* { "Util", evil_test_util }, */
47 { NULL, NULL } 44 { NULL, NULL }
48}; 45};
diff --git a/src/tests/evil/evil_suite.h b/src/tests/evil/evil_suite.h
index 20f8d03a60..b7ae5e8274 100644
--- a/src/tests/evil/evil_suite.h
+++ b/src/tests/evil/evil_suite.h
@@ -21,13 +21,10 @@
21 21
22#include <check.h> 22#include <check.h>
23 23
24/* void evil_test_dirent(TCase *tc); */
25void evil_test_dlfcn(TCase *tc); 24void evil_test_dlfcn(TCase *tc);
26/* void evil_test_fcntl(TCase *tc); */ 25/* void evil_test_fcntl(TCase *tc); */
27/* void evil_test_fnmatch(TCase *tc); */ 26/* void evil_test_fnmatch(TCase *tc); */
28/* void evil_test_inet(TCase *tc); */
29/* void evil_test_langinfo(TCase *tc); */ 27/* void evil_test_langinfo(TCase *tc); */
30/* void evil_test_link(TCase *tc); */
31void evil_test_libgen(TCase *tc); 28void evil_test_libgen(TCase *tc);
32void evil_test_main(TCase *tc); 29void evil_test_main(TCase *tc);
33/* void evil_test_mman(TCase *tc); */ 30/* void evil_test_mman(TCase *tc); */
@@ -36,7 +33,7 @@ void evil_test_stdio(TCase *tc);
36void evil_test_stdlib(TCase *tc); 33void evil_test_stdlib(TCase *tc);
37/* void evil_test_string(TCase *tc); */ 34/* void evil_test_string(TCase *tc); */
38/* void evil_test_time(TCase *tc); */ 35/* void evil_test_time(TCase *tc); */
39/* void evil_test_unistd(TCase *tc); */ 36void evil_test_unistd(TCase *tc);
40/* void evil_test_util(TCase *tc); */ 37/* void evil_test_util(TCase *tc); */
41 38
42#endif /* EVIL_SUITE_H_ */ 39#endif /* EVIL_SUITE_H_ */
diff --git a/src/tests/evil/evil_test_unistd.c b/src/tests/evil/evil_test_unistd.c
new file mode 100644
index 0000000000..0ab5f78146
--- /dev/null
+++ b/src/tests/evil/evil_test_unistd.c
@@ -0,0 +1,120 @@
1/* EVIL - EFL library for Windows port
2 * Copyright (C) 2017 Vincent Torri
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifdef HAVE_CONFIG_H
20# include "config.h"
21#endif
22
23#include <stdlib.h>
24#include <stdio.h>
25
26# define WIN32_LEAN_AND_MEAN
27# include <winsock2.h>
28# undef WIN32_LEAN_AND_MEAN
29
30#include <Evil.h>
31
32#include "evil_suite.h"
33
34
35#define FDREAD 0
36#define FDWRITE 1
37
38typedef struct
39{
40 int val;
41 int fd_write;
42} data;
43
44
45static DWORD WINAPI
46thread(void *param)
47{
48 data *d;
49 void *buf[1];
50
51 Sleep (2 * 1000);
52 d = (data *)param;
53 buf[0] = param;
54 send(d->fd_write, (char *)buf, sizeof(buf), 0);
55
56 return 0;
57}
58
59START_TEST(evil_unistd_pipe)
60{
61 int sockets[2];
62 struct timeval t;
63 fd_set rfds;
64 int ret;
65 data *d;
66 DWORD thread_id;
67 HANDLE h;
68
69 ret = evil_init();
70 fail_if(ret == 0);
71
72 FD_ZERO(&rfds);
73 t.tv_sec = 5;
74 t.tv_usec = 0;
75
76 ret = pipe(sockets);
77 fail_if(ret < 0);
78
79 FD_SET(sockets[FDREAD], &rfds);
80 fcntl(sockets[FDREAD], F_SETFL, O_NONBLOCK);
81
82 d = (data *)malloc(sizeof (data));
83 fail_if(d == NULL);
84
85 d->val = 14;
86 d->fd_write = sockets[FDWRITE];
87
88 h = CreateThread(NULL, 0, thread, d, 0, &thread_id);
89 fail_if(h == NULL);
90
91 ret = select(sockets[FDREAD] + 1, &rfds, NULL, NULL, &t);
92 fail_if(ret <= 0);
93
94 {
95 void *buf[1];
96 data *d2 = NULL;
97 int len;
98
99 while ((len = recv(sockets[FDREAD], (char *)buf, sizeof(buf), 0)) > 0)
100 {
101 if (len == sizeof(buf))
102 {
103 d2 = (data *)buf[0];
104 break;
105 }
106 }
107 fail_if(!d2 || (d2->val != d->val));
108 }
109
110 CloseHandle(h);
111 free(d);
112
113 evil_shutdown();
114}
115END_TEST
116
117void evil_test_unistd(TCase *tc)
118{
119 tcase_add_test(tc, evil_unistd_pipe);
120}