Suite: support multiple base directories

It is needed if, for example, rec and exu files are not stored in the
same place while an unique tests file is used.
master
Daniel Zaoui 4 years ago
parent d049f0cc2c
commit 1f063e3715
  1. 107
      src/bin/exactness.c

@ -29,10 +29,10 @@ typedef enum
RUN_INIT
} Run_Mode;
static unsigned short _running_jobs, _max_jobs;
static char *_base_dir;
static unsigned short _running_jobs = 0, _max_jobs = 1;
static Eina_List *_base_dirs = NULL;
static char *_dest_dir;
static char *_wrap_command;
static char *_wrap_command = NULL;
static int _verbose = 0;
static Eina_Bool _scan_objs = EINA_FALSE;
@ -57,14 +57,27 @@ _printf(int verbose, const char *fmt, ...)
}
#define CONFIG "ELM_SCALE=1 ELM_FINGER_SIZE=10"
static void
static Eina_Bool
_run_command_prepare(const List_Entry *ent, char *buf)
{
char scn_path[EXACTNESS_PATH_MAX];
Eina_Strbuf *sbuf = eina_strbuf_new();
sprintf(scn_path, "%s/%s.exu", _base_dir, ent->name);
if (!ecore_file_exists(scn_path))
sprintf(scn_path, "%s/%s.rec", _base_dir, ent->name);
Eina_Strbuf *sbuf;
const char *base_dir;
Eina_List *itr;
EINA_LIST_FOREACH(_base_dirs, itr, base_dir)
{
sprintf(scn_path, "%s/%s.exu", base_dir, ent->name);
if (ecore_file_exists(scn_path)) goto ok;
else
{
sprintf(scn_path, "%s/%s.rec", base_dir, ent->name);
if (ecore_file_exists(scn_path)) goto ok;
}
}
fprintf(stderr, "Test %s not found in the provided base directories\n", ent->name);
return EINA_FALSE;
ok:
sbuf = eina_strbuf_new();
eina_strbuf_append_printf(sbuf,
"%s %s exactness_play %s %s%.*s %s-t '%s' ",
CONFIG, _wrap_command ? _wrap_command : "",
@ -81,6 +94,7 @@ _run_command_prepare(const List_Entry *ent, char *buf)
strncpy(buf, eina_strbuf_string_get(sbuf), SCHEDULER_CMD_SIZE-1);
eina_strbuf_free(sbuf);
_printf(1, "Command: %s\n", buf);
return EINA_TRUE;
}
static Eina_Bool
@ -142,47 +156,46 @@ _job_consume()
{
static Ecore_Event_Handler *job_del_callback_handler = NULL;
char buf[SCHEDULER_CMD_SIZE];
Ecore_Exe *exe;
List_Entry *ent = _next_test_to_run;
if (_running_jobs == _max_jobs) return EINA_FALSE;
if (!ent) return EINA_FALSE;
_running_jobs++;
_tests_executed++;
_run_command_prepare(ent, buf);
switch (_mode)
if (_run_command_prepare(ent, buf))
{
case RUN_PLAY:
{
_run_test_prefix_rm(CURRENT_SUBDIR, ent->name);
_printf(1, "Running %s\n", ent->name);
break;
}
case RUN_INIT:
{
_run_test_prefix_rm(ORIG_SUBDIR, ent->name);
break;
}
default: break;
}
_running_jobs++;
_tests_executed++;
if (!job_del_callback_handler)
{
job_del_callback_handler = ecore_event_handler_add(ECORE_EXE_EVENT_DEL,
_job_deleted_cb, NULL);
}
switch (_mode)
{
case RUN_PLAY:
{
_run_test_prefix_rm(CURRENT_SUBDIR, ent->name);
_printf(1, "Running %s\n", ent->name);
break;
}
case RUN_INIT:
{
_run_test_prefix_rm(ORIG_SUBDIR, ent->name);
break;
}
default: break;
}
exe = ecore_exe_pipe_run(buf, ECORE_EXE_TERM_WITH_PARENT, ent);
if (!job_del_callback_handler)
{
job_del_callback_handler = ecore_event_handler_add(ECORE_EXE_EVENT_DEL,
_job_deleted_cb, NULL);
}
if (!ecore_exe_pipe_run(buf, ECORE_EXE_TERM_WITH_PARENT, ent))
{
fprintf(stderr, "Failed executing test '%s'\n", ent->name);
}
}
_next_test_to_run = EINA_INLIST_CONTAINER_GET(
EINA_INLIST_GET(ent)->next, List_Entry);
if (!exe)
{
fprintf(stderr, "Failed executing test '%s'\n", ent->name);
}
return EINA_TRUE;
}
@ -361,7 +374,7 @@ static const Ecore_Getopt optdesc = {
"A pixel perfect test suite for EFL based applications.",
0,
{
ECORE_GETOPT_STORE_STR('b', "base-dir", "The location of the exu/rec files."),
ECORE_GETOPT_APPEND('b', "base-dir", "The location of the exu/rec files.", ECORE_GETOPT_TYPE_STR),
ECORE_GETOPT_STORE_STR('o', "output", "The location of the images."),
ECORE_GETOPT_STORE_STR('w', "wrap", "Use a custom command to launch the tests (e.g valgrind)."),
ECORE_GETOPT_STORE_USHORT('j', "jobs", "The number of jobs to run in parallel."),
@ -385,12 +398,14 @@ main(int argc, char *argv[])
int ret = 0;
List_Entry *test_list;
int args = 0;
const char *list_file = "";
const char *list_file;
Eina_List *itr;
const char *base_dir;
char tmp[EXACTNESS_PATH_MAX];
Eina_Bool mode_play = EINA_FALSE, mode_init = EINA_FALSE, mode_simulation = EINA_FALSE;
Eina_Bool want_quit = EINA_FALSE, scan_objs = EINA_FALSE;
Ecore_Getopt_Value values[] = {
ECORE_GETOPT_VALUE_STR(_base_dir),
ECORE_GETOPT_VALUE_LIST(_base_dirs),
ECORE_GETOPT_VALUE_STR(_dest_dir),
ECORE_GETOPT_VALUE_STR(_wrap_command),
ECORE_GETOPT_VALUE_USHORT(_max_jobs),
@ -410,11 +425,7 @@ main(int argc, char *argv[])
ecore_init();
mode_play = mode_init = mode_simulation = EINA_FALSE;
want_quit = EINA_FALSE;
_base_dir = "./recordings";
_dest_dir = "./";
_wrap_command = "";
_max_jobs = 1;
_verbose = 0;
_scan_objs = scan_objs;
args = ecore_getopt_parse(&optdesc, values, argc, argv);
@ -444,8 +455,9 @@ main(int argc, char *argv[])
goto end;
}
list_file = argv[args];
if (!_base_dirs) _base_dirs = eina_list_append(NULL, "./recordings");
list_file = argv[args];
/* Load the list file and start iterating over the records. */
test_list = _list_file_load(list_file);
@ -462,7 +474,9 @@ main(int argc, char *argv[])
fprintf(stderr, "Running with settings:\n");
fprintf(stderr, "\tConcurrent jobs: %d\n", _max_jobs);
fprintf(stderr, "\tTest list: %s\n", list_file);
fprintf(stderr, "\tBase dir: %s\n", _base_dir);
fprintf(stderr, "\tBase dirs:\n");
EINA_LIST_FOREACH(_base_dirs, itr, base_dir)
fprintf(stderr, "\t\t%s\n", base_dir);
fprintf(stderr, "\tDest dir: %s\n", _dest_dir);
if (mode_play)
@ -538,7 +552,6 @@ main(int argc, char *argv[])
{
fprintf(report_file,
"<h1>Tests that failed execution:</h1><ul>");
Eina_List *itr;
List_Entry *ent;
printf("List of tests that failed execution:\n");
EINA_LIST_FOREACH(_errors, itr, ent)

Loading…
Cancel
Save