From 7200d622a9e4d6f368da17f51f6aee495dccfa1d Mon Sep 17 00:00:00 2001 From: mquinson Date: Fri, 10 Dec 2010 11:26:06 +0000 Subject: [PATCH] [tesh] allow to specify the length of the sorting prefix git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@9125 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- tools/tesh/README.tesh | 7 ++++++- tools/tesh/run_context.c | 5 ++++- tools/tesh/tesh.c | 1 + tools/tesh/tesh.h | 2 ++ 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/tools/tesh/README.tesh b/tools/tesh/README.tesh index f463dae272..08e207da9b 100644 --- a/tools/tesh/README.tesh +++ b/tools/tesh/README.tesh @@ -124,7 +124,7 @@ to sort the output back before comparing it. We expect the simulators to run with that log formating argument: -log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n -Then, tesh sorts string on the 20 first lines only, and is stable when +Then, tesh sorts string on the 19 first chars only, and is stable when line beginings are equal. This should ensure that: (1) tesh is effective (no false positive, no false negative) (2) scheduling points are separated from each other @@ -134,6 +134,11 @@ line beginings are equal. This should ensure that: This is of course very SimGrid oriented, breaking the generality of tesh, but who cares, actually? + +If you want to change the length of the prefix used for the sort, +simply specify it after the output sort directive, like this: + +! output sort 22 ENVIRONMENT ----------- diff --git a/tools/tesh/run_context.c b/tools/tesh/run_context.c index 41af0d5efd..5b9a9bb925 100644 --- a/tools/tesh/run_context.c +++ b/tools/tesh/run_context.c @@ -342,6 +342,9 @@ void rctx_pushline(const char *filepos, char kind, char *line) filepos, rctx->expected_return); } else if (!strncmp(line, "output sort", strlen("output sort"))) { + sort_len = atoi(line + strlen("output sort")); + if (sort_len==0) + sort_len=SORT_LEN_DEFAULT; rctx->output_sort = 1; VERB1("[%s] (sort output of next command)", filepos); @@ -650,7 +653,7 @@ static int cmpstringp(const void *p1, const void *p2) { DEBUG2("Compare strings '%s' and '%s'", s1, s2); - int res = strncmp(s1, s2, 19); + int res = strncmp(s1, s2, sort_len); if (res == 0) return p1>p2; return res; diff --git a/tools/tesh/tesh.c b/tools/tesh/tesh.c index f45d0b1aed..490e8c2b07 100644 --- a/tools/tesh/tesh.c +++ b/tools/tesh/tesh.c @@ -20,6 +20,7 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(tesh, "TEst SHell utility"); /*** Options ***/ int timeout_value = 5; /* child timeout value */ +int sort_len = 19; /* length of the prefix to sort */ const char *testsuite_name; static void handle_line(const char *filepos, char *line) diff --git a/tools/tesh/tesh.h b/tools/tesh/tesh.h index 8f73c1c9a0..f189375abf 100644 --- a/tools/tesh/tesh.h +++ b/tools/tesh/tesh.h @@ -23,6 +23,8 @@ const char *signal_name(unsigned int got, char *expected); /*** Options ***/ int timeout_value; /* child timeout value */ +int sort_len; /* length of the prefix to sort */ +#define SORT_LEN_DEFAULT 19 rctx_t rctx; const char *testsuite_name; -- 2.20.1