jackdanielz pushed a commit to branch master.

http://git.enlightenment.org/tools/exactness.git/commit/?id=905a507ab06d6f7e7664cd2e3c76f312901640d0

commit 905a507ab06d6f7e7664cd2e3c76f312901640d0
Author: Daniel Zaoui <daniel.za...@samsung.com>
Date:   Thu Sep 29 08:00:00 2016 +0300

    Centralize run command string generation
    
    Most of this command is common to all the run modes.
---
 src/bin/run_test.c | 84 ++++++++++++++++++++++++++++++++++++------------------
 1 file changed, 56 insertions(+), 28 deletions(-)

diff --git a/src/bin/run_test.c b/src/bin/run_test.c
index 7fecdfc..e4fb79e 100644
--- a/src/bin/run_test.c
+++ b/src/bin/run_test.c
@@ -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);
 }

-- 


Reply via email to