186 lines
5.1 KiB
C
186 lines
5.1 KiB
C
|
#include <Ecore.h>
|
||
|
#include <Ecore_Getopt.h>
|
||
|
|
||
|
#include "list_file.h"
|
||
|
#include "exactness_config.h"
|
||
|
#include "run_test.h"
|
||
|
#include "scheduler.h"
|
||
|
|
||
|
#include "config.h"
|
||
|
|
||
|
static const Ecore_Getopt optdesc = {
|
||
|
"exactness",
|
||
|
"%prog [options] <-r|-p|-i|-s> <list file>",
|
||
|
PACKAGE_VERSION,
|
||
|
"(C) 2013 Enlightenment",
|
||
|
"BSD",
|
||
|
"A pixel perfect test suite for EFL based applications.",
|
||
|
0,
|
||
|
{
|
||
|
ECORE_GETOPT_STORE_STR('b', "base-dir", "The location of the rec files."),
|
||
|
ECORE_GETOPT_STORE_STR('d', "dest-dir", "The location of the images."),
|
||
|
ECORE_GETOPT_STORE_USHORT('j', "jobs", "The number of jobs to run in parallel."),
|
||
|
ECORE_GETOPT_STORE_TRUE('r', "record", "Run in record mode."),
|
||
|
ECORE_GETOPT_STORE_TRUE('p', "play", "Run in play mode."),
|
||
|
ECORE_GETOPT_STORE_TRUE('i', "init", "Run in init mode."),
|
||
|
ECORE_GETOPT_STORE_TRUE('s', "simulation", "Run in simulation mode."),
|
||
|
ECORE_GETOPT_STORE_TRUE('v', "verbose", "Turn verbose messages on."),
|
||
|
|
||
|
ECORE_GETOPT_LICENSE('L', "license"),
|
||
|
ECORE_GETOPT_COPYRIGHT('C', "copyright"),
|
||
|
ECORE_GETOPT_VERSION('V', "version"),
|
||
|
ECORE_GETOPT_HELP('h', "help"),
|
||
|
ECORE_GETOPT_SENTINEL
|
||
|
}
|
||
|
};
|
||
|
|
||
|
int
|
||
|
main(int argc, char *argv[])
|
||
|
{
|
||
|
int ret = 0;
|
||
|
List_Entry *test_list;
|
||
|
int args = 0;
|
||
|
const char *list_file = "";
|
||
|
Eina_Bool mode_record, mode_play, mode_init, mode_simulation;
|
||
|
Eina_Bool want_quit;
|
||
|
Ecore_Getopt_Value values[] = {
|
||
|
ECORE_GETOPT_VALUE_STR(exactness_config.base_dir),
|
||
|
ECORE_GETOPT_VALUE_STR(exactness_config.dest_dir),
|
||
|
ECORE_GETOPT_VALUE_USHORT(exactness_config.jobs),
|
||
|
ECORE_GETOPT_VALUE_BOOL(mode_record),
|
||
|
ECORE_GETOPT_VALUE_BOOL(mode_play),
|
||
|
ECORE_GETOPT_VALUE_BOOL(mode_init),
|
||
|
ECORE_GETOPT_VALUE_BOOL(mode_simulation),
|
||
|
ECORE_GETOPT_VALUE_BOOL(exactness_config.verbose),
|
||
|
|
||
|
ECORE_GETOPT_VALUE_BOOL(want_quit),
|
||
|
ECORE_GETOPT_VALUE_BOOL(want_quit),
|
||
|
ECORE_GETOPT_VALUE_BOOL(want_quit),
|
||
|
ECORE_GETOPT_VALUE_BOOL(want_quit),
|
||
|
ECORE_GETOPT_VALUE_NONE
|
||
|
};
|
||
|
|
||
|
ecore_init();
|
||
|
mode_record = mode_play = mode_init = mode_simulation = EINA_FALSE;
|
||
|
want_quit = EINA_FALSE;
|
||
|
exactness_config.base_dir = PACKAGE_DATADIR "/exactness/recordings";
|
||
|
exactness_config.dest_dir = "./";
|
||
|
exactness_config.jobs = 1;
|
||
|
exactness_config.verbose = EINA_FALSE;
|
||
|
|
||
|
args = ecore_getopt_parse(&optdesc, values, argc, argv);
|
||
|
if (args < 0)
|
||
|
{
|
||
|
fprintf(stderr, "Failed parsing arguments.\n");
|
||
|
ret = 1;
|
||
|
goto end;
|
||
|
}
|
||
|
else if (want_quit)
|
||
|
{
|
||
|
ret = 1;
|
||
|
goto end;
|
||
|
}
|
||
|
else if (args == argc)
|
||
|
{
|
||
|
fprintf(stderr, "Expected test list as the last argument..\n");
|
||
|
ecore_getopt_help(stderr, &optdesc);
|
||
|
ret = 1;
|
||
|
goto end;
|
||
|
}
|
||
|
else if (mode_record + mode_play + mode_init + mode_simulation != 1)
|
||
|
{
|
||
|
fprintf(stderr, "At least and only one of the running modes can be set.\n");
|
||
|
ecore_getopt_help(stderr, &optdesc);
|
||
|
ret = 1;
|
||
|
goto end;
|
||
|
}
|
||
|
|
||
|
list_file = argv[args];
|
||
|
|
||
|
|
||
|
/* Load the list file and start iterating over the records. */
|
||
|
test_list = list_file_load(list_file);
|
||
|
|
||
|
if (!test_list)
|
||
|
{
|
||
|
fprintf(stderr, "No matching tests found in '%s'\n", list_file);
|
||
|
ret = 1;
|
||
|
goto end;
|
||
|
}
|
||
|
|
||
|
/* Pre-run summary */
|
||
|
fprintf(stderr, "Running with settings:\n");
|
||
|
fprintf(stderr, "\tConcurrent jobs: %d\n", exactness_config.jobs);
|
||
|
fprintf(stderr, "\tTest list: %s\n", list_file);
|
||
|
fprintf(stderr, "\tBase dir: %s\n", exactness_config.base_dir);
|
||
|
fprintf(stderr, "\tDest dir: %s\n", exactness_config.dest_dir);
|
||
|
|
||
|
if (mode_record)
|
||
|
{
|
||
|
scheduler_run(run_test_record, test_list);
|
||
|
}
|
||
|
else if (mode_play)
|
||
|
{
|
||
|
mkdir(CURRENT_SUBDIR, 0744);
|
||
|
scheduler_run(run_test_play, test_list);
|
||
|
}
|
||
|
else if (mode_init)
|
||
|
{
|
||
|
mkdir(ORIG_SUBDIR, 0744);
|
||
|
scheduler_run(run_test_init, test_list);
|
||
|
}
|
||
|
else if (mode_simulation)
|
||
|
{
|
||
|
scheduler_run(run_test_simulation, test_list);
|
||
|
}
|
||
|
|
||
|
|
||
|
ecore_main_loop_begin();
|
||
|
|
||
|
/* Results */
|
||
|
printf("*******************************************************\n");
|
||
|
if (mode_play)
|
||
|
{
|
||
|
List_Entry *list_itr;
|
||
|
|
||
|
EINA_INLIST_FOREACH(test_list, list_itr)
|
||
|
{
|
||
|
run_test_compare(list_itr);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
printf("Finished executing %u out of %u tests.\n",
|
||
|
exactness_ctx.tests_executed,
|
||
|
eina_inlist_count(EINA_INLIST_GET(test_list)));
|
||
|
|
||
|
if (exactness_ctx.errors)
|
||
|
{
|
||
|
Eina_List *itr;
|
||
|
List_Entry *ent;
|
||
|
printf("List of tests that failed execution:\n");
|
||
|
EINA_LIST_FOREACH(exactness_ctx.errors, itr, ent)
|
||
|
{
|
||
|
printf("\t* %s\n", ent->name);
|
||
|
}
|
||
|
ret = 1;
|
||
|
}
|
||
|
|
||
|
if (exactness_ctx.compare_errors)
|
||
|
{
|
||
|
char *test_name;
|
||
|
printf("List of images that failed comparison:\n");
|
||
|
EINA_LIST_FREE(exactness_ctx.compare_errors, test_name)
|
||
|
{
|
||
|
printf("\t* %s\n", test_name);
|
||
|
free(test_name);
|
||
|
}
|
||
|
ret = 1;
|
||
|
}
|
||
|
|
||
|
list_file_free(test_list);
|
||
|
end:
|
||
|
ecore_shutdown();
|
||
|
|
||
|
return ret;
|
||
|
}
|