Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Check the length of the description of the unit used in its summary. If the descripti...
[simgrid.git] / tools / tesh2 / src / unit.c
index 06a276b..a3c5f18 100644 (file)
@@ -164,7 +164,7 @@ unit_start(void* p)
                        if(!include->exit_code && !include->interrupted)\r
                                INFO1("Include from %s OK",include->fstream->name);\r
                        else if(include->exit_code)\r
-                               ERROR4("Include `(%s)' NOK : (<%s> %s (%d))", include->fstream->name, command->context->line, error_to_string(include->exit_code, include->err_kind), include->exit_code);\r
+                               ERROR3("Include `%s' NOK : (<%s> %s)", include->fstream->name, command->context->line, error_to_string(include->exit_code, include->err_kind));\r
                        else if(include->interrupted && !include->exit_code)\r
                                INFO1("Include `(%s)' INTR",include->fstream->name);\r
                }\r
@@ -181,7 +181,7 @@ unit_start(void* p)
                {\r
                        if(!suite->exit_code)\r
                        {\r
-                               unit_set_error(suite, ESYNTAX, 1);\r
+                               unit_set_error(suite, ESYNTAX, 1, suite->filepos);\r
                                ERROR2("[%s] Empty suite `(%s)' detected (no includes added)", suite->filepos, suite->description);\r
 \r
                                /* if the --keep-going option is not specified */\r
@@ -217,10 +217,11 @@ unit_start(void* p)
                        else if(include->exit_code)\r
                        {\r
                                if(!dry_run_flag)\r
-                                       ERROR3("Include `(%s)' NOK : (<%s> %s)", include->fstream->name, command->context->pos, error_to_string(include->exit_code, include->err_kind));\r
+                                       ERROR3("Include `%s' NOK : (<%s> %s)", include->fstream->name, command->context->pos, error_to_string(include->exit_code, include->err_kind));\r
 \r
                                suite->exit_code = include->exit_code;\r
                                suite->err_kind = include->err_kind;\r
+                               suite->err_line = strdup(include->err_line);\r
                        }\r
                        else if(include->interrupted && !include->exit_code)\r
                        {\r
@@ -237,7 +238,7 @@ unit_start(void* p)
                        if(!suite->exit_code && !suite->interrupted)\r
                                INFO1("Test suite from %s OK",suite->description);\r
                        else if(suite->exit_code)\r
-                               ERROR3("Test suite `(%s)' NOK : (<%s> %s) ", suite->description, suite->filepos, error_to_string(suite->exit_code, suite->err_kind));\r
+                               ERROR3("Test suite `%s' NOK : (<%s> %s) ", suite->description, suite->err_line, error_to_string(suite->exit_code, suite->err_kind));\r
                        else if(suite->interrupted && !suite->exit_code)\r
                                INFO1("Test suite `(%s)' INTR",suite->description);\r
                }\r
@@ -259,7 +260,7 @@ unit_start(void* p)
                else if(!root->exit_code)\r
                                INFO1("Test unit from %s OK",root->fstream->name);\r
                else if(root->exit_code)\r
-                       ERROR2("Test unit `(%s)' : NOK (%s)",root->fstream->name, error_to_string(root->exit_code, root->err_kind));    \r
+                       ERROR3("Test unit `%s': NOK (<%s> %s)",root->fstream->name, root->err_line, error_to_string(root->exit_code, root->err_kind));  \r
        }\r
        \r
        /* if it's the last unit, release the runner */\r
@@ -335,6 +336,7 @@ unit_new(runner_t runner, unit_t root, unit_t owner, fstream_t fstream)
        unit->sem = NULL;\r
        unit->exit_code = 0;\r
        unit->err_kind = 0;\r
+       unit->err_line = NULL;\r
        unit->filepos = NULL;\r
        \r
        \r
@@ -343,17 +345,19 @@ unit_new(runner_t runner, unit_t root, unit_t owner, fstream_t fstream)
 }\r
 \r
 void\r
-unit_set_error(unit_t unit, int errcode, int kind)\r
+unit_set_error(unit_t unit, int errcode, int kind, const char* line)\r
 {\r
        if(!unit->exit_code)\r
        {\r
                unit->exit_code = errcode;\r
                unit->err_kind = kind;\r
+               unit->err_line = strdup(line);\r
 \r
                if(unit->root && !unit->root->exit_code)\r
                {\r
                        unit->root->exit_code = errcode;\r
                        unit->root->err_kind = kind;\r
+                       unit->root->err_line = strdup(line);\r
                }\r
                \r
                if(!exit_code)\r
@@ -361,6 +365,7 @@ unit_set_error(unit_t unit, int errcode, int kind)
                \r
                        exit_code = errcode;\r
                        err_kind = kind;\r
+                       err_line = strdup(line);\r
                }\r
        }\r
        \r
@@ -391,6 +396,9 @@ unit_free(unit_t* ptr)
        if((*ptr)->description)\r
                free((*ptr)->description);\r
 \r
+       if((*ptr)->err_line)\r
+               free((*ptr)->err_line);\r
+\r
        if((*ptr)->filepos)\r
                free((*ptr)->filepos);\r
 \r
@@ -407,7 +415,9 @@ unit_run(unit_t unit, xbt_os_mutex_t mutex)
        if(!(unit) || !mutex)\r
     {\r
         errno = EINVAL;\r
+               xbt_os_sem_release(jobs_sem);\r
         return -1;\r
+               \r
     }\r
 \r
        if(!interrupted)\r
@@ -420,11 +430,14 @@ unit_run(unit_t unit, xbt_os_mutex_t mutex)
                unit->thread = xbt_os_thread_create("", unit_start, unit);\r
        }\r
        else\r
+       {\r
                /* the unit is interrupted by the runner before its starting \r
                 * in this case the unit semaphore is NULL take care of that\r
                 * in the function unit_free()\r
                 */\r
                unit->interrupted = 1;\r
+               xbt_os_sem_release(jobs_sem);\r
+       }\r
                \r
        return 0;\r
        \r
@@ -523,7 +536,7 @@ unit_summuarize(unit_t unit)
         return -1;\r
     }\r
        \r
-       if(unit->description)\r
+       if((unit->description) && strlen(unit->description) < 78)\r
                strcpy(title, unit->description);\r
        else\r
                sprintf(title, "file : %s",unit->fstream->name);\r