From 3b0876902c587ab030e2c2ee8e03197e17a259cb Mon Sep 17 00:00:00 2001 From: Vincent Torri Date: Wed, 31 Jan 2018 13:35:03 +0100 Subject: [PATCH] evil: remove useless binary tests Signed-off-by: Cedric Bail --- src/Makefile_Evil.am | 18 +--- src/bin/evil/evil_suite.c | 19 +--- src/bin/evil/evil_test_dlfcn.c | 79 --------------- src/bin/evil/evil_test_dlfcn.h | 8 -- src/bin/evil/evil_test_environment.c | 178 ---------------------------------- src/bin/evil/evil_test_environment.h | 8 -- src/bin/evil/evil_test_gettimeofday.c | 51 ---------- src/bin/evil/evil_test_gettimeofday.h | 8 -- src/bin/evil/evil_test_mkstemp.c | 95 ------------------ src/bin/evil/evil_test_mkstemp.h | 8 -- src/bin/evil/evil_test_print.c | 46 --------- src/bin/evil/evil_test_print.h | 8 -- src/bin/evil/evil_test_realpath.c | 45 --------- src/bin/evil/evil_test_realpath.h | 8 -- src/bin/evil/test_evil.c | 27 ------ 15 files changed, 4 insertions(+), 602 deletions(-) delete mode 100644 src/bin/evil/evil_test_dlfcn.c delete mode 100644 src/bin/evil/evil_test_dlfcn.h delete mode 100644 src/bin/evil/evil_test_environment.c delete mode 100644 src/bin/evil/evil_test_environment.h delete mode 100644 src/bin/evil/evil_test_gettimeofday.c delete mode 100644 src/bin/evil/evil_test_gettimeofday.h delete mode 100644 src/bin/evil/evil_test_mkstemp.c delete mode 100644 src/bin/evil/evil_test_mkstemp.h delete mode 100644 src/bin/evil/evil_test_print.c delete mode 100644 src/bin/evil/evil_test_print.h delete mode 100644 src/bin/evil/evil_test_realpath.c delete mode 100644 src/bin/evil/evil_test_realpath.h delete mode 100644 src/bin/evil/test_evil.c diff --git a/src/Makefile_Evil.am b/src/Makefile_Evil.am index 300254f..95c6344 100644 --- a/src/Makefile_Evil.am +++ b/src/Makefile_Evil.am @@ -74,36 +74,20 @@ lib_evil_libevil_la_CPPFLAGS += \ ### Binary -bin_PROGRAMS += bin/evil/evil_suite bin/evil/test_evil +bin_PROGRAMS += bin/evil/evil_suite bin_evil_evil_suite_SOURCES = \ bin/evil/evil_suite.c \ -bin/evil/evil_test_dlfcn.c \ -bin/evil/evil_test_environment.c \ -bin/evil/evil_test_gettimeofday.c \ -bin/evil/evil_test_mkstemp.c \ bin/evil/evil_test_pipe.c \ -bin/evil/evil_test_print.c \ -bin/evil/evil_test_realpath.c \ bin/evil/evil_test_util.c \ bin/evil/evil_suite.h \ -bin/evil/evil_test_dlfcn.h \ -bin/evil/evil_test_environment.h \ -bin/evil/evil_test_gettimeofday.h \ -bin/evil/evil_test_mkstemp.h \ bin/evil/evil_test_pipe.h \ -bin/evil/evil_test_print.h \ -bin/evil/evil_test_realpath.h \ bin/evil/evil_test_util.h bin_evil_evil_suite_CPPFLAGS = -I$(top_builddir)/src/lib/efl @EVIL_CFLAGS@ bin_evil_evil_suite_LDADD = @USE_EVIL_LIBS@ -lm bin_evil_evil_suite_DEPENDENCIES = @USE_EVIL_INTERNAL_LIBS@ -bin_evil_test_evil_SOURCES = bin/evil/test_evil.c -bin_evil_test_evil_LDADD = @USE_EVIL_LIBS@ -bin_evil_test_evil_DEPENDENCIES = @USE_EVIL_INTERNAL_LIBS@ - ### Unit tests if EFL_ENABLE_TESTS diff --git a/src/bin/evil/evil_suite.c b/src/bin/evil/evil_suite.c index 6202fb4..aa2e7f3 100644 --- a/src/bin/evil/evil_suite.c +++ b/src/bin/evil/evil_suite.c @@ -11,13 +11,7 @@ #include "Evil.h" #include "evil_suite.h" -#include "evil_test_dlfcn.h" -#include "evil_test_environment.h" -#include "evil_test_gettimeofday.h" -#include "evil_test_mkstemp.h" #include "evil_test_pipe.h" -#include "evil_test_print.h" -#include "evil_test_realpath.h" #include "evil_test_util.h" @@ -178,16 +172,9 @@ int main(void) { test tests[] = { - { "dlfcn ", test_dlfcn }, - { "environment ", test_environment }, - { "gettimeofday", test_gettimeofday }, - { "mkstemp ", test_mkstemp }, - { "pipe ", test_pipe }, - { "print ", test_print }, - { "realpath ", test_realpath }, - { "util ", test_util }, -/* { "memcpy ", test_memcpy }, */ - { NULL, NULL }, + { "pipe ", test_pipe }, + { "util ", test_util }, + { NULL, NULL }, }; suite *s; 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 605f5c4..0000000 --- a/src/bin/evil/evil_test_dlfcn.c +++ /dev/null @@ -1,79 +0,0 @@ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif /* HAVE_CONFIG_H */ - -#include - -#include - -#include "evil_suite.h" -#include "evil_test_dlfcn.h" - - -typedef int (*_evil_init)(void); -typedef int (*_evil_shutdwon)(void); - - -static int -test_dlfcn_test_dlopen(void) -{ - void *handle; - - handle = dlopen("libevil-1.dll", 0); - if (!handle) - return 0; - - if (dlclose(handle)) - return 0; - - return 1; -} - -static int -test_dlfcn_test_dlsym(void) -{ - void *handle; - _evil_init sym_init; - _evil_shutdwon sym_shutdown; - - handle = dlopen("libevil-1.dll", 0); - if (!handle) - return 0; - - sym_init = dlsym(handle, "evil_init"); - if (!sym_init) - { - dlclose(handle); - return 0; - } - - sym_shutdown = dlsym(handle, "evil_shutdown"); - if (!sym_shutdown) - { - dlclose(handle); - return 0; - } - - if (dlclose(handle)) - return 0; - - return 1; -} - -static int -test_dlfcn_tests_run(suite *s) -{ - int res; - - res = test_dlfcn_test_dlopen(); - res &= test_dlfcn_test_dlsym(); - - return res; -} - -int -test_dlfcn(suite *s) -{ - - return test_dlfcn_tests_run(s); -} diff --git a/src/bin/evil/evil_test_dlfcn.h b/src/bin/evil/evil_test_dlfcn.h deleted file mode 100644 index 0c9bce6..0000000 --- a/src/bin/evil/evil_test_dlfcn.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef __EVIL_TEST_DLFCN_H__ -#define __EVIL_TEST_DLFCN_H__ - - -int test_dlfcn(suite *s); - - -#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 0d31b79..0000000 --- a/src/bin/evil/evil_test_environment.c +++ /dev/null @@ -1,178 +0,0 @@ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif /* HAVE_CONFIG_H */ - -#include - -#include - -#include "evil_suite.h" -#include "evil_test_environment.h" - - -static int -test_env_test_setenv_NULL(void) -{ - char *val; - int res; - - res = setenv("EVIL_TEST_ENV", NULL, 1); - if (res < 0) - return 0; - - val = getenv("EVIL_TEST_ENV"); - - return val ? 0 : 1; -} - -static int -test_env_test_setenv_NULL_after_set(void) -{ - char *val; - int res; - - res = setenv("EVIL_TEST_ENV", "val", 1); - if (res < 0) - return 0; - - val = getenv("EVIL_TEST_ENV"); - if (!val) - return 0; - - if (strcmp(val, "val")) - return 0; - - res = setenv("EVIL_TEST_ENV", NULL, 1); - if (res < 0) - return 0; - - val = getenv("EVIL_TEST_ENV"); - - return val ? 0 : 1; -} - -static int -test_env_test_getenv_one(void) -{ - char *val; - int res; - - res = setenv("EVIL_TEST_ENV", "val", 1); - if (res < 0) - return 0; - - val = getenv("EVIL_TEST_ENV"); - if (!val) - return 0; - - if (strcmp(val, "val")) - return 0; - - return 1; -} - -static int -test_env_test_getenv_two(void) -{ - char *val; - int res; - - res = setenv("EVIL_TEST_ENV1", "val1", 1); - if (res < 0) - return 0; - - res = setenv("EVIL_TEST_ENV2", "val2", 1); - if (res < 0) - return 0; - - val = getenv("EVIL_TEST_ENV1"); - if (!val) - return 0; - if (strcmp(val, "val1")) - return 0; - - val = getenv("EVIL_TEST_ENV2"); - if (!val) - return 0; - - if (strcmp(val, "val2")) - return 0; - - return 1; -} - -static int -test_env_test_getenv_two_swapped(void) -{ - char *val; - int res; - - res = setenv("EVIL_TEST_ENV1", "val1", 1); - if (res < 0) - return 0; - - res = setenv("EVIL_TEST_ENV2", "val2", 1); - if (res < 0) - return 0; - - val = getenv("EVIL_TEST_ENV2"); - if (!val) - return 0; - if (strcmp(val, "val2")) - return 0; - - val = getenv("EVIL_TEST_ENV1"); - if (!val) - return 0; - - if (strcmp(val, "val1")) - return 0; - - return 1; -} - -static int -test_env_test_unsetenv(void) -{ - char *val; - int res; - - res = setenv("EVIL_TEST_ENV", "val", 1); - if (res < 0) - return 0; - - val = getenv("EVIL_TEST_ENV"); - if (!val) - return 0; - - if (unsetenv("EVIL_TEST_ENV") != 0) - return 0; - - val = getenv("EVIL_TEST_ENV"); - if (val) - return 0; - - return 1; -} - -static int -test_env_tests_run(suite *s) -{ - int res; - - res = test_env_test_setenv_NULL(); - res &= test_env_test_setenv_NULL_after_set(); - res &= test_env_test_getenv_one(); - res &= test_env_test_getenv_two(); - res &= test_env_test_getenv_two_swapped(); - res &= test_env_test_unsetenv(); - - return res; -} - -int -test_environment(suite *s) -{ - - return test_env_tests_run(s); -} diff --git a/src/bin/evil/evil_test_environment.h b/src/bin/evil/evil_test_environment.h deleted file mode 100644 index 763ee40..0000000 --- a/src/bin/evil/evil_test_environment.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef __EVIL_TEST_ENVIRONMENT_H__ -#define __EVIL_TEST_ENVIRONMENT_H__ - - -int test_environment(suite *s); - - -#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 dc9656e..0000000 --- a/src/bin/evil/evil_test_gettimeofday.c +++ /dev/null @@ -1,51 +0,0 @@ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif /* HAVE_CONFIG_H */ - -#include -#include -#include - -#include - -#include "evil_suite.h" -#include "evil_test_gettimeofday.h" - -static int -test_time_test_gettimeofday(void) -{ - struct timeval tp1; - struct timeval tp2; - double delta; - - gettimeofday (&tp1, NULL); - - Sleep(1000); - - gettimeofday (&tp2, NULL); - - delta = (double)(tp2.tv_sec - tp1.tv_sec) + (double)(tp2.tv_usec - tp1.tv_usec) / 1000000.0; - if (fabs(delta - 1) > 0.005) - { - return 0; - } - - return 1; -} - -static int -test_time_tests_run(suite *s) -{ - int res; - - res = test_time_test_gettimeofday(); - - return res; -} - -int -test_gettimeofday(suite *s) -{ - - return test_time_tests_run(s); -} diff --git a/src/bin/evil/evil_test_gettimeofday.h b/src/bin/evil/evil_test_gettimeofday.h deleted file mode 100644 index ad3155b..0000000 --- a/src/bin/evil/evil_test_gettimeofday.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef __EVIL_TEST_GETTIMEOFDAY_H__ -#define __EVIL_TEST_GETTIMEOFDAY_H__ - - -int test_gettimeofday(suite *s); - - -#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 54d9df5..0000000 --- a/src/bin/evil/evil_test_mkstemp.c +++ /dev/null @@ -1,95 +0,0 @@ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif /* HAVE_CONFIG_H */ - -#include -#include - -#include - -#include "evil_suite.h" -#include "evil_test_mkstemp.h" - - -static int -test_mkstemp_test(void) -{ - char _template[PATH_MAX]; -#ifdef _WIN32_WCE - char cwd[PATH_MAX]; -#endif - int fd; - -#ifdef _WIN32_WCE - if (!getcwd(cwd, PATH_MAX)) - return 0; - _snprintf(_template, PATH_MAX, "%s\\%s", cwd, "file_XXXXXX"); -#else - _snprintf(_template, PATH_MAX, "%s", "file_XXXXXX"); -#endif - - fd = mkstemp(_template); - - if (fd < 0) - return 0; - - return 1; -} - -static int -test_mkstemps_test(void) -{ - char _template[PATH_MAX]; -#ifdef _WIN32_WCE - char cwd[PATH_MAX]; -#endif - int fd; - -#ifdef _WIN32_WCE - if (!getcwd(cwd, PATH_MAX)) - return 0; - _snprintf(_template, PATH_MAX, "%s\\%s", cwd, "file_XXXXXX.ext"); -#else - _snprintf(_template, PATH_MAX, "%s", "file_XXXXXX.ext"); -#endif - - fd = mkstemps(_template, 4); - - if (fd < 0) - return 0; - - return 1; -} - -static int -test_mkstemp_run(suite *s) -{ - int res; - (void) s; - - res = test_mkstemp_test(); - - return res; -} - -static int -test_mkstemps_run(suite *s) -{ - int res; - (void) s; - - res = test_mkstemps_test(); - - return res; -} - -int -test_mkstemp(suite *s) -{ - int res; - - res = test_mkstemp_run(s); - res &= test_mkstemps_run(s); - - return res; -} diff --git a/src/bin/evil/evil_test_mkstemp.h b/src/bin/evil/evil_test_mkstemp.h deleted file mode 100644 index f5bb0c4..0000000 --- a/src/bin/evil/evil_test_mkstemp.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef __EVIL_TEST_MKSTEMP_H__ -#define __EVIL_TEST_MKSTEMP_H__ - - -int test_mkstemp(suite *s); - - -#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 c775cfb..0000000 --- a/src/bin/evil/evil_test_print.c +++ /dev/null @@ -1,46 +0,0 @@ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif /* HAVE_CONFIG_H */ - -#include -#include - -#include - -#include "evil_suite.h" -#include "evil_test_print.h" - -static int -test_print_test(void) -{ - char buf[16]; - int i1 = 1; - size_t i2 = 123456; - int res; - - res = printf("%02hhd\n", i1); - if (res != 3) - return 0; - - res = snprintf(buf, sizeof(buf), "%zu", i2); - if (res != 6) - return 0; - - return 1; -} - -static int -test_print_run(suite *s) -{ - int res; - - res = test_print_test(); - - return res; -} - -int -test_print(suite *s) -{ - return test_print_run(s); -} diff --git a/src/bin/evil/evil_test_print.h b/src/bin/evil/evil_test_print.h deleted file mode 100644 index 2bbf439..0000000 --- a/src/bin/evil/evil_test_print.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef __EVIL_TEST_PRINT_H__ -#define __EVIL_TEST_PRINT_H__ - - -int test_print(suite *s); - - -#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 fbc4d1d..0000000 --- a/src/bin/evil/evil_test_realpath.c +++ /dev/null @@ -1,45 +0,0 @@ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif /* HAVE_CONFIG_H */ - -#include -#include - -#include - -#include "evil_suite.h" -#include "evil_test_realpath.h" - - -static int -test_realpath_test(void) -{ - char buf[PATH_MAX]; - char *filename; - char *result; - - filename = "evil_suite.exe"; - - if (!(result = realpath(filename, buf))) - return 0; - - printf ("res : %s\n", buf); - - return 1; -} - -static int -test_realpath_run(suite *s) -{ - int res; - - res = test_realpath_test(); - - return res; -} - -int -test_realpath(suite *s) -{ - return test_realpath_run(s); -} diff --git a/src/bin/evil/evil_test_realpath.h b/src/bin/evil/evil_test_realpath.h deleted file mode 100644 index 0205aad..0000000 --- a/src/bin/evil/evil_test_realpath.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef __EVIL_TEST_REALPATH_H__ -#define __EVIL_TEST_REALPATH_H__ - - -int test_realpath(suite *s); - - -#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 5b91172..0000000 --- a/src/bin/evil/test_evil.c +++ /dev/null @@ -1,27 +0,0 @@ -#include -#include -#include - -#include - - - -int -main() -{ - struct timeval tv; - double t1 = 0.0; - double t2 = 0.0; - - if (gettimeofday(&tv, NULL) == 0) - t1 = tv.tv_sec + tv.tv_usec / 1000000.0; - - Sleep(3000); - - if (gettimeofday(&tv, NULL) == 0) - t2 = tv.tv_sec + tv.tv_usec / 1000000.0; - - printf ("3 seconds ? %f\n", t2 - t1); - - return EXIT_SUCCESS; -} -- 2.7.4