Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix compilation error
[simgrid.git] / src / xbt / cunit.c
index 97f37ea..4436ae5 100644 (file)
@@ -10,7 +10,7 @@
 
 #include "portable.h"
 
-#include "xbt/sysdep.h"         /* vasprintf */
+#include "xbt/sysdep.h"         /* bvprintf */
 #include "xbt/cunit.h"
 #include "xbt/dynar.h"
 
@@ -160,14 +160,13 @@ xbt_test_suite_t xbt_test_suite_new(const char *name, const char *fmt, ...)
 {
   xbt_test_suite_t suite = xbt_new0(struct s_xbt_test_suite, 1);
   va_list ap;
-  int vres;
 
   if (!_xbt_test_suites)
     _xbt_test_suites =
         xbt_dynar_new(sizeof(xbt_test_suite_t), xbt_test_suite_free);
 
   va_start(ap, fmt);
-  vres = vasprintf(&suite->title, fmt, ap);
+  suite->title = bvprintf(fmt, ap);
   suite->units =
       xbt_dynar_new(sizeof(xbt_test_unit_t), &xbt_test_unit_free);
   va_end(ap);
@@ -188,7 +187,6 @@ xbt_test_suite_t xbt_test_suite_by_name(const char *name, const char *fmt,
 
   char *bufname;
   va_list ap;
-  int vres;
 
   if (_xbt_test_suites)
     xbt_dynar_foreach(_xbt_test_suites, it_suite, suite)
@@ -196,7 +194,7 @@ xbt_test_suite_t xbt_test_suite_by_name(const char *name, const char *fmt,
       return suite;
 
   va_start(ap, fmt);
-  vres = vasprintf(&bufname, fmt, ap);
+  bufname = bvprintf(fmt, ap);
   va_end(ap);
   suite = xbt_test_suite_new(name, bufname, NULL);
   free(bufname);
@@ -226,7 +224,6 @@ void xbt_test_suite_push(xbt_test_suite_t suite, const char *name,
 {
   xbt_test_unit_t unit;
   va_list ap;
-  int vres;
 
   xbt_assert(suite);
   xbt_assert(func);
@@ -234,7 +231,7 @@ void xbt_test_suite_push(xbt_test_suite_t suite, const char *name,
 
   unit = xbt_new0(struct s_xbt_test_unit, 1);
   va_start(ap, fmt);
-  vres = vasprintf(&unit->title, fmt, ap);
+  unit->title = bvprintf(fmt, ap);
   va_end(ap);
   unit->name = (char *) name;
   unit->func = func;
@@ -260,7 +257,6 @@ static int xbt_test_suite_run(xbt_test_suite_t suite)
   unsigned int it_unit, it_test, it_log;
 
   int first = 1;                /* for result pretty printing */
-  int vres;
 
   if (suite == NULL)
     return 0;
@@ -271,7 +267,7 @@ static int xbt_test_suite_run(xbt_test_suite_t suite)
     int suite_len = strlen(suite->title);
     int i;
 
-    xbt_assert2(suite_len < 68,
+    xbt_assert(suite_len < 68,
                 "suite title \"%s\" too long (%d should be less than 68",
                 suite->title, suite_len);
 
@@ -299,9 +295,7 @@ static int xbt_test_suite_run(xbt_test_suite_t suite)
       unit->test_expect = 0;
 
       /* display unit title */
-      vres =
-          asprintf(&cp,
-                   " Unit: %s ......................................"
+      cp = bprintf(" Unit: %s ......................................"
                    "......................................", unit->title);
       cp[70] = '\0';
       fprintf(stderr, "%s", cp);
@@ -722,14 +716,13 @@ void _xbt_test_add(const char *file, int line, const char *fmt, ...)
   xbt_test_unit_t unit = _xbt_test_current_unit;
   xbt_test_test_t test;
   va_list ap;
-  int vres;
 
   xbt_assert(unit);
   xbt_assert(fmt);
 
   test = xbt_new0(struct s_xbt_test_test, 1);
   va_start(ap, fmt);
-  vres = vasprintf(&test->title, fmt, ap);
+  test->title = bvprintf(fmt, ap);
   va_end(ap);
   test->failed = 0;
   test->expected_failure = 0;
@@ -748,18 +741,17 @@ void _xbt_test_fail(const char *file, int line, const char *fmt, ...)
   xbt_test_test_t test;
   xbt_test_log_t log;
   va_list ap;
-  int vres;
 
   xbt_assert(unit);
   xbt_assert(fmt);
 
-  xbt_assert1(xbt_dynar_length(_xbt_test_current_unit->tests),
+  xbt_assert(xbt_dynar_length(_xbt_test_current_unit->tests),
               "Test failed even before being declared (broken unit: %s)",
               unit->title);
 
   log = xbt_new(struct s_xbt_test_log, 1);
   va_start(ap, fmt);
-  vres = vasprintf(&log->text, fmt, ap);
+  log->text = bvprintf(fmt, ap);
   va_end(ap);
   log->file = file;
   log->line = line;
@@ -779,7 +771,7 @@ void xbt_test_exception(xbt_ex_t e)
 void xbt_test_expect_failure(void)
 {
   xbt_test_test_t test;
-  xbt_assert1(xbt_dynar_length(_xbt_test_current_unit->tests),
+  xbt_assert(xbt_dynar_length(_xbt_test_current_unit->tests),
               "Cannot expect the failure of a test before declaring it (broken unit: %s)",
               _xbt_test_current_unit->title);
   test =
@@ -791,7 +783,7 @@ void xbt_test_skip(void)
 {
   xbt_test_test_t test;
 
-  xbt_assert1(xbt_dynar_length(_xbt_test_current_unit->tests),
+  xbt_assert(xbt_dynar_length(_xbt_test_current_unit->tests),
               "Test skiped even before being declared (broken unit: %s)",
               _xbt_test_current_unit->title);
 
@@ -807,18 +799,17 @@ void _xbt_test_log(const char *file, int line, const char *fmt, ...)
   xbt_test_test_t test;
   xbt_test_log_t log;
   va_list ap;
-  int vres;
 
   xbt_assert(unit);
   xbt_assert(fmt);
 
-  xbt_assert1(xbt_dynar_length(_xbt_test_current_unit->tests),
+  xbt_assert(xbt_dynar_length(_xbt_test_current_unit->tests),
               "Test logged into even before being declared (broken test unit: %s)",
               unit->title);
 
   log = xbt_new(struct s_xbt_test_log, 1);
   va_start(ap, fmt);
-  vres = vasprintf(&log->text, fmt, ap);
+  log->text = bvprintf(fmt, ap);
   va_end(ap);
   log->file = file;
   log->line = line;
@@ -836,13 +827,13 @@ XBT_TEST_SUITE("cunit", "Testsuite mechanism autotest");
 
 XBT_TEST_UNIT("expect", test_expected_failure, "expected failures")
 {
-  xbt_test_add0("Skipped test");
+  xbt_test_add("Skipped test");
   xbt_test_skip();
 
-  xbt_test_add2("%s %s", "EXPECTED", "FAILURE");
+  xbt_test_add("%s %s", "EXPECTED", "FAILURE");
   xbt_test_expect_failure();
-  xbt_test_log2("%s %s", "Test", "log");
-  xbt_test_fail0("EXPECTED FAILURE");
+  xbt_test_log("%s %s", "Test", "log");
+  xbt_test_fail("EXPECTED FAILURE");
 }
 
 #endif                          /* SIMGRID_TEST */