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 */
79 typedef enum e_command_status
81 cs_initialized = 0, /* the is initialized */
82 cs_started = 1, /* the command is started */
83 cs_in_progress = 2, /* the command is execited */
84 cs_waiting = 3, /* the command is waiting the writer, the reader and the timer */
85 cs_interrupted = 4, /* the command is interrupted */
86 cs_failed = 5, /* the command is failed */
87 cs_successeded = 6, /* the command is successeded */
88 cs_killed = 7 /* the command is killed */
92 * reason of the status of the command
94 typedef enum e_command_status_raison
96 csr_unknown = 0, /* unknown reason */
97 csr_read_failure = 1, /* a read operation failed */
98 csr_read_pipe_broken = 2, /* the pipe used to read from the stdout of the command is broken */
99 csr_timeout = 3, /* timeout */
100 csr_write_failure = 4, /* a write operation failed */
101 csr_write_pipe_broken = 5, /* the pipe used to write to the stdin of the command is broken */
102 csr_exec_failure = 6, /* can't execute the command */
103 csr_wait_failure = 8, /* the wait process function failed */
104 csr_interruption_request = 9, /* the command has received an interruption request */
105 csr_command_not_found = 10, /* the command is not found */
106 csr_exit_codes_dont_match = 11,
107 csr_outputs_dont_match = 12,
108 csr_signals_dont_match = 13,
109 csr_unexpected_signal_caught = 14,
110 csr_expected_signal_not_receipt = 15,
111 csr_pipe_function_failed = 16 /* the function pipe() or CreatePipe() fails */
121 * declaration of the tesh timer type
123 typedef struct s_timer
125 xbt_os_thread_t thread; /* asynchronous timer */
126 struct s_command* command; /* the timed command */
127 int timeouted; /* if 1, the timer is timeouted */
128 xbt_os_sem_t started;
129 }s_timer_t,* ttimer_t;
132 * declaration of the tesh reader type
134 typedef struct s_reader
136 xbt_os_thread_t thread; /* asynchonous reader */
137 struct s_command* command; /* the command of the reader */
138 int failed; /* if 1, the reader failed */
139 int broken_pipe; /* if 1, the pipe used by the reader is broken */
140 xbt_os_sem_t started;
141 }s_reader_t,* reader_t;
144 * declaration of the tesh writer type
146 typedef struct s_writer
148 xbt_os_thread_t thread; /* asynchronous writer */
149 struct s_command* command; /* the command of the writer */
150 int failed; /* if 1, the writer failed */
151 int broken_pipe; /* if 1, the pipe used by the writer is broken */
152 xbt_os_sem_t started;
153 }s_writer_t,* writer_t;
155 typedef struct s_units
157 vector_t items; /* used to store the units */
158 int number_of_runned_units; /* the number of units runned */
159 int number_of_ended_units; /* the number of units over */
161 }s_units_t,* units_t;
164 * declaration of the tesh unit type
166 typedef struct s_unit
168 struct s_fstream* fstream;
169 struct s_runner* runner; /* the runner of the unit */
171 int number_of_commands; /* number of created commands of the unit */
172 int number_of_started_commands; /* number of runned commands of the unit */
173 int number_of_interrupted_commands; /* number of interrupted commands of the unit */
174 int number_of_failed_commands; /* number of failed commands of the unit */
175 int number_of_successeded_commands; /* number of successeded commands of the unit */
176 int number_of_terminated_commands; /* number of ended commands */
177 xbt_os_thread_t thread; /* all the units run in its own thread */
178 xbt_os_sem_t sem; /* used by the commands of the unit to signal the end of the unit */
179 xbt_os_mutex_t mutex; /* used to synchronously access to the properties of the runner */
180 int interrupted; /* if 1, the unit is interrupted by the runner */
181 int failed; /* if 1, the unit is failed */
182 int successeded; /* if 1, the unit is successeded */
183 int parsed; /* if 1, the tesh file of the unit is parsed */
185 int parsing_include_file;
186 struct s_suite* owner; /* the suite containing the unit if any */
188 int number; /* the number of suites */
189 int capacity; /* the number of suites that the unit can contain */
190 int running_suite; /* if 1, the suite running a suite */
195 * declaration of tesh suite type
197 typedef struct s_suite
199 const char* description; /* the name of the suite */
200 struct s_unit* owner; /* the unit owning the suite */
201 vector_t units; /* the units of the suite */
202 int number; /* the numnber of suites contained by the suite */
203 int capacity; /* the number of suites that the vector can contain */
204 int number_of_successed_units; /* the number of successeded units of the suite */
205 int number_of_failed_units; /* the number of failed units of the suite */
206 }s_suite_t,* suite_t;
209 * declaration of the tesh runner type
211 typedef struct s_runner
214 /*vector_t units;*/ /* the vector containing all the units launched by the runner */
215 struct s_units* units;
216 int timeouted; /* if 1, the runner is timeouted */
217 int timeout; /* the timeout of the runner */
218 int interrupted; /* if 1, the runner failed */
219 int number_of_runned_units; /* the number of units runned by the runner */
220 int number_of_ended_units; /* the number of ended units */
221 int waiting; /* if 1, the runner is waiting the end of all the units */
222 xbt_os_thread_t thread; /* the timer thread */
223 }s_runner_t,* runner_t;
226 typedef struct s_fstreams
229 }s_fstreams_t,* fstreams_t;
232 typedef struct s_fstream
237 }s_fstream_t,* fstream_t;
239 typedef struct s_excludes
242 }s_excludes_t,* excludes_t;
244 typedef struct s_directory
249 }s_directory_t,* directory_t;
251 typedef struct s_directories
254 }s_directories_t,* directories_t;
264 * declaration of the tesh context type
266 typedef struct s_context
268 const char* command_line; /* the command line of the command to execute */
269 const char* line; /* the current parsed line */
270 int exit_code; /* the expected exit code of the command */
271 char* signal; /* the expected signal raised by the command */
272 int timeout; /* the timeout of the test */
273 xbt_strbuff_t input; /* the input to write in the stdin of the command to run */
274 xbt_strbuff_t output; /* the expected output of the command of the test */
275 output_handling_t output_handling;
276 int async; /* if 1, the command is asynchronous */
277 }s_context_t,* context_t;
280 * declaration of the tesh command type
282 typedef struct s_command
284 unit_t unit; /* the unit of the command */
285 struct s_context* context; /* the context of the execution of the command */
286 xbt_os_thread_t thread; /* asynchronous command */
287 struct s_writer* writer; /* the writer used to write in the command stdin */
288 struct s_reader* reader; /* the reader used to read from the command stout */
289 struct s_timer* timer; /* the timer used for the command */
290 command_status_t status; /* the current status of the command */
291 cs_reason_t reason; /* the reason of the state of the command */
292 int successeded; /* if 1, the command is successeded */
293 int interrupted; /* if 1, the command is interrupted */
294 int failed; /* if 1, the command is failed */
295 pid_t pid; /* the program id of the command */
296 xbt_strbuff_t output; /* the output of the command */
297 fd_t stdout_fd; /* the stdout fd of the command */
298 fd_t stdin_fd; /* the stdin fd of the command */
299 int exit_code; /* the exit code of the command */
301 unsigned long stat_val;
305 char* signal; /* the signal raised by the command if any */
306 xbt_os_mutex_t mutex;
308 int killed; /* if 1, the command was killed */
310 }s_command_t,* command_t;
317 #endif /* !__TYPES_H */