X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/bea7d471e30c245e71b6276dcdcd420f8e9d088f..7eef625065d0b3af4a64b5665009491426db974f:/tools/tesh2/include/types.h diff --git a/tools/tesh2/include/types.h b/tools/tesh2/include/types.h index 6c4cff8d0c..322d81c229 100644 --- a/tools/tesh2/include/types.h +++ b/tools/tesh2/include/types.h @@ -1,8 +1,21 @@ +/* + * include/types.h - types representing the tesh concepts. + * + * Copyright 2008,2009 Martin Quinson, Malek Cherier All right reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the license (GNU LGPL) which comes with this package. + * + * Purpose: + * This file declares the types used to run a set of tesh files. + * + */ + + #ifndef __TYPES_H #define __TYPES_H #include - #include #include #include @@ -10,11 +23,7 @@ #include -#include -#include -#include - -#ifdef _cplusplus +#ifdef __cplusplus extern "C" { #endif @@ -30,7 +39,7 @@ extern "C" { * file descriptor and pid types for portability. */ -#ifdef WIN32 +#ifdef _XBT_WIN32 #ifndef __FD_T_DEFINED typedef HANDLE fd_t; @@ -55,13 +64,13 @@ extern "C" { #endif #endif - /* forward declarations */ + +struct s_unit; /* this structure represents a tesh unit */ + struct s_runner; struct s_units; struct s_unit; -struct s_suites; -struct s_suite; struct s_excludes; struct s_fstreams; struct s_fstream; @@ -71,7 +80,58 @@ struct s_writer; struct s_reader; struct s_timer; struct s_context; +struct s_command; +struct s_variable; +struct s_error; + + +/* + * declaration of the tesh unit type which represents a tesh file + * to run. + */ +typedef struct s_unit +{ + char* description; /* an optional description of the unit */ + struct s_fstream* fstream; /* the file stream used to parse the tesh file */ + struct s_runner* runner; /* the runner of the unit */ + xbt_dynar_t commands; /* a vector containing all the commands parsed from the tesh file */ + int cmd_nb; /* number of created commands of the unit */ + int started_cmd_nb; /* number of started commands of the unit */ + int interrupted_cmd_nb; /* number of interrupted commands of the unit */ + int failed_cmd_nb; /* number of failed commands of the unit */ + int successeded_cmd_nb; /* number of successeded commands of the unit */ + int terminated_cmd_nb; /* number of ended commands */ + int waiting_cmd_nb; /* REMOVE THIS FIELD LATER */ + xbt_os_thread_t thread; /* all the units run in its own thread */ + xbt_os_sem_t sem; /* used by the last command of the unit to signal the end of the unit */ + xbt_os_mutex_t mutex; /* used to synchronously access to the properties of the runner */ + unsigned interrupted : 1; /* if 1, the unit is interrupted by the runner */ + unsigned failed : 1; /* if 1, the unit is failed */ + unsigned successeded : 1; /* if 1, the unit is successeded */ + unsigned parsed : 1; /* if 1, the tesh file of the unit is parsed */ + unsigned released : 1; /* if 1, the unit is released */ + unsigned is_running_suite : 1; /* if 1, the unit is running a suite */ + struct s_unit* owner; /* the unit owned the unit is included */ + struct s_unit* root; /* the root unit */ + xbt_dynar_t suites; /* the suites contained by the unit */ + int exit_code; /* the exit code of the unit */ + int err_kind; + char* err_line; + xbt_dynar_t includes; + char* filepos; +}s_unit_t,* unit_t; +/* + * declaration of the tesh file stream type used to manage the tesh file. + */ +typedef struct s_fstream +{ + char* name; /* the name of the file stream (same as the name of the tesh file) */ + char* directory; /* the directory containing the tesh file */ + FILE* stream; /* the system file stream */ + struct s_unit* unit; /* a reference to the unit using the file stream object */ + unsigned parsed:1; +}s_fstream_t,* fstream_t; /* * command status @@ -85,7 +145,8 @@ typedef enum e_command_status cs_interrupted = 4, /* the command is interrupted */ cs_failed = 5, /* the command is failed */ cs_successeded = 6, /* the command is successeded */ - cs_killed = 7 /* the command is killed */ + cs_killed = 7, /* the command is killed */ + csr_fcntl_function_failed = 8 /* the fcntl function failed */ }command_status_t; /* @@ -93,37 +154,49 @@ typedef enum e_command_status */ typedef enum e_command_status_raison { - csr_unknown = 0, /* unknown reason */ - csr_read_failure = 1, /* a read operation failed */ - csr_read_pipe_broken = 2, /* the pipe used to read from the stdout of the command is broken */ - csr_timeout = 3, /* timeout */ - csr_write_failure = 4, /* a write operation failed */ - csr_write_pipe_broken = 5, /* the pipe used to write to the stdin of the command is broken */ - csr_exec_failure = 6, /* can't execute the command */ - csr_wait_failure = 8, /* the wait process function failed */ - csr_interruption_request = 9, /* the command has received an interruption request */ - csr_command_not_found = 10, /* the command is not found */ - csr_exit_codes_dont_match = 11, - csr_outputs_dont_match = 12, - csr_signals_dont_match = 13, - csr_unexpected_signal_caught = 14, - csr_expected_signal_not_receipt = 15, - csr_pipe_function_failed = 16 /* the function pipe() or CreatePipe() fails */ + csr_unknown = 0, /* unknown reason */ + csr_read_failure = 1, /* a read operation failed */ + csr_read_pipe_broken = 2, /* the pipe used to read from the stdout of the command is broken */ + csr_timeout = 3, /* timeout */ + csr_write_failure = 4, /* a write operation failed */ + csr_write_pipe_broken = 5, /* the pipe used to write to the stdin of the command is broken */ + csr_fork_function_failure = 6, /* can't execute the command */ + csr_wait_failure = 8, /* the wait process function failed */ + csr_interruption_request = 9, /* the command has received an interruption request */ + csr_command_not_found = 10, /* the command is not found */ + csr_exit_codes_dont_match = 11, + csr_outputs_dont_match = 12, + csr_signals_dont_match = 13, + csr_unexpected_signal_caught = 14, + csr_expected_signal_not_received = 15, + csr_pipe_function_failed = 16, /* the function pipe() or CreatePipe() fails */ + csr_dup2_function_failure = 17, + csr_execlp_function_failure = 18, + csr_create_process_function_failure = 19, + csr_waitpid_function_failure = 20, + csr_get_exit_code_process_function_failure = 21, + csr_shell_failed = 22 }cs_reason_t; -struct s_command; -struct s_variable; -struct s_variables; +typedef struct s_variable +{ + char* name; + char* val; + int used; + int env; + int err; +}s_variable_t,* variable_t; + /* * declaration of the tesh timer type */ typedef struct s_timer { xbt_os_thread_t thread; /* asynchronous timer */ - struct s_command* command; /* the timed command */ + struct s_command* command; /* the timed command */ int timeouted; /* if 1, the timer is timeouted */ xbt_os_sem_t started; }s_timer_t,* ttimer_t; @@ -134,9 +207,10 @@ typedef struct s_timer typedef struct s_reader { xbt_os_thread_t thread; /* asynchonous reader */ - struct s_command* command; /* the command of the reader */ + struct s_command* command; /* the command of the reader */ int failed; /* if 1, the reader failed */ int broken_pipe; /* if 1, the pipe used by the reader is broken */ + int done; xbt_os_sem_t started; }s_reader_t,* reader_t; @@ -146,72 +220,28 @@ typedef struct s_reader typedef struct s_writer { xbt_os_thread_t thread; /* asynchronous writer */ - struct s_command* command; /* the command of the writer */ + struct s_command* command; /* the command of the writer */ int failed; /* if 1, the writer failed */ int broken_pipe; /* if 1, the pipe used by the writer is broken */ - xbt_os_sem_t started; + xbt_os_sem_t written; + xbt_os_sem_t can_write; + int done; }s_writer_t,* writer_t; + typedef struct s_units -{ - vector_t items; /* used to store the units */ - int number_of_runned_units; /* the number of units runned */ - int number_of_ended_units; /* the number of units over */ +{ + xbt_dynar_t items; + int number_of_runned_units; /* the number of units runned */ + int number_of_ended_units; /* the number of units over */ }s_units_t,* units_t; -/* - * declaration of the tesh unit type - */ -typedef struct s_unit -{ - struct s_fstream* fstream; - struct s_runner* runner; /* the runner of the unit */ - vector_t commands; - int number_of_commands; /* number of created commands of the unit */ - int number_of_started_commands; /* number of runned commands of the unit */ - int number_of_interrupted_commands; /* number of interrupted commands of the unit */ - int number_of_failed_commands; /* number of failed commands of the unit */ - int number_of_successeded_commands; /* number of successeded commands of the unit */ - int number_of_terminated_commands; /* number of ended commands */ - xbt_os_thread_t thread; /* all the units run in its own thread */ - xbt_os_sem_t sem; /* used by the commands of the unit to signal the end of the unit */ - xbt_os_mutex_t mutex; /* used to synchronously access to the properties of the runner */ - int interrupted; /* if 1, the unit is interrupted by the runner */ - int failed; /* if 1, the unit is failed */ - int successeded; /* if 1, the unit is successeded */ - int parsed; /* if 1, the tesh file of the unit is parsed */ - int released; - int parsing_include_file; - struct s_suite* owner; /* the suite containing the unit if any */ - vector_t suites; - int number; /* the number of suites */ - int capacity; /* the number of suites that the unit can contain */ - int running_suite; /* if 1, the suite running a suite */ -}s_unit_t,* unit_t; - - -/* - * declaration of tesh suite type - */ -typedef struct s_suite -{ - const char* description; /* the name of the suite */ - struct s_unit* owner; /* the unit owning the suite */ - vector_t units; /* the units of the suite */ - int number; /* the numnber of suites contained by the suite */ - int capacity; /* the number of suites that the vector can contain */ - int number_of_successed_units; /* the number of successeded units of the suite */ - int number_of_failed_units; /* the number of failed units of the suite */ -}s_suite_t,* suite_t; - /* * declaration of the tesh runner type */ typedef struct s_runner { - - /*vector_t units;*/ /* the vector containing all the units launched by the runner */ struct s_units* units; int timeouted; /* if 1, the runner is timeouted */ int timeout; /* the timeout of the runner */ @@ -220,37 +250,47 @@ typedef struct s_runner int number_of_ended_units; /* the number of ended units */ int waiting; /* if 1, the runner is waiting the end of all the units */ xbt_os_thread_t thread; /* the timer thread */ + xbt_dynar_t variables; + + int total_of_tests; + int total_of_successeded_tests; + int total_of_failed_tests; + int total_of_interrupted_tests; + + int total_of_units; + int total_of_successeded_units; + int total_of_failed_units; + int total_of_interrupted_units; + + int total_of_suites; + int total_of_successeded_suites; + int total_of_failed_suites; + int total_of_interrupted_suites; + char** path; + char** builtin; }s_runner_t,* runner_t; typedef struct s_fstreams { - vector_t items; + xbt_dynar_t items; }s_fstreams_t,* fstreams_t; -typedef struct s_fstream -{ - char* name; - char* directory; - FILE* stream; -}s_fstream_t,* fstream_t; - typedef struct s_excludes { - vector_t items; + xbt_dynar_t items; }s_excludes_t,* excludes_t; typedef struct s_directory { char* name; DIR* stream; - int load; }s_directory_t,* directory_t; typedef struct s_directories { - vector_t items; + xbt_dynar_t items; }s_directories_t,* directories_t; @@ -265,8 +305,9 @@ typedef enum */ typedef struct s_context { - const char* command_line; /* the command line of the command to execute */ + char* command_line; /* the command line of the command to execute */ const char* line; /* the current parsed line */ + char* pos; int exit_code; /* the expected exit code of the command */ char* signal; /* the expected signal raised by the command */ int timeout; /* the timeout of the test */ @@ -274,6 +315,12 @@ typedef struct s_context xbt_strbuff_t output; /* the expected output of the command of the test */ output_handling_t output_handling; int async; /* if 1, the command is asynchronous */ + + #ifdef _XBT_WIN32 + char* t_command_line; /* translate the command line on Windows */ + unsigned is_not_found:1; + #endif + }s_context_t,* context_t; /* @@ -281,12 +328,13 @@ typedef struct s_context */ typedef struct s_command { - unit_t unit; /* the unit of the command */ - struct s_context* context; /* the context of the execution of the command */ + unit_t root; + unit_t unit; /* the unit of the command */ + struct s_context* context; /* the context of the execution of the command */ xbt_os_thread_t thread; /* asynchronous command */ - struct s_writer* writer; /* the writer used to write in the command stdin */ - struct s_reader* reader; /* the reader used to read from the command stout */ - struct s_timer* timer; /* the timer used for the command */ + struct s_writer* writer; /* the writer used to write in the command stdin */ + struct s_reader* reader; /* the reader used to read from the command stout */ + struct s_timer* timer; /* the timer used for the command */ command_status_t status; /* the current status of the command */ cs_reason_t reason; /* the reason of the state of the command */ int successeded; /* if 1, the command is successeded */ @@ -297,21 +345,24 @@ typedef struct s_command fd_t stdout_fd; /* the stdout fd of the command */ fd_t stdin_fd; /* the stdin fd of the command */ int exit_code; /* the exit code of the command */ - #ifdef WIN32 + #ifdef _XBT_WIN32 unsigned long stat_val; #else int stat_val; #endif char* signal; /* the signal raised by the command if any */ xbt_os_mutex_t mutex; - #ifndef WIN32 + + #ifndef _XBT_WIN32 int killed; /* if 1, the command was killed */ + int execlp_errno; #endif + }s_command_t,* command_t; -#ifdef _cplusplus +#ifdef __cplusplus } #endif - #endif /* !__TYPES_H */ +