7 #include <xbt/xbt_os_thread.h>
8 #include <xbt/strbuff.h>
15 #include <dictionary.h>
22 * byte type definition
24 #ifndef __BYTE_T_DEFINED
25 typedef unsigned char byte;
26 #define __BYTE_T_DEFINED
30 * file descriptor and pid types for portability.
35 #ifndef __FD_T_DEFINED
37 #define __FD_T_DEFINED
40 #ifndef __PID_T_DEFINED
42 #define __PID_T_DEFINED
47 #ifndef __FD_T_DEFINED
49 #define __FD_T_DEFINED
52 #ifndef __PID_T_DEFINED
54 #define __PID_T_DEFINED
59 /* forward declarations */
83 typedef enum e_command_status
85 cs_initialized = 0, /* the is initialized */
86 cs_started = 1, /* the command is started */
87 cs_in_progress = 2, /* the command is execited */
88 cs_waiting = 3, /* the command is waiting the writer, the reader and the timer */
89 cs_interrupted = 4, /* the command is interrupted */
90 cs_failed = 5, /* the command is failed */
91 cs_successeded = 6, /* the command is successeded */
92 cs_killed = 7 /* the command is killed */
96 * reason of the status of the command
98 typedef enum e_command_status_raison
100 csr_unknown = 0, /* unknown reason */
101 csr_read_failure = 1, /* a read operation failed */
102 csr_read_pipe_broken = 2, /* the pipe used to read from the stdout of the command is broken */
103 csr_timeout = 3, /* timeout */
104 csr_write_failure = 4, /* a write operation failed */
105 csr_write_pipe_broken = 5, /* the pipe used to write to the stdin of the command is broken */
106 csr_exec_failure = 6, /* can't execute the command */
107 csr_wait_failure = 8, /* the wait process function failed */
108 csr_interruption_request = 9, /* the command has received an interruption request */
109 csr_command_not_found = 10, /* the command is not found */
110 csr_exit_codes_dont_match = 11,
111 csr_outputs_dont_match = 12,
112 csr_signals_dont_match = 13,
113 csr_unexpected_signal_caught = 14,
114 csr_expected_signal_not_receipt = 15,
115 csr_pipe_function_failed = 16 /* the function pipe() or CreatePipe() fails */
118 typedef struct s_variable
125 }s_variable_t,* variable_t;
127 typedef struct s_variables
130 }s_variables_t,* variables_t;
133 * declaration of the tesh timer type
135 typedef struct s_timer
137 xbt_os_thread_t thread; /* asynchronous timer */
138 struct s_command* command; /* the timed command */
139 int timeouted; /* if 1, the timer is timeouted */
140 xbt_os_sem_t started;
141 }s_timer_t,* ttimer_t;
144 * declaration of the tesh reader type
146 typedef struct s_reader
148 xbt_os_thread_t thread; /* asynchonous reader */
149 struct s_command* command; /* the command of the reader */
150 int failed; /* if 1, the reader failed */
151 int broken_pipe; /* if 1, the pipe used by the reader is broken */
153 xbt_os_sem_t started;
154 }s_reader_t,* reader_t;
157 * declaration of the tesh writer type
159 typedef struct s_writer
161 xbt_os_thread_t thread; /* asynchronous writer */
162 struct s_command* command; /* the command of the writer */
163 int failed; /* if 1, the writer failed */
164 int broken_pipe; /* if 1, the pipe used by the writer is broken */
165 xbt_os_sem_t written;
166 xbt_os_sem_t can_write;
168 }s_writer_t,* writer_t;
171 typedef struct s_units
173 vector_t items; /* used to store the units */
174 int number_of_runned_units; /* the number of units runned */
175 int number_of_ended_units; /* the number of units over */
177 }s_units_t,* units_t;
180 * declaration of the tesh unit type
182 typedef struct s_unit
186 struct s_fstream* fstream;
187 struct s_runner* runner; /* the runner of the unit */
189 int number_of_commands; /* number of created commands of the unit */
190 int number_of_started_commands; /* number of runned commands of the unit */
191 int number_of_interrupted_commands; /* number of interrupted commands of the unit */
192 int number_of_failed_commands; /* number of failed commands of the unit */
193 int number_of_successeded_commands; /* number of successeded commands of the unit */
194 int number_of_terminated_commands; /* number of ended commands */
195 int number_of_waiting_commands;
196 xbt_os_thread_t thread; /* all the units run in its own thread */
197 xbt_os_sem_t sem; /* used by the commands of the unit to signal the end of the unit */
198 xbt_os_mutex_t mutex; /* used to synchronously access to the properties of the runner */
199 int interrupted; /* if 1, the unit is interrupted by the runner */
200 int failed; /* if 1, the unit is failed */
201 int successeded; /* if 1, the unit is successeded */
202 int parsed; /* if 1, the tesh file of the unit is parsed */
204 int parsing_include_file;
205 struct s_unit* owner; /* the unit containing the unit if any */
208 int number; /* the number of suites */
209 int capacity; /* the number of suites that the unit can contain */
210 int running_suite; /* if 1, the suite running a suite */
218 * declaration of tesh suite type
220 typedef struct s_suite
222 const char* description; /* the name of the suite */
223 struct s_unit* owner; /* the unit owning the suite */
224 vector_t units; /* the units of the suite */
225 int number; /* the numnber of suites contained by the suite */
226 int capacity; /* the number of suites that the vector can contain */
227 int number_of_successed_units; /* the number of successeded units of the suite */
228 int number_of_failed_units; /* the number of failed units of the suite */
229 }s_suite_t,* suite_t;
232 * declaration of the tesh runner type
234 typedef struct s_runner
237 /*vector_t units;*/ /* the vector containing all the units launched by the runner */
238 struct s_units* units;
239 int timeouted; /* if 1, the runner is timeouted */
240 int timeout; /* the timeout of the runner */
241 int interrupted; /* if 1, the runner failed */
242 int number_of_runned_units; /* the number of units runned by the runner */
243 int number_of_ended_units; /* the number of ended units */
244 int waiting; /* if 1, the runner is waiting the end of all the units */
245 xbt_os_thread_t thread; /* the timer thread */
249 int total_of_successeded_tests;
250 int total_of_failed_tests;
251 int total_of_interrupted_tests;
254 int total_of_successeded_units;
255 int total_of_failed_units;
256 int total_of_interrupted_units;
259 int total_of_successeded_suites;
260 int total_of_failed_suites;
261 int total_of_interrupted_suites;
262 }s_runner_t,* runner_t;
265 typedef struct s_fstreams
268 }s_fstreams_t,* fstreams_t;
271 typedef struct s_fstream
276 }s_fstream_t,* fstream_t;
278 typedef struct s_excludes
281 }s_excludes_t,* excludes_t;
283 typedef struct s_directory
287 }s_directory_t,* directory_t;
289 typedef struct s_directories
292 }s_directories_t,* directories_t;
302 * declaration of the tesh context type
304 typedef struct s_context
306 const char* command_line; /* the command line of the command to execute */
307 const char* line; /* the current parsed line */
308 int exit_code; /* the expected exit code of the command */
309 char* signal; /* the expected signal raised by the command */
310 int timeout; /* the timeout of the test */
311 xbt_strbuff_t input; /* the input to write in the stdin of the command to run */
312 xbt_strbuff_t output; /* the expected output of the command of the test */
313 output_handling_t output_handling;
314 int async; /* if 1, the command is asynchronous */
315 }s_context_t,* context_t;
318 typedef void (*fn_sig_io_handler_t)(int);
320 * declaration of the tesh command type
322 typedef struct s_command
324 unit_t unit; /* the unit of the command */
325 struct s_context* context; /* the context of the execution of the command */
326 xbt_os_thread_t thread; /* asynchronous command */
327 struct s_writer* writer; /* the writer used to write in the command stdin */
328 struct s_reader* reader; /* the reader used to read from the command stout */
329 struct s_timer* timer; /* the timer used for the command */
330 command_status_t status; /* the current status of the command */
331 cs_reason_t reason; /* the reason of the state of the command */
332 int successeded; /* if 1, the command is successeded */
333 int interrupted; /* if 1, the command is interrupted */
334 int failed; /* if 1, the command is failed */
335 pid_t pid; /* the program id of the command */
336 xbt_strbuff_t output; /* the output of the command */
337 fd_t stdout_fd; /* the stdout fd of the command */
338 fd_t stdin_fd; /* the stdin fd of the command */
339 int exit_code; /* the exit code of the command */
341 unsigned long stat_val;
345 char* signal; /* the signal raised by the command if any */
346 xbt_os_mutex_t mutex;
348 int killed; /* if 1, the command was killed */
351 fn_sig_io_handler_t fn_sig_io_handler;
352 }s_command_t,* command_t;
359 #endif /* !__TYPES_H */