Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add an option on tesh to ignore output of code coverage.
authorNavarrop <Pierre.Navarro@imag.fr>
Tue, 4 Oct 2011 15:55:24 +0000 (17:55 +0200)
committerNavarrop <Pierre.Navarro@imag.fr>
Tue, 4 Oct 2011 15:55:24 +0000 (17:55 +0200)
--enable-coverage

tools/tesh/run_context.c
tools/tesh/tesh.c
tools/tesh/tesh.h

index 60b38bf..3d3aeb6 100644 (file)
@@ -796,19 +796,38 @@ void *rctx_wait(void *r)
     errcode = 1;
   }
 
-  if (rctx->output_sort) {
-    xbt_dynar_t a = xbt_str_split(rctx->output_got->data, "\n");
-    xbt_dynar_sort(a,cmpstringp);
-    char *sorted_output = xbt_str_join(a, "\n");
-    strcpy(rctx->output_got->data, sorted_output);
-    xbt_free(sorted_output);
-    xbt_dynar_free(&a);
-    /* If an empty line moved in first position, move it back to the end */
-    if (rctx->output_got->data[0]=='\n') {
-      memmove(rctx->output_got->data,rctx->output_got->data+1,rctx->output_got->used-1);
-      rctx->output_got->data[rctx->output_got->used-1] = '\n';
-    }
-  }
+       if(rctx->output_sort || coverage){
+       xbt_dynar_t a = xbt_str_split(rctx->output_got->data, "\n");
+
+               if (rctx->output_sort)
+                       xbt_dynar_sort(a,cmpstringp);
+
+               if (coverage){
+                       int pos;
+                       char* data;
+                       for(pos=0;pos<xbt_dynar_length(a);pos++){
+                         data = xbt_dynar_get_as(a,pos,char*);
+                         if(!strncmp(data,"profiling:",strlen("profiling:"))){
+                                 XBT_INFO("Remove line a[%d]='%s'",pos,data);
+                                 rctx->output_got->used -= strlen(data)+1;
+                                 xbt_dynar_remove_at(a,pos,data);
+                         }
+
+                       }
+               }
+
+               char *sorted_output = xbt_str_join(a, "\n");
+               strcpy(rctx->output_got->data, sorted_output);
+               xbt_free(sorted_output);
+               xbt_dynar_free(&a);
+
+               /* If an empty line moved in first position, move it back to the end */
+               if (rctx->output_got->data[0]=='\n') {
+                 memmove(rctx->output_got->data,rctx->output_got->data+1,rctx->output_got->used-1);
+                 rctx->output_got->data[rctx->output_got->used-1] = '\n';
+               }
+       }
+
   if ((errcode && errcode != 1) || rctx->interrupted) {
     /* checking output, and matching */
     xbt_dynar_t a = xbt_str_split(rctx->output_got->data, "\n");
index 34c92b1..b4659fc 100644 (file)
@@ -22,6 +22,7 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(tesh, "TEst SHell utility");
 int timeout_value = 5;          /* child timeout value */
 int sort_len = 19;              /* length of the prefix to sort */
 char *option;
+int coverage = 0;                              /* whether the code coverage is enable */
 
 rctx_t rctx;
 const char *testsuite_name;
@@ -255,6 +256,13 @@ int main(int argc, char *argv[])
       argc -= 2;
       i -= 2;
     }
+    else if (!strcmp(argv[i], "--enable-coverage" )){
+       coverage = 1;
+       XBT_INFO("Enable coverage");
+       memmove(argv + i, argv + i + 1, (argc - i - 1) * sizeof(char *));
+       argc -= 1;
+       i -= 1;
+    }
   }
 
   /* Find the description file */
index 0dfd22b..4029614 100644 (file)
@@ -26,6 +26,7 @@ extern int timeout_value;       /* child timeout value */
 extern int sort_len;            /* length of the prefix to sort */
 extern char* option;            /* cfg for command line */
 #define SORT_LEN_DEFAULT 19
+extern int coverage;       /* coverage */
 
 extern rctx_t rctx;
 extern const char *testsuite_name;