+++ /dev/null
-/*\r
- * src/unit.c - type representing the tesh unit concept.\r
- *\r
- * Copyright 2008,2009 Martin Quinson, Malek Cherier All right reserved. \r
- *\r
- * This program is free software; you can redistribute it and/or modify it \r
- * under the terms of the license (GNU LGPL) which comes with this package.\r
- *\r
- * Purpose:\r
- * This file contains all the definitions of the functions related with\r
- * the tesh unit concept.\r
- *\r
- */ \r
- \r
-#include <unit.h>\r
-#include <command.h>\r
-#include <context.h>\r
-#include <fstream.h>\r
-#include <variable.h>\r
-#include <str_replace.h>\r
-#include <xerrno.h>\r
- \r\r\rXBT_LOG_EXTERNAL_DEFAULT_CATEGORY(tesh);
-\r\r
-/*! \brief unit_start - start the processing of the tesh file representing by the unit\r
- *\r
- * \param p A void pointer to the unit representing the tesh file to process.\r
- *\r
- * \return This function (thread routine always returns NULL)\r
- *\r
- * Scenario :\r
- * \r
- * 1) The unit increment the number of running unit of the runner.\r
- * 2) The unit wait for the jobs semaphore to realy start its job.\r
- * 3) The unit runs the parsing of its tesh file using an fstream object.\r
- * 3.1) The fstream object parse the tesh file an launch each command with its context of execution.\r
- * 3.2) If a syntax error is detected the fstream object handle the failure and signals it by setting\r
- * the flag interrupted of the unit to one (depending of the keep-going and keep-going-unit flag values)\r
- * 3.3) If a command failed (exit code do not match, timeout, ouptupt different from the expected..)\r
- * the command handle the failure (see command_handle_failure() for more details).\r
- * 4) After the parsing of the tesh file.\r
- * 4.1) If all commands are successeded the last command release the unit by releasing its semaphore. \r
- * 4.2) If a command failed or if the tesh file is malformated the unit interrupt all the commands in progress.\r
- * 5) The unit wait for the end of all the threads associated with a command.\r
- * 6) Its release the next waiting unit (if any) by releasing the jobs semaphore.\r
- * 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
- * \r
- */ \r
-static void *\r unit_start(void *p) \r
-{
- \rxbt_os_thread_t thread;
- \rxbt_os_mutex_t mutex;
- \runit_t include, suite;
- \runsigned int itc, itu, its;
- \rint include_nb, suite_nb;
- \rcommand_t command;
- \r\runit_t root = (unit_t) p;
- \r\r
- /* increment the number of running units */ \r
- xbt_os_mutex_acquire(root->mutex);
- \rroot->runner->number_of_runned_units++;
- \rxbt_os_mutex_release(root->mutex);
- \r\r
- /* must acquire the jobs semaphore to start */ \r
- /*xbt_os_sem_acquire(jobs_sem); */ \r
- \r
- /* initialize the mutex used to synchronize the access to the properties of this unit */ \r
- mutex = xbt_os_mutex_init();
- \r\rif (!dry_run_flag)
- \rINFO1("Test unit from %s", root->fstream->name);
- \r
- else
- \rINFO1("Checking unit %s...", root->fstream->name);
- \r\r
- /* launch the parsing of the unit */ \r
- fstream_parse(root->fstream, mutex);
- \r\r
- /* if the unit is not interrupted and not failed the unit, all the file is parsed\r
- * so all the command are launched\r
- */ \r
- if (!root->interrupted)
- \r {
- \rroot->parsed = 1;
- \r\r
- /* all the commands have terminated before the end of the parsing of the tesh file\r
- * so the unit release the semaphore itself\r
- */ \r
- if (!root->released
- && (root->started_cmd_nb ==
- (root->failed_cmd_nb + root->interrupted_cmd_nb +
- root->successeded_cmd_nb)))
- \rxbt_os_sem_release(root->sem);
- \r}
- \r\r
- /* wait the end of all the commands or a command failure or an interruption */ \r
- \rxbt_os_sem_acquire(root->sem);
- \r\r\rif (root->interrupted)
- \r {
- \r\rxbt_dynar_foreach(root->commands, itc, command) \r {
- \rif (command->status == cs_in_progress)
- \rcommand_interrupt(command);
- \r}
- \r\r
- /* interrupt all the running commands of the included units */ \r
- include_nb = xbt_dynar_length(root->includes);
- \r\rxbt_dynar_foreach(root->includes, itu, include) \r {
- \rxbt_dynar_foreach(include->commands, itc, command) \r {
- \rif (command->status == cs_in_progress)
- \rcommand_interrupt(command);
- \r}
- \r}
- \r\r
- /* interrupt all the running commands of the unit */ \r
- suite_nb = xbt_dynar_length(root->suites);
- \r\rxbt_dynar_foreach(root->suites, its, suite) \r {
- \rinclude_nb = xbt_dynar_length(suite->includes);
- \r\rxbt_dynar_foreach(suite->includes, itu, include) \r {
- \rxbt_dynar_foreach(include->commands, itc, command) \r {
- \rif (command->status == cs_in_progress)
- \rcommand_interrupt(command);
- \r}
- \r}
- \r}
- \r}
- \r\r
- /* wait the end of the command threads of the unit */ \r
- xbt_dynar_foreach(root->commands, itc, command) \r {
- \rthread = command->thread;
- \r\rif (thread)
- \rxbt_os_thread_join(thread, NULL);
- \r}
- \r\r
- /* wait the end of the command threads of the included units of the unit */ \r
- include_nb = xbt_dynar_length(root->includes);
- \r\rxbt_dynar_foreach(root->includes, itu, include) \r {
- \rxbt_dynar_foreach(include->commands, itc, command) \r {
- \rthread = command->thread;
- \r\rif (thread)
- \rxbt_os_thread_join(thread, NULL);
- \r}
- \r\rif (!dry_run_flag)
- \r {
- \rif (!include->exit_code && !include->interrupted)
- \rINFO1("Include from %s OK", include->fstream->name);
- \r
- else if (include->exit_code)
- \rERROR3("Include `%s' NOK : (<%s> %s)", include->fstream->name,
- include->err_line, error_to_string(include->exit_code,
- include->err_kind));
- \r
- else if (include->interrupted && !include->exit_code)
- \rINFO1("Include `(%s)' INTR", include->fstream->name);
- \r}
- \r}
- \r\r
- /* interrupt all the running commands of the unit */ \r
- suite_nb = xbt_dynar_length(root->suites);
- \r\rxbt_dynar_foreach(root->suites, its, suite) \r {
- \rinclude_nb = xbt_dynar_length(suite->includes);
- \r\rif (!include_nb)
- \r {
- \rif (!suite->exit_code)
- \r {
- \runit_set_error(suite, ESYNTAX, 1, suite->filepos);
- \rERROR2("[%s] Empty suite `(%s)' detected (no includes added)",
- suite->filepos, suite->description);
- \r\r
- /* if the --keep-going option is not specified */ \r
- if (!keep_going_flag)
- \r {
- \rif (!interrupted)
- \r {
- \r
- /* request an global interruption by the runner */ \r
- interrupted = 1;
- \r\r
- /* release the runner */ \r
- xbt_os_sem_release(units_sem);
- \r}
- \r}
- \r}
- \r}
- \r\rxbt_dynar_foreach(suite->includes, itu, include) \r {
- \rxbt_dynar_foreach(include->commands, itc, command) \r {
- \rthread = command->thread;
- \r\rif (thread)
- \rxbt_os_thread_join(thread, NULL);
- \r}
- \r\rif (!include->exit_code && !include->interrupted)
- \r {
- \rif (!dry_run_flag)
- \rINFO1("Include from %s OK", include->fstream->name);
- \r}
- \r
- else if (include->exit_code)
- \r {
- \rif (!dry_run_flag)
- \rERROR3("Include `%s' NOK : (<%s> %s)", include->fstream->name,
- command->context->pos,
- error_to_string(include->exit_code, include->err_kind));
- \r\rsuite->exit_code = include->exit_code;
- \rsuite->err_kind = include->err_kind;
- \rsuite->err_line = strdup(include->err_line);
- \r}
- \r
- else if (include->interrupted && !include->exit_code)
- \r {
- \rif (!dry_run_flag)
- \rINFO1("Include `(%s)' INTR", include->fstream->name);
- \r\rsuite->interrupted = 1;
- \r}
- \r\r}
- \r\rif (!dry_run_flag)
- \r {
- \rif (!suite->exit_code && !suite->interrupted)
- \rINFO1("Test suite from %s OK", suite->description);
- \r
- else if (suite->exit_code)
- \rERROR3("Test suite `%s' NOK : (<%s> %s) ", suite->description,
- suite->err_line, error_to_string(suite->exit_code,
- suite->err_kind));
- \r
- else if (suite->interrupted && !suite->exit_code)
- \rINFO1("Test suite `(%s)' INTR", suite->description);
- \r}
- \r}
- \r\r
- /* you can now destroy the mutex used to synchrone the command accesses to the properties of the unit */ \r
- xbt_os_mutex_destroy(mutex);
- \r\r
- /* update the number of ended units of the runner */ \r
- xbt_os_mutex_acquire(root->mutex);
- \r\r
- /* increment the number of ended units */ \r
- root->runner->number_of_ended_units++;
- \r\rif (!dry_run_flag)
- \r {
- \rif (root->interrupted && !root->exit_code)
- \rINFO1("Test unit from %s INTR", root->fstream->name);
- \r
- else if (!root->exit_code)
- \rINFO1("Test unit from %s OK", root->fstream->name);
- \r
- else if (root->exit_code)
- \rERROR3("Test unit `%s': NOK (<%s> %s)", root->fstream->name,
- root->err_line, error_to_string(root->exit_code,
- root->err_kind));
- \r}
- \r\r
- /* if it's the last unit, release the runner */ \r
- if ((root->runner->number_of_runned_units ==
- root->runner->number_of_ended_units))
- \r {
- \r
- /* if all the commands of the unit are successeded itc's a successeded unit */ \r
- if (root->successeded_cmd_nb == root->cmd_nb
- && !root->
- exit_code /* case of only one cd : nb = successeded = 0) */ )
- \rroot->successeded = 1;
- \r\r
- /* first release the mutex */ \r
- xbt_os_mutex_release(root->mutex);
- \r\r
- /* release the runner */ \r
- xbt_os_sem_release(units_sem);
- \r}
- \r
- else
- \rxbt_os_mutex_release(root->mutex);
- \r\r
- /* release the jobs semaphore, then the next waiting unit can start */ \r
- xbt_os_sem_release(jobs_sem);
- \r\rreturn NULL;
-\r\r}
-
-\r\r\runit_t \r
-unit_new(runner_t runner, unit_t root, unit_t owner, fstream_t fstream) \r
-{
- \runit_t unit;
- \r\runit = xbt_new0(s_unit_t, 1);
- \r\r
- /* instantiate the vector used to store all the commands of the unit */ \r
- unit->commands =
- xbt_dynar_new(sizeof(command_t), (void_f_pvoid_t) command_free);
- \r\r
- /* instantiate the vector used to store all the included units */ \r
- unit->includes =
- xbt_dynar_new(sizeof(unit_t), (void_f_pvoid_t) unit_free);
- \r\r
- /* instantiate the vector used to store all the included suites */ \r
- unit->suites =
- xbt_dynar_new(sizeof(unit_t), (void_f_pvoid_t) unit_free);
- \r\r
- /* the runner used to launch the tesh unit */ \r
- unit->runner = runner;
- \r\r
- /* the file stream object to use to parse the tesh file */ \r
- unit->fstream = fstream;
- \r\rif (fstream)
- \rfstream->unit = unit;
- \r\r
- /* if no root parameter specified assume that itc's the root of all the units */ \r
- unit->root = root ? root : unit;
- \r\r
- /* the owner of the suite */ \r
- unit->owner = owner;
- \r\runit->thread = NULL;
- \runit->started_cmd_nb = 0;
- \runit->interrupted_cmd_nb = 0;
- \runit->failed_cmd_nb = 0;
- \runit->successeded_cmd_nb = 0;
- \runit->terminated_cmd_nb = 0;
- \runit->waiting_cmd_nb = 0;
- \runit->interrupted = 0;
- \runit->failed = 0;
- \runit->successeded = 0;
- \runit->parsed = 0;
- \runit->released = 0;
- \runit->owner = owner;
- \runit->is_running_suite = 0;
- \runit->description = NULL;
- \runit->sem = NULL;
- \runit->exit_code = 0;
- \runit->err_kind = 0;
- \runit->err_line = NULL;
- \runit->filepos = NULL;
- \r\r\r\rreturn unit;
-\r}
-
-\r\rvoid \r
-unit_set_error(unit_t unit, int errcode, int kind, const char *line) \r
-{
- \rif (!unit->exit_code)
- \r {
- \runit->exit_code = errcode;
- \runit->err_kind = kind;
- \runit->err_line = strdup(line);
- \r\rif (unit->root && !unit->root->exit_code)
- \r {
- \runit->root->exit_code = errcode;
- \runit->root->err_kind = kind;
- \runit->root->err_line = strdup(line);
- \r}
- \r\rif (!exit_code)
- \r {
- \r\rexit_code = errcode;
- \rerr_kind = kind;
- \rerr_line = strdup(line);
- \r}
- \r}
-\r\r}
-
-\r\rint \r unit_free(unit_t * ptr) \r
-{
- \rif (!(*ptr))
- \r {
- \rerrno = EINVAL;
- \rreturn -1;
- \r}
- \r\rif ((*ptr)->commands)
- \rxbt_dynar_free(&((*ptr)->commands));
- \r\rif ((*ptr)->includes)
- \rxbt_dynar_free(&((*ptr)->includes));
- \r\rif ((*ptr)->suites)
- \rxbt_dynar_free(&((*ptr)->suites));
- \r\r
- /* if the unit is interrupted during its run, the semaphore is NULL */ \r
- if ((*ptr)->sem)
- \rxbt_os_sem_destroy((*ptr)->sem);
- \r\rif ((*ptr)->description)
- \rfree((*ptr)->description);
- \r\rif ((*ptr)->err_line)
- \rfree((*ptr)->err_line);
- \r\rif ((*ptr)->filepos)
- \rfree((*ptr)->filepos);
- \r\rfree(*ptr);
- \r*ptr = NULL;
- \r\rreturn 0;
-\r}
-
-\r\rint \r unit_run(unit_t unit, xbt_os_mutex_t mutex) \r
-{
- \r
- /* check the parameters */ \r
- if (!(unit) || !mutex)
- \r {
- \rerrno = EINVAL;
- \rxbt_os_sem_release(jobs_sem);
- \rreturn -1;
- \r\r}
- \r\rif (!interrupted)
- \r {
- \runit->mutex = mutex;
- \r\runit->sem = xbt_os_sem_init(0);
- \r\r
- /* start the unit */ \r
- unit->thread = xbt_os_thread_create("", unit_start, unit);
- \r}
- \r
- else
- \r {
- \r
- /* the unit is interrupted by the runner before its starting \r
- * in this case the unit semaphore is NULL take care of that\r
- * in the function unit_free()\r
- */ \r
- unit->interrupted = 1;
- \rxbt_os_sem_release(jobs_sem);
- \r}
- \r\rreturn 0;
-\r\r}
-
-\r\rint \r unit_interrupt(unit_t unit) \r
-{
- \r
- /* check the parameter */ \r
- if (!(unit))
- \r {
- \rerrno = EINVAL;
- \rreturn -1;
- \r}
- \r\r
- /* if the unit is already interrupted, signal the error */ \r
- if (unit->interrupted)
- \r {
- \rerrno = EALREADY;
- \rreturn -1;
- \r}
- \r\r
- /* interrupt the run of the specified unit */ \r
- unit->interrupted = 1;
- \rxbt_os_sem_release(unit->sem);
- \r\rreturn 0;
-\r}
-
-\r\r
-/* just print the title of the root unit or a suite (if any) */ \r
-static void \r print_title(const char *description) \r
-{
- \rregister int i;
- \rchar title[80];
- \rsize_t len = strlen(description);
- \r\rtitle[0] = ' ';
- \r\rfor (i = 1; i < 79; i++)
- \rtitle[i] = '=';
- \r\rtitle[i++] = '\n';
- \rtitle[79] = '\0';
- \r\rsprintf(title + 40 - (len + 4) / 2, "[ %s ]", description);
- \rtitle[40 + (len + 5) / 2] = '=';
- \r\rprintf("\n%s\n", title);
-\r}
-
-\r\rint \r unit_summuarize(unit_t unit) \r
-{
- \rcommand_t command;
- \runsigned int itc, itu, its;
- \runit_t include;
- \runit_t suite;
- \rchar *p;
- \rchar title[PATH_MAX + 1] = { 0 };
- \r\rint number_of_tests = 0; /* number of tests of a unit contained by this unit */
- \rint number_of_failed_tests = 0; /* number of failed test of a unit contained by this unit */
- \rint number_of_successeded_tests = 0; /* number of successeded tests of a unit contained by this unit */
- \rint number_of_interrupted_tests = 0; /* number of interrupted tests of a unit contained by this unit */
- \r\rint number_of_tests_of_suite = 0; /* number of tests of a suite contained by this unit */
- \rint number_of_interrupted_tests_of_suite = 0; /* number of interrupted tests of a suite contained by this unit */
- \rint number_of_failed_tests_of_suite = 0; /* number of failed tests of a suite contained by this unit */
- \rint number_of_successeded_tests_of_suite = 0; /* number of successeded tests of a suite contained by this */
- \r\rint number_of_units = 0; /* number of units contained by a suite */
- \rint number_of_failed_units = 0; /* number of failed units contained by a suite */
- \rint number_of_successeded_units = 0; /* number of successeded units contained by a suite */
- \rint number_of_interrupted_units = 0; /* number of interrupted units contained by a suite */
- \r\rint total_of_tests = 0; /* total of the tests contained by this unit */
- \rint total_of_failed_tests = 0; /* total of failed tests contained by this unit */
- \rint total_of_successeded_tests = 0; /* total of successeded tests contained by this unit */
- \rint total_of_interrupted_tests = 0; /* total of interrupted tests contained by this unit */
- \r\rint total_of_units = 0; /* total of units contained by this unit */
- \rint total_of_failed_units = 0; /* total of failed units contained by this unit */
- \rint total_of_successeded_units = 0; /* total of successeded units contained by this unit */
- \rint total_of_interrupted_units = 0; /* total of interrutped units contained by this unit */
- \r\rint total_of_suites = 0; /* total of suites contained by this unit */
- \rint total_of_failed_suites = 0; /* total of failed suites contained by this unit */
- \rint total_of_successeded_suites = 0; /* total of successeded suites contained by this unit */
- \rint total_of_interrupted_suites = 0; /* total of interrupted suites contained by this unit */
- \r\r
- /* check the parameter */ \r
- if (!(unit))
- \r {
- \rerrno = EINVAL;
- \rreturn -1;
- \r}
- \r\rif ((unit->description) && strlen(unit->description) < 76)
- \rstrcpy(title, unit->description);
- \r
- else
- \rsprintf(title, "file : %s", unit->fstream->name);
- \r\rif (unit->interrupted)
- \r {
- \rif (strlen(title) + strlen(" (interrupted)") < 76)
- \rstrcat(title, " (interrupted)");
- \r
- else
- \r {
- \rmemset(title, 0, PATH_MAX + 1);
- \rsprintf(title, "file : %s", unit->fstream->name);
- \rstrcat(title, " (interrupted)");
- \r\r}
- \r}
- \r\rprint_title(title);
- \r\rnumber_of_tests = xbt_dynar_length(unit->commands);
- \r\r
- /* tests */ \r
- xbt_dynar_foreach(unit->commands, itc, command) \r {
- \rif (command->status == cs_interrupted)
- \rnumber_of_interrupted_tests++;
- \r
- else if (command->status == cs_failed)
- \rnumber_of_failed_tests++;
- \r
- else if (command->status == cs_successeded)
- \rnumber_of_successeded_tests++;
- \r}
- \r\r\rif (number_of_tests)
- \r {
- \rasprintf(&p,
- " Test(s): .........................................................................");
- \r\rp[70] = '\0';
- \rprintf("%s", p);
- \rfree(p);
- \r\rif (number_of_failed_tests > 0)
- \rprintf(".. failed\n");
- \r
- else if (number_of_interrupted_tests > 0)
- \rprintf("interrupt\n");
- \r
- else
- \rprintf(".... ..ok\n");
- \r\rxbt_dynar_foreach(unit->commands, itc, command) \r {
- \rprintf(" %s: %s [%s]\n",
- \rcommand->status ==
- cs_interrupted ? "INTR " \r : command->status ==
- cs_failed ? "FAILED" \r : command->status ==
- cs_successeded ? "PASS " \r : "UNKNWN",
- \rcommand->context->command_line, \rcommand->context->pos);
- \r\rif (detail_summary_flag)
- \rcommand_summarize(command);
- \r}
- \r\rprintf
- (" =====================================================================%s\n",
- \rnumber_of_failed_tests ? "== FAILED" :
- number_of_interrupted_tests ? "==== INTR" : "====== OK");
- \r\rprintf(" Summary: Test(s): %.0f%% ok (%d test(s): %d ok",
- \r((1 -
- ((double) number_of_failed_tests +
- (double) number_of_interrupted_tests) /
- (double) number_of_tests) * 100.0), \rnumber_of_tests,
- number_of_successeded_tests);
- \r\rif (number_of_failed_tests > 0)
- \rprintf(", %d failed", number_of_failed_tests);
- \r\rif (number_of_interrupted_tests > 0)
- \rprintf(", %d interrupted)", number_of_interrupted_tests);
- \r\rprintf(")\n\n");
- \r\rtotal_of_tests = number_of_tests;
- \rtotal_of_failed_tests = number_of_failed_tests;
- \rtotal_of_interrupted_tests = number_of_interrupted_tests;
- \rtotal_of_successeded_tests = number_of_successeded_tests;
- \r}
- \r\r\r\r
- /* includes */ \r
- total_of_failed_units = total_of_interrupted_units =
- total_of_successeded_units = 0;
- \rnumber_of_failed_units = number_of_successeded_units =
- number_of_interrupted_units = 0;
- \rnumber_of_units = xbt_dynar_length(unit->includes);
- \r\rxbt_dynar_foreach(unit->includes, itu, include) \r {
- \r\rnumber_of_interrupted_tests = number_of_failed_tests =
- number_of_successeded_tests = 0;
- \r\rnumber_of_tests = xbt_dynar_length(include->commands);
- \r\rxbt_dynar_foreach(include->commands, itc, command) \r {
- \rif (command->status == cs_interrupted)
- \rnumber_of_interrupted_tests++;
- \r
- else if (command->status == cs_failed)
- \rnumber_of_failed_tests++;
- \r
- else if (command->status == cs_successeded)
- \rnumber_of_successeded_tests++;
- \r}
- \r\rasprintf(&p,
- " Unit: %s ............................................................................",
- include->description
- && strlen(include->description) <
- 60 ? include->description : include->fstream->name);
- \r\rp[70] = '\0';
- \rprintf("%s", p);
- \rfree(p);
- \r\rif (number_of_failed_tests > 0)
- \r {
- \rtotal_of_failed_units++;
- \rprintf(".. failed\n");
- \r}
- \r
- else if (number_of_interrupted_tests > 0)
- \r {
- \rtotal_of_interrupted_units++;
- \rprintf("interrupt\n");
- \r}
- \r
- else
- \r {
- \rtotal_of_successeded_units++;
- \rprintf(".... ..ok\n");
- \r}
- \r\rif (detail_summary_flag)
- \r {
- \r\rxbt_dynar_foreach(include->commands, itc, command) \r {
- \rprintf(" %s: %s [%s]\n",
- \rcommand->status ==
- cs_interrupted ? "INTR " \r : command->status ==
- cs_failed ? "FAILED" \r : command->status ==
- cs_successeded ? "PASS " \r : "UNKNWN",
- \rcommand->context->command_line, \rcommand->context->pos);
- \r\rcommand_summarize(command);
- \r}
- \r\r\r}
- \r\rprintf
- (" =====================================================================%s\n",
- \rnumber_of_failed_tests ? "== FAILED" :
- number_of_interrupted_tests ? "==== INTR" : "====== OK");
- \r\r\rprintf(" Summary: Test(s): %.0f%% ok (%d test(s): %d ok",
- \r(number_of_tests
- ? (1 -
- ((double) number_of_failed_tests +
- (double) number_of_interrupted_tests) /
- (double) number_of_tests) * 100.0 : 100.0),
- \rnumber_of_tests, number_of_successeded_tests);
- \r\rif (number_of_failed_tests > 0)
- \rprintf(", %d failed", number_of_failed_tests);
- \r\rif (number_of_interrupted_tests > 0)
- \rprintf(", %d interrupted)", number_of_interrupted_tests);
- \r\rprintf(")\n\n");
- \r\r\rtotal_of_tests += number_of_tests;
- \rtotal_of_failed_tests += number_of_failed_tests;
- \rtotal_of_interrupted_tests += number_of_interrupted_tests;
- \rtotal_of_successeded_tests += number_of_successeded_tests;
- \r}
- \r\r
- /* suites */ \r
- total_of_units = number_of_units;
- \r\rtotal_of_failed_suites = total_of_successeded_suites =
- total_of_interrupted_suites = 0;
- \r\rtotal_of_suites = xbt_dynar_length(unit->suites);
- \r\rxbt_dynar_foreach(unit->suites, its, suite) \r {
- \rprint_title(suite->description);
- \r\rnumber_of_tests_of_suite = number_of_interrupted_tests_of_suite =
- number_of_failed_tests_of_suite =
- number_of_successeded_tests_of_suite = 0;
- \r\rnumber_of_interrupted_units = number_of_failed_units =
- number_of_successeded_units = 0;
- \r\rnumber_of_units = xbt_dynar_length(suite->includes);
- \r\rxbt_dynar_foreach(suite->includes, itu, include) \r {
- \rnumber_of_interrupted_tests = number_of_failed_tests =
- number_of_successeded_tests = 0;
- \r\rnumber_of_tests = xbt_dynar_length(include->commands);
- \r\r\rxbt_dynar_foreach(include->commands, itc, command) \r {
- \rif (command->status == cs_interrupted)
- \rnumber_of_interrupted_tests++;
- \r
- else if (command->status == cs_failed)
- \rnumber_of_failed_tests++;
- \r
- else if (command->status == cs_successeded)
- \rnumber_of_successeded_tests++;
- \r}
- \r\rasprintf(&p,
- " Unit: %s ............................................................................",
- include->description
- && strlen(include->description) <
- 60 ? include->description : include->fstream->name);
- \r\rp[70] = '\0';
- \rprintf("%s", p);
- \rfree(p);
- \r\rif (number_of_failed_tests > 0)
- \r {
- \rnumber_of_failed_units++;
- \rprintf(".. failed\n");
- \r}
- \r
- else if (number_of_interrupted_tests > 0)
- \r {
- \rnumber_of_interrupted_units++;
- \rprintf("interrupt\n");
- \r}
- \r
- else
- \r {
- \rnumber_of_successeded_units++;
- \rprintf(".... ..ok\n");
- \r}
- \r\rnumber_of_interrupted_tests_of_suite +=
- number_of_interrupted_tests;
- \rnumber_of_failed_tests_of_suite += number_of_failed_tests;
- \rnumber_of_successeded_tests_of_suite += number_of_successeded_tests;
- \r\rnumber_of_tests_of_suite += number_of_tests;
- \r\rtotal_of_tests += number_of_tests;
- \rtotal_of_failed_tests += number_of_failed_tests;
- \rtotal_of_interrupted_tests += number_of_interrupted_tests;
- \rtotal_of_successeded_tests += number_of_successeded_tests;
- \r\rif (detail_summary_flag)
- \r {
- \r\rxbt_dynar_foreach(include->commands, itc, command) \r {
- \rprintf(" %s: %s [%s]\n",
- \rcommand->status ==
- cs_interrupted ? "INTR " \r : command->status ==
- cs_failed ? "FAILED" \r : command->status ==
- cs_successeded ? "PASS " \r : "UNKNWN",
- \rcommand->context->command_line, \rcommand->context->pos);
- \r\rcommand_summarize(command);
- \r}
- \r\r\r}
- \r\r}
- \r\rprintf
- (" =====================================================================%s\n",
- \rnumber_of_failed_tests_of_suite ? "== FAILED" :
- number_of_interrupted_tests_of_suite ? "==== INTR" : "====== OK");
- \r\rif (number_of_failed_tests_of_suite > 0)
- \rtotal_of_failed_suites++;
- \r
- else if (number_of_interrupted_tests_of_suite)
- \rtotal_of_interrupted_suites++;
- \r
- else
- \rtotal_of_successeded_suites++;
- \r\rtotal_of_failed_units += number_of_failed_units;
- \rtotal_of_interrupted_units += number_of_interrupted_units;
- \rtotal_of_successeded_units += number_of_successeded_units;
- \r\rtotal_of_units += number_of_units;
- \r\rprintf(" Summary: Unit(s): %.0f%% ok (%d unit(s): %d ok", \r
- (number_of_units
- ? (1 -
- ((double) number_of_failed_units +
- (double) number_of_interrupted_units) /
- (double) number_of_units) * 100.0 : 100.0),
- \rnumber_of_units, number_of_successeded_units);
- \r\rif (number_of_failed_units > 0)
- \rprintf(", %d failed", number_of_failed_units);
- \r\rif (number_of_interrupted_units > 0)
- \rprintf(", %d interrupted)", number_of_interrupted_units);
- \r\rprintf(")\n");
- \r\rprintf(" Test(s): %.0f%% ok (%d test(s): %d ok", \r
- (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),
- \rnumber_of_tests_of_suite,
- number_of_successeded_tests_of_suite);
- \r\rif (number_of_failed_tests_of_suite > 0)
- \rprintf(", %d failed", number_of_failed_tests_of_suite);
- \r\rif (number_of_interrupted_tests_of_suite > 0)
- \rprintf(", %d interrupted)", number_of_interrupted_tests_of_suite);
- \r\rprintf(")\n\n");
- \r}
- \r\rprintf(" TOTAL : Suite(s): %.0f%% ok (%d suite(s): %d ok", \r
- (total_of_suites
- ? (1 -
- ((double) total_of_failed_suites +
- (double) total_of_interrupted_suites) /
- (double) total_of_suites) * 100.0 : 100.0),
- \rtotal_of_suites, total_of_successeded_suites);
- \r\rif (total_of_failed_suites > 0)
- \rprintf(", %d failed", total_of_failed_suites);
- \r\rif (total_of_interrupted_suites > 0)
- \rprintf(", %d interrupted)", total_of_interrupted_suites);
- \r\rprintf(")\n");
- \r\rprintf(" Unit(s): %.0f%% ok (%d unit(s): %d ok", \r
- (total_of_units
- ? (1 -
- ((double) total_of_failed_units +
- (double) total_of_interrupted_units) /
- (double) total_of_units) * 100.0 : 100.0), \rtotal_of_units,
- total_of_successeded_units);
- \r\rif (total_of_failed_units > 0)
- \rprintf(", %d failed", total_of_failed_units);
- \r\rif (total_of_interrupted_units > 0)
- \rprintf(", %d interrupted)", total_of_interrupted_units);
- \r\rprintf(")\n");
- \r\rprintf(" Test(s): %.0f%% ok (%d test(s): %d ok", \r
- (total_of_tests
- ? (1 -
- ((double) total_of_failed_tests +
- (double) total_of_interrupted_tests) /
- (double) total_of_tests) * 100.0 : 100.0), \rtotal_of_tests,
- total_of_successeded_tests);
- \r\rif (total_of_failed_tests > 0)
- \rprintf(", %d failed", total_of_failed_tests);
- \r\rif (total_of_interrupted_tests > 0)
- \rprintf(", %d interrupted)", total_of_interrupted_tests);
- \r\rprintf(")\n\n");
- \r\rif (unit->interrupted)
- \runit->runner->total_of_interrupted_units++;
- \r
- else if (total_of_failed_tests > 0)
- \runit->runner->total_of_failed_units++;
- \r
- else
- \runit->runner->total_of_successeded_units++;
- \r\runit->runner->total_of_tests += total_of_tests;
- \runit->runner->total_of_failed_tests += total_of_failed_tests;
- \runit->runner->total_of_successeded_tests += total_of_successeded_tests;
- \runit->runner->total_of_interrupted_tests += total_of_interrupted_tests;
- \r\runit->runner->total_of_units += total_of_units + 1;
- \runit->runner->total_of_successeded_units += total_of_successeded_units;
- \runit->runner->total_of_failed_units += total_of_failed_units;
- \runit->runner->total_of_interrupted_units += total_of_interrupted_units;
- \r\runit->runner->total_of_suites += total_of_suites;
- \runit->runner->total_of_successeded_suites +=
- total_of_successeded_suites;
- \runit->runner->total_of_failed_suites += total_of_failed_suites;
- \runit->runner->total_of_interrupted_suites +=
- total_of_interrupted_suites;
- \r\rreturn 0;
-\r}
-
-\r\rint \r unit_reset(unit_t unit) \r
-{
- \runit_t cur;
- \runsigned int i;
- \r\r
- /* reset all the suites of the unit */ \r
- xbt_dynar_foreach(unit->suites, i, cur) \r {
- \runit_reset(cur);
- \r} \r\r\r
- /* reset all the includes of the unit */ \r
- xbt_dynar_foreach(unit->includes, i, cur) \r {
- \runit_reset(cur);
- \r} \r\rfseek(unit->fstream->stream, 0L, SEEK_SET);
- \runit->parsed = 0;
- \runit->cmd_nb = 0;
- \runit->started_cmd_nb = 0;
- \runit->interrupted_cmd_nb = 0;
- \runit->failed_cmd_nb = 0;
- \runit->successeded_cmd_nb = 0;
- \runit->terminated_cmd_nb = 0;
- \runit->waiting_cmd_nb = 0;
- \runit->interrupted = 0;
- \runit->failed = 0;
- \runit->successeded = 0;
- \runit->parsed = 0;
- \runit->released = 0;
- \runit->is_running_suite = 0;
- \r\rif (unit->description)
- \r {
- \rfree(unit->description);
- \runit->description = NULL;
- \r}
- \r\runit->exit_code = 0;
- \r\rreturn 0;
-\r}
-
-\r