Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
last changes of Tesh tools
[simgrid.git] / tools / tesh2 / src / fstream.c
index 60a70ac..2bbaa6e 100644 (file)
@@ -31,7 +31,7 @@
 \r
 #ifdef WIN32\r
 static int\r
-is_w32_cmd(const char* cmd, char** path)\r
+is_w32_cmd(char* cmd, char** path)\r
 {\r
        size_t i = 0;\r
        struct stat stat_buff = {0};\r
@@ -51,6 +51,9 @@ is_w32_cmd(const char* cmd, char** path)
                {\r
                        for (i = 0; path[i] != NULL; i++)\r
                        {\r
+                               /* use Cat.exe on Windows */\r
+                               if(!strcmp(cmd, "cat"))\r
+                                       cmd[0] = 'C';\r
                                \r
                                sprintf(buff,"%s\\%s",path[i], cmd);\r
                                \r
@@ -324,7 +327,7 @@ fstream_parse(fstream_t fstream, xbt_os_mutex_t mutex)
                                unit->is_running_suite = 0;\r
                        }\r
                                \r
-                       if(context->command_line)\r
+                       if(context->command_line && !context->is_not_found)\r
                        {\r
                                if(fstream_launch_command(fstream, context, mutex) < 0)\r
                                                break;\r
@@ -371,7 +374,7 @@ fstream_parse(fstream_t fstream, xbt_os_mutex_t mutex)
        }\r
        \r
        /* Check that last command of the file ran well */\r
-       if(context->command_line)\r
+       if(context->command_line && !context->is_not_found)\r
        {\r
                if(fstream_launch_command(fstream, context, mutex) < 0)\r
                        return -1;\r
@@ -705,7 +708,7 @@ fstream_lex_line(fstream_t fstream, context_t context, xbt_os_mutex_t mutex, con
                        \r
                        if((p = strstr(line2 + 2, exp)))\r
                        {\r
-                               if((p + strlen(variable->name) + 1)[0] != '\0')\r
+                               if((p + strlen(variable->name) + 1)[0] != '\0' && !(isalpha((p + strlen(variable->name) + 1)[0])))\r
                                        delimiters[0] = (p + strlen(variable->name) + 1)[0];\r
 \r
                                if(variable->val)\r
@@ -983,10 +986,10 @@ fstream_lex_line(fstream_t fstream, context_t context, xbt_os_mutex_t mutex, con
                \r
        }\r
        \r
-       p = line2 + 2;\r
-       \r
-       while(p && 1)\r
+       while(1)\r
        {\r
+               p = line2 + (line2[0] =='<' ? 4 : 2);\r
+               \r
                if((p = strchr(p, '$')))\r
                {\r
                        if(*(p+1) != ' ')\r
@@ -1303,9 +1306,21 @@ fstream_process_token(fstream_t fstream, context_t context, xbt_os_mutex_t mutex
                \r
                if(!is_w32_cmd(command_line, fstream->unit->runner->path) && getpath(command_line, &path) < 0)\r
                {\r
+                       command_t command;\r
+\r
                        ERROR3("[%s] `%s' : NOK (%s)", filepos, command_line, error_to_string(ECMDNOTFOUND, 1));\r
                        unit_set_error(fstream->unit, ECMDNOTFOUND, 1, filepos);\r
+\r
+                       context->is_not_found = 1;\r
+                       \r
+                       command = command_new(fstream->unit, context, mutex);\r
+\r
+                       command->status = cs_failed;\r
+                       command->reason = csr_command_not_found;\r
+\r
                        failure(unit);\r
+                       \r
+                       \r
                        return;\r
                }\r
                \r