Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
fix on libpcre detection by cmake
[simgrid.git] / tools / tesh2 / src / main.c
index c1715900271f382f29cf3ee44a00215c3a189cab..c169f1ef51e4f5ad3ccde8385d44c50c1937edb1 100644 (file)
@@ -45,7 +45,7 @@ typedef struct s_optentry
 /* logs */
 XBT_LOG_NEW_DEFAULT_CATEGORY(tesh,"TEst SHell utility");
 
-#ifdef WIN32
+#ifdef _XBT_WIN32
 /* Windows specific : the previous process error mode                  */
 static UINT 
 prev_error_mode = 0;
@@ -182,6 +182,9 @@ exit_code = 0;
 int
 err_kind = 0;
 
+char* 
+err_line = NULL;
+
 
 pid_t
 pid =0;
@@ -298,7 +301,7 @@ finalized = 0;
 static int 
 sig_int = 0;
 
-#ifdef WIN32
+#ifdef _XBT_WIN32
 static void 
 sig_int_handler(int signum)
 {
@@ -425,7 +428,7 @@ main(int argc, char* argv[])
        /* then, finalize tesh (release all the allocated memory and exits) */
        finalize();
        
-       #ifndef WIN32
+       #ifndef _XBT_WIN32
        return exit_code;
        #endif
        
@@ -446,7 +449,7 @@ init(void)
        char* buffer;
        char* suffix = strdup(".tesh");
        
-       #ifdef WIN32
+       #ifdef _XBT_WIN32
        /* Windows specific : don't display the general-protection-fault message box and
         * the the critical-error-handler message box (instead the system send the error
         * to the calling process : tesh)
@@ -604,22 +607,30 @@ finalize(void)
                xbt_os_sem_destroy(units_sem);
        
        /* Windows specific (restore the previouse error mode */
-       #ifdef WIN32
+       #ifdef _XBT_WIN32
        SetErrorMode(prev_error_mode);
        #endif
 
        if(sig_int)
                INFO0("Tesh interrupted (receive a SIGINT)");
-       else if(!summary_flag && !dry_run_flag && !silent_flag && !just_print_flag && !print_version_flag && !print_usage_flag && is_tesh_root)
+       else if(!summary_flag && !detail_summary_flag && !dry_run_flag && !silent_flag && !just_print_flag && !print_version_flag && !print_usage_flag && is_tesh_root)
        {
                if(!exit_code)
                        INFO2("Tesh terminated with exit code %d : %s",exit_code, "success");
                else
-                       ERROR2("Tesh terminated with exit code `(%s)' (%d)",error_to_string(exit_code, err_kind), exit_code);
+               {
+                       if(err_line)
+                               ERROR3("Tesh terminated with exit code `(<%s> %s)' (%d)",err_line, error_to_string(exit_code, err_kind), exit_code);
+                       else
+                               ERROR2("Tesh terminated with exit code `(%s)' (%d)", error_to_string(exit_code, err_kind), exit_code);
+                       
+               }
        }
+
+       if(err_line)
+               free(err_line);
        
        /* exit from the xbt framework */
-       xbt_exit();
 
        finalized = 1;
        
@@ -750,7 +761,7 @@ process_command_line(int argc, char** argv)
                        /* get to the last / (if any) to get the short name of the file */
                        delimiter = strrchr(optarg,'/');
                        
-                       #ifdef WIN32
+                       #ifdef _XBT_WIN32
                        if(!delimiter)
                                delimiter = strrchr(optarg,'\\');
                        #endif
@@ -961,14 +972,14 @@ process_command_line(int argc, char** argv)
                                                                if(ENOENT == errno)
                                                                        ERROR1("File %s does not exist", optarg);
                                                                else
-                                                                       ERROR0("Insufficient memory is available to process the command line - system error");
+                                                                       ERROR1("System error :`(%s)'", strerror(errno));
                                                                
                                                                return -1;
                                                        }
                                                        
                                                        delimiter = strrchr(optarg,'/');
 
-                                                       #ifdef WIN32
+                                                       #ifdef _XBT_WIN32
                                                        if(!delimiter)
                                                                delimiter = strrchr(optarg,'\\');
                                                        #endif
@@ -1053,7 +1064,7 @@ process_command_line(int argc, char** argv)
                        
                                                        delimiter = strrchr(optarg,'/');
 
-                                                       #ifdef WIN32
+                                                       #ifdef _XBT_WIN32
                                                        if(!delimiter)
                                                                delimiter = strrchr(optarg,'\\');
                                                        #endif
@@ -1138,7 +1149,7 @@ print_usage(void)
 
        if(!screen_cleaned)
        {
-               #ifdef WIN32
+               #ifdef _XBT_WIN32
                system("cls");
                #else
                system("clear");
@@ -1159,7 +1170,7 @@ print_version(void)
 {
        if(!screen_cleaned)
        {
-               #ifdef WIN32
+               #ifdef _XBT_WIN32
                system("cls");
                #else
                system("clear");