Centralize run command string generation

Most of this command is common to all the run modes.
This commit is contained in:
Daniel Zaoui 2016-09-29 08:00:00 +03:00
parent 1ad03a2e49
commit 905a507ab0
1 changed files with 56 additions and 28 deletions

View File

@ -13,28 +13,68 @@
#define CONFIG "ELM_SCALE=1 ELM_FINGER_SIZE=10"
typedef enum
{
RUN_SIMULATION,
RUN_PLAY,
RUN_RECORD,
RUN_INIT
} Run_Mode;
static void
_run_command_prepare(const List_Entry *ent, Run_Mode mode, char *buf)
{
Eina_Strbuf *sbuf = eina_strbuf_new();
eina_strbuf_append_printf(sbuf, "TSUITE_VERBOSE=%d ", exactness_config.verbose);
eina_strbuf_append_printf(sbuf, "TSUITE_FILE_NAME='%s/%s.rec' ",
exactness_config.base_dir, ent->name);
eina_strbuf_append_printf(sbuf, "TSUITE_TEST_NAME='%s' ", ent->name);
switch (mode)
{
case RUN_SIMULATION:
{
eina_strbuf_append_printf(sbuf, "TSUITE_DEST_DIR='%s' ",
exactness_config.dest_dir);
break;
}
case RUN_PLAY:
{
eina_strbuf_append(sbuf, "ELM_ENGINE='buffer' ");
eina_strbuf_append_printf(sbuf, "TSUITE_DEST_DIR='%s/%s' ",
exactness_config.dest_dir, CURRENT_SUBDIR);
break;
}
case RUN_INIT:
{
eina_strbuf_append(sbuf, "ELM_ENGINE='buffer' ");
eina_strbuf_append_printf(sbuf, "TSUITE_DEST_DIR='%s/%s' ",
exactness_config.dest_dir, ORIG_SUBDIR);
break;
}
case RUN_RECORD:
{
eina_strbuf_append_printf(sbuf, "TSUITE_DEST_DIR='%s' ",
exactness_config.dest_dir);
eina_strbuf_append(sbuf, "TSUITE_RECORDING='rec' ");
break;
}
}
eina_strbuf_append_printf(sbuf, "LD_PRELOAD='%s' %s %s %s",
LIBEXACTNESS_PATH, CONFIG, exactness_config.wrap_command, ent->command);
strncpy(buf, eina_strbuf_string_get(sbuf), SCHEDULER_CMD_SIZE-1);
eina_strbuf_free(sbuf);
}
void
run_test_simulation(const List_Entry *ent, char *buf)
{
snprintf(buf, SCHEDULER_CMD_SIZE, "TSUITE_VERBOSE=%d TSUITE_DEST_DIR='%s' TSUITE_FILE_NAME='%s/%s.rec' TSUITE_TEST_NAME='%s' LD_PRELOAD='%s' %s %s %s",
exactness_config.verbose,
exactness_config.dest_dir,
exactness_config.base_dir, ent->name,
ent->name, LIBEXACTNESS_PATH, CONFIG,
exactness_config.wrap_command,
ent->command);
_run_command_prepare(ent, RUN_SIMULATION, buf);
}
void
run_test_play(const List_Entry *ent, char *buf)
{
snprintf(buf, SCHEDULER_CMD_SIZE, "TSUITE_VERBOSE=%d ELM_ENGINE='buffer' TSUITE_DEST_DIR='%s/" CURRENT_SUBDIR "' TSUITE_FILE_NAME='%s/%s.rec' TSUITE_TEST_NAME='%s' LD_PRELOAD='%s' %s %s %s",
exactness_config.verbose,
exactness_config.dest_dir,
exactness_config.base_dir, ent->name,
ent->name, LIBEXACTNESS_PATH, CONFIG,
exactness_config.wrap_command,
ent->command);
_run_command_prepare(ent, RUN_PLAY, buf);
run_test_prefix_rm(CURRENT_SUBDIR, ent->name);
if (exactness_config.verbose)
@ -46,25 +86,13 @@ run_test_play(const List_Entry *ent, char *buf)
void
run_test_record(const List_Entry *ent, char *buf)
{
snprintf(buf, SCHEDULER_CMD_SIZE, "TSUITE_VERBOSE=%d TSUITE_RECORDING='rec' TSUITE_DEST_DIR='%s' TSUITE_FILE_NAME='%s/%s.rec' TSUITE_TEST_NAME='%s' LD_PRELOAD='%s' %s %s %s",
exactness_config.verbose,
exactness_config.dest_dir,
exactness_config.base_dir, ent->name,
ent->name, LIBEXACTNESS_PATH, CONFIG,
exactness_config.wrap_command,
ent->command);
_run_command_prepare(ent, RUN_RECORD, buf);
}
void
run_test_init(const List_Entry *ent, char *buf)
{
snprintf(buf, SCHEDULER_CMD_SIZE, "TSUITE_VERBOSE=%d ELM_ENGINE='buffer' TSUITE_DEST_DIR='%s/" ORIG_SUBDIR "' TSUITE_FILE_NAME='%s/%s.rec' TSUITE_TEST_NAME='%s' LD_PRELOAD='%s' %s %s %s",
exactness_config.verbose,
exactness_config.dest_dir,
exactness_config.base_dir, ent->name,
ent->name, LIBEXACTNESS_PATH, CONFIG,
exactness_config.wrap_command,
ent->command);
_run_command_prepare(ent, RUN_INIT, buf);
run_test_prefix_rm(ORIG_SUBDIR, ent->name);
}