evil: remove useless binary tests

Signed-off-by: Cedric Bail <cedric@osg.samsung.com>
This commit is contained in:
Vincent Torri 2018-01-31 13:35:03 +01:00 committed by Cedric Bail
parent a6d0e787e4
commit b464ffb679
15 changed files with 4 additions and 602 deletions

View File

@ -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

View File

@ -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;

View File

@ -1,79 +0,0 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif /* HAVE_CONFIG_H */
#include <string.h>
#include <Evil.h>
#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);
}

View File

@ -1,8 +0,0 @@
#ifndef __EVIL_TEST_DLFCN_H__
#define __EVIL_TEST_DLFCN_H__
int test_dlfcn(suite *s);
#endif /* __EVIL_TEST_DLFCN_H__ */

View File

@ -1,178 +0,0 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif /* HAVE_CONFIG_H */
#include <string.h>
#include <Evil.h>
#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);
}

View File

@ -1,8 +0,0 @@
#ifndef __EVIL_TEST_ENVIRONMENT_H__
#define __EVIL_TEST_ENVIRONMENT_H__
int test_environment(suite *s);
#endif /* __EVIL_TEST_ENVIRONMENT_H__ */

View File

@ -1,51 +0,0 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif /* HAVE_CONFIG_H */
#include <string.h>
#include <math.h>
#include <sys/time.h>
#include <Evil.h>
#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);
}

View File

@ -1,8 +0,0 @@
#ifndef __EVIL_TEST_GETTIMEOFDAY_H__
#define __EVIL_TEST_GETTIMEOFDAY_H__
int test_gettimeofday(suite *s);
#endif /* __EVIL_TEST_GETTIMEOFDAY_H__ */

View File

@ -1,95 +0,0 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif /* HAVE_CONFIG_H */
#include <stdio.h>
#include <string.h>
#include <Evil.h>
#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;
}

View File

@ -1,8 +0,0 @@
#ifndef __EVIL_TEST_MKSTEMP_H__
#define __EVIL_TEST_MKSTEMP_H__
int test_mkstemp(suite *s);
#endif /* __EVIL_TEST_MKSTEMP_H__ */

View File

@ -1,46 +0,0 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif /* HAVE_CONFIG_H */
#include <stdlib.h>
#include <stdio.h>
#include <Evil.h>
#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);
}

View File

@ -1,8 +0,0 @@
#ifndef __EVIL_TEST_PRINT_H__
#define __EVIL_TEST_PRINT_H__
int test_print(suite *s);
#endif /* __EVIL_TEST_PRINT_H__ */

View File

@ -1,45 +0,0 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif /* HAVE_CONFIG_H */
#include <stdio.h>
#include <string.h>
#include <Evil.h>
#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);
}

View File

@ -1,8 +0,0 @@
#ifndef __EVIL_TEST_REALPATH_H__
#define __EVIL_TEST_REALPATH_H__
int test_realpath(suite *s);
#endif /* __EVIL_TEST_REALPATH_H__ */

View File

@ -1,27 +0,0 @@
#include <stdlib.h>
#include <stdio.h>
#include <sys/time.h>
#include <windows.h>
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;
}