2 * src/unit.c - type representing the tesh unit concept.
\r
4 * Copyright 2008,2009 Martin Quinson, Malek Cherier All right reserved.
\r
6 * This program is free software; you can redistribute it and/or modify it
\r
7 * under the terms of the license (GNU LGPL) which comes with this package.
\r
10 * This file contains all the definitions of the functions related with
\r
11 * the tesh unit concept.
\r
16 #include <command.h>
\r
17 #include <context.h>
\r
18 #include <fstream.h>
\r
19 #include <variable.h>
\r
20 #include <str_replace.h>
\r
25 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(tesh);
\r
27 /*! \brief unit_start - start the processing of the tesh file representing by the unit
\r
29 * \param p A void pointer to the unit representing the tesh file to process.
\r
31 * \return This function (thread routine always returns NULL)
\r
35 * 1) The unit increment the number of running unit of the runner.
\r
36 * 2) The unit wait for the jobs semaphore to realy start its job.
\r
37 * 3) The unit runs the parsing of its tesh file using an fstream object.
\r
38 * 3.1) The fstream object parse the tesh file an launch each command with its context of execution.
\r
39 * 3.2) If a syntax error is detected the fstream object handle the failure and signals it by setting
\r
40 * the flag interrupted of the unit to one (depending of the keep-going and keep-going-unit flag values)
\r
41 * 3.3) If a command failed (exit code do not match, timeout, ouptupt different from the expected..)
\r
42 * the command handle the failure (see command_handle_failure() for more details).
\r
43 * 4) After the parsing of the tesh file.
\r
44 * 4.1) If all commands are successeded the last command release the unit by releasing its semaphore.
\r
45 * 4.2) If a command failed or if the tesh file is malformated the unit interrupt all the commands in progress.
\r
46 * 5) The unit wait for the end of all the threads associated with a command.
\r
47 * 6) Its release the next waiting unit (if any) by releasing the jobs semaphore.
\r
48 * 7) If its the last unit, it release the runner by releasing the semaphore used to wait for the end of all the units.
\r
52 unit_start(void* p)
\r
54 xbt_os_thread_t thread;
\r
55 xbt_os_mutex_t mutex;
\r
56 unit_t include, suite;
\r
57 unsigned int itc, itu, its;
\r
58 int include_nb, suite_nb;
\r
61 unit_t root = (unit_t)p;
\r
63 /* increment the number of running units */
\r
64 xbt_os_mutex_acquire(root->mutex);
\r
65 root->runner->number_of_runned_units++;
\r
66 xbt_os_mutex_release(root->mutex);
\r
68 /* must acquire the jobs semaphore to start */
\r
69 /*xbt_os_sem_acquire(jobs_sem);*/
\r
71 /* initialize the mutex used to synchronize the access to the properties of this unit */
\r
72 mutex = xbt_os_mutex_init();
\r
75 INFO1("Test unit from %s",root->fstream->name);
\r
77 INFO1("Checking unit %s...",root->fstream->name);
\r
79 /* launch the parsing of the unit */
\r
80 fstream_parse(root->fstream, mutex);
\r
82 /* if the unit is not interrupted and not failed the unit, all the file is parsed
\r
83 * so all the command are launched
\r
85 if(!root->interrupted)
\r
89 /* all the commands have terminated before the end of the parsing of the tesh file
\r
90 * so the unit release the semaphore itself
\r
92 if(!root->released && (root->started_cmd_nb == (root->failed_cmd_nb + root->interrupted_cmd_nb + root->successeded_cmd_nb)))
\r
93 xbt_os_sem_release(root->sem);
\r
96 /* wait the end of all the commands or a command failure or an interruption */
\r
98 xbt_os_sem_acquire(root->sem);
\r
101 if(root->interrupted)
\r
104 xbt_dynar_foreach(root->commands, itc , command)
\r
106 if(command->status == cs_in_progress)
\r
107 command_interrupt(command);
\r
110 /* interrupt all the running commands of the included units */
\r
111 include_nb = xbt_dynar_length(root->includes);
\r
113 xbt_dynar_foreach(root->includes, itu, include)
\r
115 xbt_dynar_foreach(include->commands, itc, command)
\r
117 if(command->status == cs_in_progress)
\r
118 command_interrupt(command);
\r
122 /* interrupt all the running commands of the unit */
\r
123 suite_nb = xbt_dynar_length(root->suites);
\r
125 xbt_dynar_foreach(root->suites, its, suite)
\r
127 include_nb = xbt_dynar_length(suite->includes);
\r
129 xbt_dynar_foreach(suite->includes, itu, include)
\r
131 xbt_dynar_foreach(include->commands, itc, command)
\r
133 if(command->status == cs_in_progress)
\r
134 command_interrupt(command);
\r
140 /* wait the end of the command threads of the unit */
\r
141 xbt_dynar_foreach(root->commands, itc, command)
\r
143 thread = command->thread;
\r
146 xbt_os_thread_join(thread,NULL);
\r
149 /* wait the end of the command threads of the included units of the unit */
\r
150 include_nb = xbt_dynar_length(root->includes);
\r
152 xbt_dynar_foreach(root->includes, itu, include)
\r
154 xbt_dynar_foreach(include->commands, itc, command)
\r
156 thread = command->thread;
\r
159 xbt_os_thread_join(thread,NULL);
\r
164 if(!include->exit_code && !include->interrupted)
\r
165 INFO1("Include from %s OK",include->fstream->name);
\r
166 else if(include->exit_code)
\r
167 ERROR3("Include `%s' NOK : (<%s> %s)", include->fstream->name, include->err_line, error_to_string(include->exit_code, include->err_kind));
\r
168 else if(include->interrupted && !include->exit_code)
\r
169 INFO1("Include `(%s)' INTR",include->fstream->name);
\r
173 /* interrupt all the running commands of the unit */
\r
174 suite_nb = xbt_dynar_length(root->suites);
\r
176 xbt_dynar_foreach(root->suites, its, suite)
\r
178 include_nb = xbt_dynar_length(suite->includes);
\r
182 if(!suite->exit_code)
\r
184 unit_set_error(suite, ESYNTAX, 1, suite->filepos);
\r
185 ERROR2("[%s] Empty suite `(%s)' detected (no includes added)", suite->filepos, suite->description);
\r
187 /* if the --keep-going option is not specified */
\r
188 if(!keep_going_flag)
\r
192 /* request an global interruption by the runner */
\r
195 /* release the runner */
\r
196 xbt_os_sem_release(units_sem);
\r
202 xbt_dynar_foreach(suite->includes, itu, include)
\r
204 xbt_dynar_foreach(include->commands, itc, command)
\r
206 thread = command->thread;
\r
209 xbt_os_thread_join(thread,NULL);
\r
212 if(!include->exit_code && !include->interrupted)
\r
215 INFO1("Include from %s OK",include->fstream->name);
\r
217 else if(include->exit_code)
\r
220 ERROR3("Include `%s' NOK : (<%s> %s)", include->fstream->name, command->context->pos, error_to_string(include->exit_code, include->err_kind));
\r
222 suite->exit_code = include->exit_code;
\r
223 suite->err_kind = include->err_kind;
\r
224 suite->err_line = strdup(include->err_line);
\r
226 else if(include->interrupted && !include->exit_code)
\r
229 INFO1("Include `(%s)' INTR",include->fstream->name);
\r
231 suite->interrupted = 1;
\r
238 if(!suite->exit_code && !suite->interrupted)
\r
239 INFO1("Test suite from %s OK",suite->description);
\r
240 else if(suite->exit_code)
\r
241 ERROR3("Test suite `%s' NOK : (<%s> %s) ", suite->description, suite->err_line, error_to_string(suite->exit_code, suite->err_kind));
\r
242 else if(suite->interrupted && !suite->exit_code)
\r
243 INFO1("Test suite `(%s)' INTR",suite->description);
\r
247 /* you can now destroy the mutex used to synchrone the command accesses to the properties of the unit */
\r
248 xbt_os_mutex_destroy(mutex);
\r
250 /* update the number of ended units of the runner */
\r
251 xbt_os_mutex_acquire(root->mutex);
\r
253 /* increment the number of ended units */
\r
254 root->runner->number_of_ended_units++;
\r
258 if(root->interrupted && !root->exit_code)
\r
259 INFO1("Test unit from %s INTR",root->fstream->name);
\r
260 else if(!root->exit_code)
\r
261 INFO1("Test unit from %s OK",root->fstream->name);
\r
262 else if(root->exit_code)
\r
263 ERROR3("Test unit `%s': NOK (<%s> %s)",root->fstream->name, root->err_line, error_to_string(root->exit_code, root->err_kind));
\r
266 /* if it's the last unit, release the runner */
\r
267 if((root->runner->number_of_runned_units == root->runner->number_of_ended_units))
\r
269 /* if all the commands of the unit are successeded itc's a successeded unit */
\r
270 if(root->successeded_cmd_nb == root->cmd_nb && !root->exit_code /* case of only one cd : nb = successeded = 0)*/)
\r
271 root->successeded = 1;
\r
273 /* first release the mutex */
\r
274 xbt_os_mutex_release(root->mutex);
\r
276 /* release the runner */
\r
277 xbt_os_sem_release(units_sem);
\r
280 xbt_os_mutex_release(root->mutex);
\r
282 /* release the jobs semaphore, then the next waiting unit can start */
\r
283 xbt_os_sem_release(jobs_sem);
\r
291 unit_new(runner_t runner, unit_t root, unit_t owner, fstream_t fstream)
\r
295 unit = xbt_new0(s_unit_t, 1);
\r
297 /* instantiate the vector used to store all the commands of the unit */
\r
298 unit->commands = xbt_dynar_new(sizeof(command_t), (void_f_pvoid_t)command_free);
\r
300 /* instantiate the vector used to store all the included units */
\r
301 unit->includes = xbt_dynar_new(sizeof(unit_t), (void_f_pvoid_t)unit_free);
\r
303 /* instantiate the vector used to store all the included suites */
\r
304 unit->suites = xbt_dynar_new(sizeof(unit_t), (void_f_pvoid_t)unit_free);
\r
306 /* the runner used to launch the tesh unit */
\r
307 unit->runner = runner;
\r
309 /* the file stream object to use to parse the tesh file */
\r
310 unit->fstream = fstream;
\r
313 fstream->unit = unit;
\r
315 /* if no root parameter specified assume that itc's the root of all the units */
\r
316 unit->root = root ? root : unit;
\r
318 /* the owner of the suite */
\r
319 unit->owner = owner;
\r
321 unit->thread = NULL;
\r
322 unit->started_cmd_nb = 0;
\r
323 unit->interrupted_cmd_nb = 0;
\r
324 unit->failed_cmd_nb = 0;
\r
325 unit->successeded_cmd_nb = 0;
\r
326 unit->terminated_cmd_nb = 0;
\r
327 unit->waiting_cmd_nb = 0;
\r
328 unit->interrupted = 0;
\r
330 unit->successeded = 0;
\r
332 unit->released = 0;
\r
333 unit->owner = owner;
\r
334 unit->is_running_suite = 0;
\r
335 unit->description = NULL;
\r
337 unit->exit_code = 0;
\r
338 unit->err_kind = 0;
\r
339 unit->err_line = NULL;
\r
340 unit->filepos = NULL;
\r
348 unit_set_error(unit_t unit, int errcode, int kind, const char* line)
\r
350 if(!unit->exit_code)
\r
352 unit->exit_code = errcode;
\r
353 unit->err_kind = kind;
\r
354 unit->err_line = strdup(line);
\r
356 if(unit->root && !unit->root->exit_code)
\r
358 unit->root->exit_code = errcode;
\r
359 unit->root->err_kind = kind;
\r
360 unit->root->err_line = strdup(line);
\r
366 exit_code = errcode;
\r
368 err_line = strdup(line);
\r
375 unit_free(unit_t* ptr)
\r
383 if((*ptr)->commands)
\r
384 xbt_dynar_free(&((*ptr)->commands));
\r
386 if((*ptr)->includes)
\r
387 xbt_dynar_free(&((*ptr)->includes));
\r
390 xbt_dynar_free(&((*ptr)->suites));
\r
392 /* if the unit is interrupted during its run, the semaphore is NULL */
\r
394 xbt_os_sem_destroy((*ptr)->sem);
\r
396 if((*ptr)->description)
\r
397 free((*ptr)->description);
\r
399 if((*ptr)->err_line)
\r
400 free((*ptr)->err_line);
\r
402 if((*ptr)->filepos)
\r
403 free((*ptr)->filepos);
\r
412 unit_run(unit_t unit, xbt_os_mutex_t mutex)
\r
414 /* check the parameters */
\r
415 if(!(unit) || !mutex)
\r
418 xbt_os_sem_release(jobs_sem);
\r
425 unit->mutex = mutex;
\r
427 unit->sem = xbt_os_sem_init(0);
\r
429 /* start the unit */
\r
430 unit->thread = xbt_os_thread_create("", unit_start, unit);
\r
434 /* the unit is interrupted by the runner before its starting
\r
435 * in this case the unit semaphore is NULL take care of that
\r
436 * in the function unit_free()
\r
438 unit->interrupted = 1;
\r
439 xbt_os_sem_release(jobs_sem);
\r
447 unit_interrupt(unit_t unit)
\r
449 /* check the parameter */
\r
456 /* if the unit is already interrupted, signal the error */
\r
457 if(unit->interrupted)
\r
463 /* interrupt the run of the specified unit */
\r
464 unit->interrupted = 1;
\r
465 xbt_os_sem_release(unit->sem);
\r
470 /* just print the title of the root unit or a suite (if any) */
\r
472 print_title(const char* description)
\r
476 size_t len = strlen(description);
\r
480 for (i = 1; i < 79; i++)
\r
486 sprintf(title + 40 - (len + 4)/2, "[ %s ]",description);
\r
487 title[40 + (len + 5 ) / 2] = '=';
\r
489 printf("\n%s\n",title);
\r
493 unit_summuarize(unit_t unit)
\r
496 unsigned int itc, itu, its;
\r
500 char title[PATH_MAX + 1] = {0};
\r
502 int number_of_tests = 0; /* number of tests of a unit contained by this unit */
\r
503 int number_of_failed_tests = 0; /* number of failed test of a unit contained by this unit */
\r
504 int number_of_successeded_tests = 0; /* number of successeded tests of a unit contained by this unit */
\r
505 int number_of_interrupted_tests = 0; /* number of interrupted tests of a unit contained by this unit */
\r
507 int number_of_tests_of_suite = 0; /* number of tests of a suite contained by this unit */
\r
508 int number_of_interrupted_tests_of_suite = 0; /* number of interrupted tests of a suite contained by this unit */
\r
509 int number_of_failed_tests_of_suite = 0; /* number of failed tests of a suite contained by this unit */
\r
510 int number_of_successeded_tests_of_suite = 0; /* number of successeded tests of a suite contained by this */
\r
512 int number_of_units = 0; /* number of units contained by a suite */
\r
513 int number_of_failed_units = 0; /* number of failed units contained by a suite */
\r
514 int number_of_successeded_units = 0; /* number of successeded units contained by a suite */
\r
515 int number_of_interrupted_units = 0; /* number of interrupted units contained by a suite */
\r
517 int total_of_tests = 0; /* total of the tests contained by this unit */
\r
518 int total_of_failed_tests = 0; /* total of failed tests contained by this unit */
\r
519 int total_of_successeded_tests = 0; /* total of successeded tests contained by this unit */
\r
520 int total_of_interrupted_tests = 0; /* total of interrupted tests contained by this unit */
\r
522 int total_of_units = 0; /* total of units contained by this unit */
\r
523 int total_of_failed_units = 0; /* total of failed units contained by this unit */
\r
524 int total_of_successeded_units = 0; /* total of successeded units contained by this unit */
\r
525 int total_of_interrupted_units = 0; /* total of interrutped units contained by this unit */
\r
527 int total_of_suites = 0; /* total of suites contained by this unit */
\r
528 int total_of_failed_suites = 0; /* total of failed suites contained by this unit */
\r
529 int total_of_successeded_suites = 0; /* total of successeded suites contained by this unit */
\r
530 int total_of_interrupted_suites = 0; /* total of interrupted suites contained by this unit */
\r
532 /* check the parameter */
\r
539 if((unit->description) && strlen(unit->description) < 76)
\r
540 strcpy(title, unit->description);
\r
542 sprintf(title, "file : %s",unit->fstream->name);
\r
544 if(unit->interrupted)
\r
546 if(strlen(title) + strlen(" (interrupted)") < 76)
\r
547 strcat(title, " (interrupted)");
\r
550 memset(title, 0, PATH_MAX + 1);
\r
551 sprintf(title, "file : %s",unit->fstream->name);
\r
552 strcat(title, " (interrupted)");
\r
557 print_title(title);
\r
559 number_of_tests = xbt_dynar_length(unit->commands);
\r
562 xbt_dynar_foreach(unit->commands, itc, command)
\r
564 if(command->status == cs_interrupted)
\r
565 number_of_interrupted_tests++;
\r
566 else if(command->status == cs_failed)
\r
567 number_of_failed_tests++;
\r
568 else if(command->status == cs_successeded)
\r
569 number_of_successeded_tests++;
\r
573 if(number_of_tests)
\r
575 asprintf(&p," Test(s): .........................................................................");
\r
581 if(number_of_failed_tests > 0)
\r
582 printf(".. failed\n");
\r
583 else if(number_of_interrupted_tests > 0)
\r
584 printf("interrupt\n");
\r
586 printf(".... ..ok\n");
\r
588 xbt_dynar_foreach(unit->commands, itc, command)
\r
590 printf(" %s: %s [%s]\n",
\r
591 command->status == cs_interrupted ? "INTR "
\r
592 : command->status == cs_failed ? "FAILED"
\r
593 : command->status == cs_successeded ? "PASS "
\r
595 command->context->command_line,
\r
596 command->context->pos);
\r
598 if(detail_summary_flag)
\r
599 command_summarize(command);
\r
602 printf(" =====================================================================%s\n",
\r
603 number_of_failed_tests ? "== FAILED": number_of_interrupted_tests ? "==== INTR" : "====== OK");
\r
605 printf(" Summary: Test(s): %.0f%% ok (%d test(s): %d ok",
\r
606 ((1-((double)number_of_failed_tests + (double)number_of_interrupted_tests)/(double)number_of_tests)*100.0),
\r
607 number_of_tests, number_of_successeded_tests);
\r
609 if(number_of_failed_tests > 0)
\r
610 printf(", %d failed", number_of_failed_tests);
\r
612 if(number_of_interrupted_tests > 0)
\r
613 printf(", %d interrupted)", number_of_interrupted_tests);
\r
617 total_of_tests = number_of_tests;
\r
618 total_of_failed_tests = number_of_failed_tests;
\r
619 total_of_interrupted_tests = number_of_interrupted_tests;
\r
620 total_of_successeded_tests = number_of_successeded_tests;
\r
626 total_of_failed_units = total_of_interrupted_units = total_of_successeded_units = 0;
\r
627 number_of_failed_units = number_of_successeded_units = number_of_interrupted_units = 0;
\r
628 number_of_units = xbt_dynar_length(unit->includes);
\r
630 xbt_dynar_foreach(unit->includes, itu, include)
\r
633 number_of_interrupted_tests = number_of_failed_tests = number_of_successeded_tests = 0;
\r
635 number_of_tests = xbt_dynar_length(include->commands);
\r
637 xbt_dynar_foreach(include->commands, itc, command)
\r
639 if(command->status == cs_interrupted)
\r
640 number_of_interrupted_tests++;
\r
641 else if(command->status == cs_failed)
\r
642 number_of_failed_tests++;
\r
643 else if(command->status == cs_successeded)
\r
644 number_of_successeded_tests++;
\r
647 asprintf(&p," Unit: %s ............................................................................", include->description && strlen(include->description) < 60 ? include->description : include->fstream->name);
\r
653 if(number_of_failed_tests > 0)
\r
655 total_of_failed_units++;
\r
656 printf(".. failed\n");
\r
658 else if(number_of_interrupted_tests > 0)
\r
660 total_of_interrupted_units++;
\r
661 printf("interrupt\n");
\r
665 total_of_successeded_units++;
\r
666 printf(".... ..ok\n");
\r
669 if(detail_summary_flag)
\r
672 xbt_dynar_foreach(include->commands, itc, command)
\r
674 printf(" %s: %s [%s]\n",
\r
675 command->status == cs_interrupted ? "INTR "
\r
676 : command->status == cs_failed ? "FAILED"
\r
677 : command->status == cs_successeded ? "PASS "
\r
679 command->context->command_line,
\r
680 command->context->pos);
\r
682 command_summarize(command);
\r
688 printf(" =====================================================================%s\n",
\r
689 number_of_failed_tests ? "== FAILED": number_of_interrupted_tests ? "==== INTR" : "====== OK");
\r
692 printf(" Summary: Test(s): %.0f%% ok (%d test(s): %d ok",
\r
693 (number_of_tests ? (1-((double)number_of_failed_tests + (double)number_of_interrupted_tests)/(double)number_of_tests)*100.0 : 100.0),
\r
694 number_of_tests, number_of_successeded_tests);
\r
696 if(number_of_failed_tests > 0)
\r
697 printf(", %d failed", number_of_failed_tests);
\r
699 if(number_of_interrupted_tests > 0)
\r
700 printf(", %d interrupted)", number_of_interrupted_tests);
\r
705 total_of_tests += number_of_tests;
\r
706 total_of_failed_tests += number_of_failed_tests;
\r
707 total_of_interrupted_tests += number_of_interrupted_tests;
\r
708 total_of_successeded_tests += number_of_successeded_tests;
\r
712 total_of_units = number_of_units;
\r
714 total_of_failed_suites = total_of_successeded_suites = total_of_interrupted_suites = 0;
\r
716 total_of_suites = xbt_dynar_length(unit->suites);
\r
718 xbt_dynar_foreach(unit->suites, its, suite)
\r
720 print_title(suite->description);
\r
722 number_of_tests_of_suite = number_of_interrupted_tests_of_suite = number_of_failed_tests_of_suite = number_of_successeded_tests_of_suite = 0;
\r
724 number_of_interrupted_units = number_of_failed_units = number_of_successeded_units = 0;
\r
726 number_of_units = xbt_dynar_length(suite->includes);
\r
728 xbt_dynar_foreach(suite->includes, itu, include)
\r
730 number_of_interrupted_tests = number_of_failed_tests = number_of_successeded_tests = 0;
\r
732 number_of_tests = xbt_dynar_length(include->commands);
\r
735 xbt_dynar_foreach(include->commands, itc, command)
\r
737 if(command->status == cs_interrupted)
\r
738 number_of_interrupted_tests++;
\r
739 else if(command->status == cs_failed)
\r
740 number_of_failed_tests++;
\r
741 else if(command->status == cs_successeded)
\r
742 number_of_successeded_tests++;
\r
745 asprintf(&p," Unit: %s ............................................................................", include->description && strlen(include->description) < 60 ? include->description : include->fstream->name);
\r
751 if(number_of_failed_tests > 0)
\r
753 number_of_failed_units++;
\r
754 printf(".. failed\n");
\r
756 else if(number_of_interrupted_tests > 0)
\r
758 number_of_interrupted_units++;
\r
759 printf("interrupt\n");
\r
763 number_of_successeded_units++;
\r
764 printf(".... ..ok\n");
\r
767 number_of_interrupted_tests_of_suite += number_of_interrupted_tests;
\r
768 number_of_failed_tests_of_suite += number_of_failed_tests;
\r
769 number_of_successeded_tests_of_suite += number_of_successeded_tests;
\r
771 number_of_tests_of_suite += number_of_tests;
\r
773 total_of_tests += number_of_tests;
\r
774 total_of_failed_tests += number_of_failed_tests;
\r
775 total_of_interrupted_tests += number_of_interrupted_tests;
\r
776 total_of_successeded_tests += number_of_successeded_tests;
\r
778 if(detail_summary_flag)
\r
781 xbt_dynar_foreach(include->commands, itc, command)
\r
783 printf(" %s: %s [%s]\n",
\r
784 command->status == cs_interrupted ? "INTR "
\r
785 : command->status == cs_failed ? "FAILED"
\r
786 : command->status == cs_successeded ? "PASS "
\r
788 command->context->command_line,
\r
789 command->context->pos);
\r
791 command_summarize(command);
\r
799 printf(" =====================================================================%s\n",
\r
800 number_of_failed_tests_of_suite ? "== FAILED": number_of_interrupted_tests_of_suite ? "==== INTR" : "====== OK");
\r
802 if(number_of_failed_tests_of_suite > 0)
\r
803 total_of_failed_suites++;
\r
804 else if(number_of_interrupted_tests_of_suite)
\r
805 total_of_interrupted_suites++;
\r
807 total_of_successeded_suites++;
\r
809 total_of_failed_units += number_of_failed_units;
\r
810 total_of_interrupted_units += number_of_interrupted_units;
\r
811 total_of_successeded_units += number_of_successeded_units;
\r
813 total_of_units += number_of_units;
\r
815 printf(" Summary: Unit(s): %.0f%% ok (%d unit(s): %d ok",
\r
816 (number_of_units ? (1-((double)number_of_failed_units + (double)number_of_interrupted_units)/(double)number_of_units)*100.0 : 100.0),
\r
817 number_of_units, number_of_successeded_units);
\r
819 if(number_of_failed_units > 0)
\r
820 printf(", %d failed", number_of_failed_units);
\r
822 if(number_of_interrupted_units > 0)
\r
823 printf(", %d interrupted)", number_of_interrupted_units);
\r
827 printf(" Test(s): %.0f%% ok (%d test(s): %d ok",
\r
828 (number_of_tests_of_suite ? (1-((double)number_of_failed_tests_of_suite + (double)number_of_interrupted_tests_of_suite)/(double)number_of_tests_of_suite)*100.0 : 100.0),
\r
829 number_of_tests_of_suite, number_of_successeded_tests_of_suite);
\r
831 if(number_of_failed_tests_of_suite > 0)
\r
832 printf(", %d failed", number_of_failed_tests_of_suite);
\r
834 if(number_of_interrupted_tests_of_suite > 0)
\r
835 printf(", %d interrupted)", number_of_interrupted_tests_of_suite);
\r
840 printf(" TOTAL : Suite(s): %.0f%% ok (%d suite(s): %d ok",
\r
841 (total_of_suites ? (1-((double)total_of_failed_suites + (double)total_of_interrupted_suites)/(double)total_of_suites)*100.0 : 100.0),
\r
842 total_of_suites, total_of_successeded_suites);
\r
844 if(total_of_failed_suites > 0)
\r
845 printf(", %d failed", total_of_failed_suites);
\r
847 if(total_of_interrupted_suites > 0)
\r
848 printf(", %d interrupted)", total_of_interrupted_suites);
\r
852 printf(" Unit(s): %.0f%% ok (%d unit(s): %d ok",
\r
853 (total_of_units ? (1-((double)total_of_failed_units + (double)total_of_interrupted_units)/(double)total_of_units)*100.0 : 100.0),
\r
854 total_of_units, total_of_successeded_units);
\r
856 if(total_of_failed_units > 0)
\r
857 printf(", %d failed", total_of_failed_units);
\r
859 if(total_of_interrupted_units > 0)
\r
860 printf(", %d interrupted)", total_of_interrupted_units);
\r
864 printf(" Test(s): %.0f%% ok (%d test(s): %d ok",
\r
865 (total_of_tests ? (1-((double)total_of_failed_tests + (double)total_of_interrupted_tests)/(double)total_of_tests)*100.0 : 100.0),
\r
866 total_of_tests, total_of_successeded_tests);
\r
868 if(total_of_failed_tests > 0)
\r
869 printf(", %d failed", total_of_failed_tests);
\r
871 if(total_of_interrupted_tests > 0)
\r
872 printf(", %d interrupted)", total_of_interrupted_tests);
\r
876 if(unit->interrupted)
\r
877 unit->runner->total_of_interrupted_units++;
\r
878 else if(total_of_failed_tests > 0)
\r
879 unit->runner->total_of_failed_units++;
\r
881 unit->runner->total_of_successeded_units++;
\r
883 unit->runner->total_of_tests += total_of_tests;
\r
884 unit->runner->total_of_failed_tests += total_of_failed_tests;
\r
885 unit->runner->total_of_successeded_tests += total_of_successeded_tests;
\r
886 unit->runner->total_of_interrupted_tests += total_of_interrupted_tests;
\r
888 unit->runner->total_of_units += total_of_units + 1;
\r
889 unit->runner->total_of_successeded_units += total_of_successeded_units;
\r
890 unit->runner->total_of_failed_units += total_of_failed_units;
\r
891 unit->runner->total_of_interrupted_units += total_of_interrupted_units;
\r
893 unit->runner->total_of_suites += total_of_suites;
\r
894 unit->runner->total_of_successeded_suites += total_of_successeded_suites;
\r
895 unit->runner->total_of_failed_suites += total_of_failed_suites;
\r
896 unit->runner->total_of_interrupted_suites += total_of_interrupted_suites;
\r
902 unit_reset(unit_t unit)
\r
907 /* reset all the suites of the unit */
\r
908 xbt_dynar_foreach(unit->suites, i, cur)
\r
914 /* reset all the includes of the unit */
\r
915 xbt_dynar_foreach(unit->includes, i, cur)
\r
920 fseek(unit->fstream->stream,0L, SEEK_SET);
\r
923 unit->started_cmd_nb = 0;
\r
924 unit->interrupted_cmd_nb = 0;
\r
925 unit->failed_cmd_nb = 0;
\r
926 unit->successeded_cmd_nb = 0;
\r
927 unit->terminated_cmd_nb = 0;
\r
928 unit->waiting_cmd_nb = 0;
\r
929 unit->interrupted = 0;
\r
931 unit->successeded = 0;
\r
933 unit->released = 0;
\r
934 unit->is_running_suite = 0;
\r
936 if(unit->description)
\r
938 free(unit->description);
\r
939 unit->description = NULL;
\r
942 unit->exit_code = 0;
\r