Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Make bprintf abort on error, and define bvprintf accordingly.
[simgrid.git] / src / xbt / cunit.c
index 97f37ea..8efe254 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;
@@ -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,7 +741,6 @@ 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);
@@ -759,7 +751,7 @@ void _xbt_test_fail(const char *file, int line, const char *fmt, ...)
 
   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;
@@ -807,7 +799,6 @@ 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);
@@ -818,7 +809,7 @@ void _xbt_test_log(const char *file, int line, const char *fmt, ...)
 
   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;