+ /* suite title pretty-printing */
+ {
+ char suite_title[81];
+ int suite_len = strlen(suite->title);
+ int i;
+
+ xbt_assert(suite_len < 68,
+ "suite title \"%s\" too long (%d should be less than 68",
+ suite->title, suite_len);
+
+ suite_title[0] = ' ';
+ for (i = 1; i < 80; i++)
+ suite_title[i] = '=';
+ suite_title[i++] = '\n';
+ suite_title[80] = '\0';
+
+ sprintf(suite_title + 40 - (suite_len + 4) / 2, "[ %s ]",
+ suite->title);
+ suite_title[40 + (suite_len + 5) / 2] = '=';
+ if (!suite->enabled)
+ snprintf(suite_title + 70, 11, " DISABLED ");
+ fprintf(stderr, "\n%s\n", suite_title);
+ }
+
+ if (suite->enabled) {
+ /* iterate through all tests */
+ xbt_dynar_foreach(suite->units, it_unit, unit) {
+ /* init unit case counters */
+ unit->nb_tests = 0;
+ unit->test_ignore = 0;
+ unit->test_failed = 0;
+ unit->test_expect = 0;
+
+ /* display unit title */
+ cp = bprintf(" Unit: %s ......................................"
+ "......................................", unit->title);
+ cp[70] = '\0';
+ fprintf(stderr, "%s", cp);
+ free(cp);
+
+ /* run the test case function */
+ _xbt_test_current_unit = unit;
+ if (unit->enabled)
+ unit->func();
+
+ /* iterate through all performed tests to determine status */
+ xbt_dynar_foreach(unit->tests, it_test, test) {
+ if (test->ignored) {
+ unit->test_ignore++;
+ } else {
+ unit->nb_tests++;
+
+ if (test->failed && !test->expected_failure)
+ unit->test_failed++;
+ if (!test->failed && test->expected_failure)
+ unit->test_failed++;
+ if (test->expected_failure)
+ unit->test_expect++;
+ }
+ }
+
+
+ /* Display whether this unit went well */
+ if (unit->test_failed > 0 || unit->test_expect) {
+ /* some tests failed (or were supposed to), so do detailed reporting of test case */
+ if (unit->test_failed > 0) {
+ fprintf(stderr, ".. failed\n");
+ } else if (unit->nb_tests) {
+ fprintf(stderr, "...... ok\n"); /* successful, but show about expected */
+ } else {
+ fprintf(stderr, ".... skip\n"); /* shouldn't happen, but I'm a bit lost with this logic */
+ }
+ xbt_dynar_foreach(unit->tests, it_test, test) {
+ file = (test->file != NULL ? test->file : unit->file);
+ line = (test->line != 0 ? test->line : unit->line);
+ fprintf(stderr, " %s: %s [%s:%d]\n",
+ (test->ignored ? " SKIP"
+ : (test->expected_failure
+ ? (test->
+ failed ? "EFAIL" : "EPASS") : (test->failed ?
+ " FAIL" :
+ " PASS"))),
+ test->title, file, line);
+
+ if ((test->expected_failure && !test->failed)
+ || (!test->expected_failure && test->failed)) {
+ xbt_dynar_foreach(test->logs, it_log, log) {
+ file = (log->file != NULL ? log->file : file);
+ line = (log->line != 0 ? log->line : line);
+ fprintf(stderr, " %s:%d: %s\n",
+ file, line, log->text);
+
+ }
+ }
+ }
+ fprintf(stderr, " Summary: %d of %d tests failed",
+ unit->test_failed, unit->nb_tests);
+ if (unit->test_ignore) {
+ fprintf(stderr, " (%d tests ignored)\n", unit->test_ignore);
+ } else {
+ fprintf(stderr, "\n");
+ }
+
+ } else if (!unit->enabled) {
+ fprintf(stderr, " disabled\n"); /* no test were run */
+ } else if (unit->nb_tests) {
+ fprintf(stderr, "...... ok\n"); /* successful */