summaryrefslogtreecommitdiff
path: root/src/bin/evil
diff options
context:
space:
mode:
authorVincent Torri <vincent.torri@gmail.com>2018-01-31 13:35:03 +0100
committerCedric Bail <cedric@osg.samsung.com>2018-01-31 11:07:11 -0800
commitb464ffb67943573f4e12b55dea23a1bc2b1c6832 (patch)
treed14f51cb287897ec655b0bc324508a513505bf4c /src/bin/evil
parenta6d0e787e4f8695cd1269a4af716e419c8c40133 (diff)
evil: remove useless binary tests
Signed-off-by: Cedric Bail <cedric@osg.samsung.com>
Diffstat (limited to 'src/bin/evil')
-rw-r--r--src/bin/evil/evil_suite.c19
-rw-r--r--src/bin/evil/evil_test_dlfcn.c79
-rw-r--r--src/bin/evil/evil_test_dlfcn.h8
-rw-r--r--src/bin/evil/evil_test_environment.c178
-rw-r--r--src/bin/evil/evil_test_environment.h8
-rw-r--r--src/bin/evil/evil_test_gettimeofday.c51
-rw-r--r--src/bin/evil/evil_test_gettimeofday.h8
-rw-r--r--src/bin/evil/evil_test_mkstemp.c95
-rw-r--r--src/bin/evil/evil_test_mkstemp.h8
-rw-r--r--src/bin/evil/evil_test_print.c46
-rw-r--r--src/bin/evil/evil_test_print.h8
-rw-r--r--src/bin/evil/evil_test_realpath.c45
-rw-r--r--src/bin/evil/evil_test_realpath.h8
-rw-r--r--src/bin/evil/test_evil.c27
14 files changed, 3 insertions, 585 deletions
diff --git a/src/bin/evil/evil_suite.c b/src/bin/evil/evil_suite.c
index 6202fb4e7f..aa2e7f3cd4 100644
--- a/src/bin/evil/evil_suite.c
+++ b/src/bin/evil/evil_suite.c
@@ -11,13 +11,7 @@
11 11
12#include "Evil.h" 12#include "Evil.h"
13#include "evil_suite.h" 13#include "evil_suite.h"
14#include "evil_test_dlfcn.h"
15#include "evil_test_environment.h"
16#include "evil_test_gettimeofday.h"
17#include "evil_test_mkstemp.h"
18#include "evil_test_pipe.h" 14#include "evil_test_pipe.h"
19#include "evil_test_print.h"
20#include "evil_test_realpath.h"
21#include "evil_test_util.h" 15#include "evil_test_util.h"
22 16
23 17
@@ -178,16 +172,9 @@ int
178main(void) 172main(void)
179{ 173{
180 test tests[] = { 174 test tests[] = {
181 { "dlfcn ", test_dlfcn }, 175 { "pipe ", test_pipe },
182 { "environment ", test_environment }, 176 { "util ", test_util },
183 { "gettimeofday", test_gettimeofday }, 177 { NULL, NULL },
184 { "mkstemp ", test_mkstemp },
185 { "pipe ", test_pipe },
186 { "print ", test_print },
187 { "realpath ", test_realpath },
188 { "util ", test_util },
189/* { "memcpy ", test_memcpy }, */
190 { NULL, NULL },
191 }; 178 };
192 suite *s; 179 suite *s;
193 int i; 180 int i;
diff --git a/src/bin/evil/evil_test_dlfcn.c b/src/bin/evil/evil_test_dlfcn.c
deleted file mode 100644
index 605f5c4b68..0000000000
--- a/src/bin/evil/evil_test_dlfcn.c
+++ /dev/null
@@ -1,79 +0,0 @@
1#ifdef HAVE_CONFIG_H
2# include "config.h"
3#endif /* HAVE_CONFIG_H */
4
5#include <string.h>
6
7#include <Evil.h>
8
9#include "evil_suite.h"
10#include "evil_test_dlfcn.h"
11
12
13typedef int (*_evil_init)(void);
14typedef int (*_evil_shutdwon)(void);
15
16
17static int
18test_dlfcn_test_dlopen(void)
19{
20 void *handle;
21
22 handle = dlopen("libevil-1.dll", 0);
23 if (!handle)
24 return 0;
25
26 if (dlclose(handle))
27 return 0;
28
29 return 1;
30}
31
32static int
33test_dlfcn_test_dlsym(void)
34{
35 void *handle;
36 _evil_init sym_init;
37 _evil_shutdwon sym_shutdown;
38
39 handle = dlopen("libevil-1.dll", 0);
40 if (!handle)
41 return 0;
42
43 sym_init = dlsym(handle, "evil_init");
44 if (!sym_init)
45 {
46 dlclose(handle);
47 return 0;
48 }
49
50 sym_shutdown = dlsym(handle, "evil_shutdown");
51 if (!sym_shutdown)
52 {
53 dlclose(handle);
54 return 0;
55 }
56
57 if (dlclose(handle))
58 return 0;
59
60 return 1;
61}
62
63static int
64test_dlfcn_tests_run(suite *s)
65{
66 int res;
67
68 res = test_dlfcn_test_dlopen();
69 res &= test_dlfcn_test_dlsym();
70
71 return res;
72}
73
74int
75test_dlfcn(suite *s)
76{
77
78 return test_dlfcn_tests_run(s);
79}
diff --git a/src/bin/evil/evil_test_dlfcn.h b/src/bin/evil/evil_test_dlfcn.h
deleted file mode 100644
index 0c9bce689e..0000000000
--- a/src/bin/evil/evil_test_dlfcn.h
+++ /dev/null
@@ -1,8 +0,0 @@
1#ifndef __EVIL_TEST_DLFCN_H__
2#define __EVIL_TEST_DLFCN_H__
3
4
5int test_dlfcn(suite *s);
6
7
8#endif /* __EVIL_TEST_DLFCN_H__ */
diff --git a/src/bin/evil/evil_test_environment.c b/src/bin/evil/evil_test_environment.c
deleted file mode 100644
index 0d31b7912a..0000000000
--- a/src/bin/evil/evil_test_environment.c
+++ /dev/null
@@ -1,178 +0,0 @@
1#ifdef HAVE_CONFIG_H
2# include "config.h"
3#endif /* HAVE_CONFIG_H */
4
5#include <string.h>
6
7#include <Evil.h>
8
9#include "evil_suite.h"
10#include "evil_test_environment.h"
11
12
13static int
14test_env_test_setenv_NULL(void)
15{
16 char *val;
17 int res;
18
19 res = setenv("EVIL_TEST_ENV", NULL, 1);
20 if (res < 0)
21 return 0;
22
23 val = getenv("EVIL_TEST_ENV");
24
25 return val ? 0 : 1;
26}
27
28static int
29test_env_test_setenv_NULL_after_set(void)
30{
31 char *val;
32 int res;
33
34 res = setenv("EVIL_TEST_ENV", "val", 1);
35 if (res < 0)
36 return 0;
37
38 val = getenv("EVIL_TEST_ENV");
39 if (!val)
40 return 0;
41
42 if (strcmp(val, "val"))
43 return 0;
44
45 res = setenv("EVIL_TEST_ENV", NULL, 1);
46 if (res < 0)
47 return 0;
48
49 val = getenv("EVIL_TEST_ENV");
50
51 return val ? 0 : 1;
52}
53
54static int
55test_env_test_getenv_one(void)
56{
57 char *val;
58 int res;
59
60 res = setenv("EVIL_TEST_ENV", "val", 1);
61 if (res < 0)
62 return 0;
63
64 val = getenv("EVIL_TEST_ENV");
65 if (!val)
66 return 0;
67
68 if (strcmp(val, "val"))
69 return 0;
70
71 return 1;
72}
73
74static int
75test_env_test_getenv_two(void)
76{
77 char *val;
78 int res;
79
80 res = setenv("EVIL_TEST_ENV1", "val1", 1);
81 if (res < 0)
82 return 0;
83
84 res = setenv("EVIL_TEST_ENV2", "val2", 1);
85 if (res < 0)
86 return 0;
87
88 val = getenv("EVIL_TEST_ENV1");
89 if (!val)
90 return 0;
91 if (strcmp(val, "val1"))
92 return 0;
93
94 val = getenv("EVIL_TEST_ENV2");
95 if (!val)
96 return 0;
97
98 if (strcmp(val, "val2"))
99 return 0;
100
101 return 1;
102}
103
104static int
105test_env_test_getenv_two_swapped(void)
106{
107 char *val;
108 int res;
109
110 res = setenv("EVIL_TEST_ENV1", "val1", 1);
111 if (res < 0)
112 return 0;
113
114 res = setenv("EVIL_TEST_ENV2", "val2", 1);
115 if (res < 0)
116 return 0;
117
118 val = getenv("EVIL_TEST_ENV2");
119 if (!val)
120 return 0;
121 if (strcmp(val, "val2"))
122 return 0;
123
124 val = getenv("EVIL_TEST_ENV1");
125 if (!val)
126 return 0;
127
128 if (strcmp(val, "val1"))
129 return 0;
130
131 return 1;
132}
133
134static int
135test_env_test_unsetenv(void)
136{
137 char *val;
138 int res;
139
140 res = setenv("EVIL_TEST_ENV", "val", 1);
141 if (res < 0)
142 return 0;
143
144 val = getenv("EVIL_TEST_ENV");
145 if (!val)
146 return 0;
147
148 if (unsetenv("EVIL_TEST_ENV") != 0)
149 return 0;
150
151 val = getenv("EVIL_TEST_ENV");
152 if (val)
153 return 0;
154
155 return 1;
156}
157
158static int
159test_env_tests_run(suite *s)
160{
161 int res;
162
163 res = test_env_test_setenv_NULL();
164 res &= test_env_test_setenv_NULL_after_set();
165 res &= test_env_test_getenv_one();
166 res &= test_env_test_getenv_two();
167 res &= test_env_test_getenv_two_swapped();
168 res &= test_env_test_unsetenv();
169
170 return res;
171}
172
173int
174test_environment(suite *s)
175{
176
177 return test_env_tests_run(s);
178}
diff --git a/src/bin/evil/evil_test_environment.h b/src/bin/evil/evil_test_environment.h
deleted file mode 100644
index 763ee401b1..0000000000
--- a/src/bin/evil/evil_test_environment.h
+++ /dev/null
@@ -1,8 +0,0 @@
1#ifndef __EVIL_TEST_ENVIRONMENT_H__
2#define __EVIL_TEST_ENVIRONMENT_H__
3
4
5int test_environment(suite *s);
6
7
8#endif /* __EVIL_TEST_ENVIRONMENT_H__ */
diff --git a/src/bin/evil/evil_test_gettimeofday.c b/src/bin/evil/evil_test_gettimeofday.c
deleted file mode 100644
index dc9656e83d..0000000000
--- a/src/bin/evil/evil_test_gettimeofday.c
+++ /dev/null
@@ -1,51 +0,0 @@
1#ifdef HAVE_CONFIG_H
2# include "config.h"
3#endif /* HAVE_CONFIG_H */
4
5#include <string.h>
6#include <math.h>
7#include <sys/time.h>
8
9#include <Evil.h>
10
11#include "evil_suite.h"
12#include "evil_test_gettimeofday.h"
13
14static int
15test_time_test_gettimeofday(void)
16{
17 struct timeval tp1;
18 struct timeval tp2;
19 double delta;
20
21 gettimeofday (&tp1, NULL);
22
23 Sleep(1000);
24
25 gettimeofday (&tp2, NULL);
26
27 delta = (double)(tp2.tv_sec - tp1.tv_sec) + (double)(tp2.tv_usec - tp1.tv_usec) / 1000000.0;
28 if (fabs(delta - 1) > 0.005)
29 {
30 return 0;
31 }
32
33 return 1;
34}
35
36static int
37test_time_tests_run(suite *s)
38{
39 int res;
40
41 res = test_time_test_gettimeofday();
42
43 return res;
44}
45
46int
47test_gettimeofday(suite *s)
48{
49
50 return test_time_tests_run(s);
51}
diff --git a/src/bin/evil/evil_test_gettimeofday.h b/src/bin/evil/evil_test_gettimeofday.h
deleted file mode 100644
index ad3155b146..0000000000
--- a/src/bin/evil/evil_test_gettimeofday.h
+++ /dev/null
@@ -1,8 +0,0 @@
1#ifndef __EVIL_TEST_GETTIMEOFDAY_H__
2#define __EVIL_TEST_GETTIMEOFDAY_H__
3
4
5int test_gettimeofday(suite *s);
6
7
8#endif /* __EVIL_TEST_GETTIMEOFDAY_H__ */
diff --git a/src/bin/evil/evil_test_mkstemp.c b/src/bin/evil/evil_test_mkstemp.c
deleted file mode 100644
index 54d9df5d17..0000000000
--- a/src/bin/evil/evil_test_mkstemp.c
+++ /dev/null
@@ -1,95 +0,0 @@
1#ifdef HAVE_CONFIG_H
2# include "config.h"
3#endif /* HAVE_CONFIG_H */
4
5#include <stdio.h>
6#include <string.h>
7
8#include <Evil.h>
9
10#include "evil_suite.h"
11#include "evil_test_mkstemp.h"
12
13
14static int
15test_mkstemp_test(void)
16{
17 char _template[PATH_MAX];
18#ifdef _WIN32_WCE
19 char cwd[PATH_MAX];
20#endif
21 int fd;
22
23#ifdef _WIN32_WCE
24 if (!getcwd(cwd, PATH_MAX))
25 return 0;
26 _snprintf(_template, PATH_MAX, "%s\\%s", cwd, "file_XXXXXX");
27#else
28 _snprintf(_template, PATH_MAX, "%s", "file_XXXXXX");
29#endif
30
31 fd = mkstemp(_template);
32
33 if (fd < 0)
34 return 0;
35
36 return 1;
37}
38
39static int
40test_mkstemps_test(void)
41{
42 char _template[PATH_MAX];
43#ifdef _WIN32_WCE
44 char cwd[PATH_MAX];
45#endif
46 int fd;
47
48#ifdef _WIN32_WCE
49 if (!getcwd(cwd, PATH_MAX))
50 return 0;
51 _snprintf(_template, PATH_MAX, "%s\\%s", cwd, "file_XXXXXX.ext");
52#else
53 _snprintf(_template, PATH_MAX, "%s", "file_XXXXXX.ext");
54#endif
55
56 fd = mkstemps(_template, 4);
57
58 if (fd < 0)
59 return 0;
60
61 return 1;
62}
63
64static int
65test_mkstemp_run(suite *s)
66{
67 int res;
68 (void) s;
69
70 res = test_mkstemp_test();
71
72 return res;
73}
74
75static int
76test_mkstemps_run(suite *s)
77{
78 int res;
79 (void) s;
80
81 res = test_mkstemps_test();
82
83 return res;
84}
85
86int
87test_mkstemp(suite *s)
88{
89 int res;
90
91 res = test_mkstemp_run(s);
92 res &= test_mkstemps_run(s);
93
94 return res;
95}
diff --git a/src/bin/evil/evil_test_mkstemp.h b/src/bin/evil/evil_test_mkstemp.h
deleted file mode 100644
index f5bb0c4270..0000000000
--- a/src/bin/evil/evil_test_mkstemp.h
+++ /dev/null
@@ -1,8 +0,0 @@
1#ifndef __EVIL_TEST_MKSTEMP_H__
2#define __EVIL_TEST_MKSTEMP_H__
3
4
5int test_mkstemp(suite *s);
6
7
8#endif /* __EVIL_TEST_MKSTEMP_H__ */
diff --git a/src/bin/evil/evil_test_print.c b/src/bin/evil/evil_test_print.c
deleted file mode 100644
index c775cfbefd..0000000000
--- a/src/bin/evil/evil_test_print.c
+++ /dev/null
@@ -1,46 +0,0 @@
1#ifdef HAVE_CONFIG_H
2# include "config.h"
3#endif /* HAVE_CONFIG_H */
4
5#include <stdlib.h>
6#include <stdio.h>
7
8#include <Evil.h>
9
10#include "evil_suite.h"
11#include "evil_test_print.h"
12
13static int
14test_print_test(void)
15{
16 char buf[16];
17 int i1 = 1;
18 size_t i2 = 123456;
19 int res;
20
21 res = printf("%02hhd\n", i1);
22 if (res != 3)
23 return 0;
24
25 res = snprintf(buf, sizeof(buf), "%zu", i2);
26 if (res != 6)
27 return 0;
28
29 return 1;
30}
31
32static int
33test_print_run(suite *s)
34{
35 int res;
36
37 res = test_print_test();
38
39 return res;
40}
41
42int
43test_print(suite *s)
44{
45 return test_print_run(s);
46}
diff --git a/src/bin/evil/evil_test_print.h b/src/bin/evil/evil_test_print.h
deleted file mode 100644
index 2bbf43904f..0000000000
--- a/src/bin/evil/evil_test_print.h
+++ /dev/null
@@ -1,8 +0,0 @@
1#ifndef __EVIL_TEST_PRINT_H__
2#define __EVIL_TEST_PRINT_H__
3
4
5int test_print(suite *s);
6
7
8#endif /* __EVIL_TEST_PRINT_H__ */
diff --git a/src/bin/evil/evil_test_realpath.c b/src/bin/evil/evil_test_realpath.c
deleted file mode 100644
index fbc4d1d570..0000000000
--- a/src/bin/evil/evil_test_realpath.c
+++ /dev/null
@@ -1,45 +0,0 @@
1#ifdef HAVE_CONFIG_H
2# include "config.h"
3#endif /* HAVE_CONFIG_H */
4
5#include <stdio.h>
6#include <string.h>
7
8#include <Evil.h>
9
10#include "evil_suite.h"
11#include "evil_test_realpath.h"
12
13
14static int
15test_realpath_test(void)
16{
17 char buf[PATH_MAX];
18 char *filename;
19 char *result;
20
21 filename = "evil_suite.exe";
22
23 if (!(result = realpath(filename, buf)))
24 return 0;
25
26 printf ("res : %s\n", buf);
27
28 return 1;
29}
30
31static int
32test_realpath_run(suite *s)
33{
34 int res;
35
36 res = test_realpath_test();
37
38 return res;
39}
40
41int
42test_realpath(suite *s)
43{
44 return test_realpath_run(s);
45}
diff --git a/src/bin/evil/evil_test_realpath.h b/src/bin/evil/evil_test_realpath.h
deleted file mode 100644
index 0205aad149..0000000000
--- a/src/bin/evil/evil_test_realpath.h
+++ /dev/null
@@ -1,8 +0,0 @@
1#ifndef __EVIL_TEST_REALPATH_H__
2#define __EVIL_TEST_REALPATH_H__
3
4
5int test_realpath(suite *s);
6
7
8#endif /* __EVIL_TEST_REALPATH_H__ */
diff --git a/src/bin/evil/test_evil.c b/src/bin/evil/test_evil.c
deleted file mode 100644
index 5b91172cb3..0000000000
--- a/src/bin/evil/test_evil.c
+++ /dev/null
@@ -1,27 +0,0 @@
1#include <stdlib.h>
2#include <stdio.h>
3#include <sys/time.h>
4
5#include <windows.h>
6
7
8
9int
10main()
11{
12 struct timeval tv;
13 double t1 = 0.0;
14 double t2 = 0.0;
15
16 if (gettimeofday(&tv, NULL) == 0)
17 t1 = tv.tv_sec + tv.tv_usec / 1000000.0;
18
19 Sleep(3000);
20
21 if (gettimeofday(&tv, NULL) == 0)
22 t2 = tv.tv_sec + tv.tv_usec / 1000000.0;
23
24 printf ("3 seconds ? %f\n", t2 - t1);
25
26 return EXIT_SUCCESS;
27}