X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/54702ce88779779500025ff0ce2d66d70cbc9f7a..b9e946cdde00d87529a22bd6e152357d8e71e935:/src/xbt/cunit.c diff --git a/src/xbt/cunit.c b/src/xbt/cunit.c index 0d1569cb6c..ab53a53787 100644 --- a/src/xbt/cunit.c +++ b/src/xbt/cunit.c @@ -72,7 +72,7 @@ typedef struct s_xbt_test_test { static void xbt_test_test_dump(xbt_test_test_t test){ if (test) { xbt_test_log_t log; - int it_log; + unsigned int it_log; fprintf(stderr," test %p(%s:%d)=%s (%s)\n", test,test->file,test->line,test->title, test->failed?"failed":"not failed"); @@ -100,7 +100,7 @@ struct s_xbt_test_unit { static void xbt_test_unit_dump(xbt_test_unit_t unit) { if (unit) { xbt_test_test_t test; - int it_test; + unsigned int it_test; fprintf(stderr," UNIT %s: %s (%s)\n", unit->name,unit->title, (unit->enabled?"enabled":"disabled")); @@ -141,7 +141,7 @@ xbt_test_suite_t xbt_test_suite_new(const char *name, const char *fmt, ...) { va_list ap; if (!_xbt_test_suites) - _xbt_test_suites = xbt_dynar_new(sizeof(xbt_test_suite_t),&xbt_test_suite_free); + _xbt_test_suites = xbt_dynar_new(sizeof(xbt_test_suite_t),xbt_test_suite_free); va_start(ap, fmt); vasprintf(&suite->title,fmt, ap); @@ -158,7 +158,7 @@ xbt_test_suite_t xbt_test_suite_new(const char *name, const char *fmt, ...) { /** @brief retrieve a testsuite from name, or create a new one */ xbt_test_suite_t xbt_test_suite_by_name(const char *name,const char *fmt, ...) { xbt_test_suite_t suite; - int it_suite; + unsigned int it_suite; char *bufname; va_list ap; @@ -180,7 +180,7 @@ xbt_test_suite_t xbt_test_suite_by_name(const char *name,const char *fmt, ...) { void xbt_test_suite_dump(xbt_test_suite_t suite) { if (suite) { xbt_test_unit_t unit; - int it_unit; + unsigned int it_unit; fprintf(stderr,"TESTSUITE %s: %s (%s)\n", suite->name, suite->title, suite->enabled?"enabled":"disabled"); @@ -225,7 +225,7 @@ static int xbt_test_suite_run(xbt_test_suite_t suite) { const char *file; int line; char *cp; - int it_unit,it_test,it_log; + unsigned int it_unit,it_test,it_log; int first=1; /* for result pretty printing */ @@ -245,13 +245,13 @@ static int xbt_test_suite_run(xbt_test_suite_t suite) { for (i=1;i<79;i++) suite_title[i]='='; suite_title[i++]='\n'; - suite_title[i]='\0'; + suite_title[79]='\0'; sprintf(suite_title + 40 - (suite_len+4)/2, "[ %s ]", suite->title); suite_title[40 + (suite_len+5)/2] = '='; if (!suite->enabled) sprintf(suite_title+ 70," DISABLED "); - fprintf(stderr, "\n%s",suite_title); + fprintf(stderr, "\n%s\n",suite_title); } if (suite->enabled) { @@ -308,12 +308,14 @@ static int xbt_test_suite_run(xbt_test_suite_t suite) { (test->failed?" FAIL":" PASS"))), test->title, file, line); - 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); - + 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); @@ -430,10 +432,10 @@ static void apply_selection(char *selection) { int done = 0; char dir[1024]; /* the directive */ /* iterators */ - int it_suite; + unsigned int it_suite; xbt_test_suite_t suite; xbt_test_unit_t unit; - int it_unit; + unsigned int it_unit; char suitename[512]; char unitname[512]; @@ -461,6 +463,10 @@ static void apply_selection(char *selection) { enabling = 0; memmove(dir,dir+1,strlen(dir)); } + if (dir[0] == '+') { + enabling = 1; + memmove(dir,dir+1,strlen(dir)); + } p =strchr(dir,':'); if (p) { @@ -488,8 +494,8 @@ static void apply_selection(char *selection) { suite->enabled = enabling; } } else { - int it; - for (it=0; itname)) { /* Do not disable the whole suite when we just want to disable a child */ @@ -501,9 +507,9 @@ static void apply_selection(char *selection) { unit->enabled = enabling; } } else { /* act on one child only */ - int it2_unit; + unsigned int it2_unit; /* search it, first (we won't reuse it for external loop which gets broken) */ - for (it2_unit=0; it2_unitunits); it2_unit++) { + for (it2_unit=0; it2_unit< xbt_dynar_length(thissuite->units); it2_unit++) { xbt_test_unit_t thisunit=xbt_dynar_get_as(thissuite->units,it2_unit,xbt_test_unit_t); if (!strcmp(thisunit->name,unitname)) { thisunit->enabled = enabling; @@ -533,7 +539,7 @@ void xbt_test_dump(char *selection) { apply_selection(selection); if (_xbt_test_suites) { - int it_suite; + unsigned int it_suite; xbt_test_suite_t suite; xbt_dynar_foreach(_xbt_test_suites,it_suite,suite) @@ -547,7 +553,7 @@ int xbt_test_run(char *selection) { apply_selection(selection); if (_xbt_test_suites) { - int it_suite; + unsigned int it_suite; xbt_test_suite_t suite; int first=1;