summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
45cb284)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@5601
48e7efb5-ca39-0410-a469-
dd3cf9ba447f
XBT_PUBLIC(int) xbt_test_run(char *selection);
/* Show information about the selection of tests */
XBT_PUBLIC(void) xbt_test_dump(char *selection);
XBT_PUBLIC(int) xbt_test_run(char *selection);
/* Show information about the selection of tests */
XBT_PUBLIC(void) xbt_test_dump(char *selection);
+/* Cleanup the mess */
+XBT_PUBLIC(void) xbt_test_exit(void);
/* test operations */
XBT_PUBLIC(void) _xbt_test_add(const char*file,int line, const char *fmt, ...)_XBT_GNUC_PRINTF(3,4);
/* test operations */
XBT_PUBLIC(void) _xbt_test_add(const char*file,int line, const char *fmt, ...)_XBT_GNUC_PRINTF(3,4);
else
fprintf(stderr," log=NULL\n");
}
else
fprintf(stderr," log=NULL\n");
}
-static void xbt_test_log_free(xbt_test_log_t log) {
- if (!log)
- return;
- if (log->text)
- free(log->text);
- free(log);
-}
/* test suite test check */
typedef struct s_xbt_test_test {
/* test suite test check */
typedef struct s_xbt_test_test {
+static void xbt_test_unit_free(void *unit) {
+ xbt_test_unit_t u = *(xbt_test_unit_t*)unit;
+ /* name is static */
+ free(u->title);
+ xbt_dynar_free(&u->tests);
+ free(u);
+}
+static void xbt_test_test_free(void *test) {
+ xbt_test_test_t t = *(xbt_test_test_t*)test;
+ free(t->title);
+ xbt_dynar_free(&(t->logs));
+ free(t);
+}
+static void xbt_test_log_free(void *log) {
+ xbt_test_log_t l= *(xbt_test_log_t*) log;
+ free(l->text);
+ free(l);
+}
+
/** @brief create test suite */
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);
/** @brief create test suite */
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_start(ap, fmt);
vasprintf(&suite->title,fmt, ap);
va_start(ap, fmt);
vasprintf(&suite->title,fmt, ap);
- suite->units = xbt_dynar_new(sizeof(xbt_test_unit_t), NULL);
+ suite->units = xbt_dynar_new(sizeof(xbt_test_unit_t), &xbt_test_unit_free);
va_end(ap);
suite->name = name;
suite->enabled = 1;
va_end(ap);
suite->name = name;
suite->enabled = 1;
unit->file = NULL;
unit->line = 0;
unit->enabled = 1;
unit->file = NULL;
unit->line = 0;
unit->enabled = 1;
- unit->tests = xbt_dynar_new(sizeof(xbt_test_test_t), NULL);
+ unit->tests = xbt_dynar_new(sizeof(xbt_test_test_t), xbt_test_test_free);
xbt_dynar_push(suite->units, &unit);
return;
xbt_dynar_push(suite->units, &unit);
return;
}
return _xbt_test_unit_failed;
}
}
return _xbt_test_unit_failed;
}
+void xbt_test_exit(void) {
+ xbt_dynar_free(&_xbt_test_suites);
+}
/* annotate test case with test */
void _xbt_test_add(const char*file,int line, const char *fmt, ...) {
/* annotate test case with test */
void _xbt_test_add(const char*file,int line, const char *fmt, ...) {
xbt_assert(unit);
xbt_assert(fmt);
xbt_assert(unit);
xbt_assert(fmt);
- test = xbt_new(struct s_xbt_test_test,1);
+ test = xbt_new0(struct s_xbt_test_test,1);
va_start(ap, fmt);
vasprintf(&test->title, fmt, ap);
va_end(ap);
va_start(ap, fmt);
vasprintf(&test->title, fmt, ap);
va_end(ap);
test->ignored = 0;
test->file = file;
test->line = line;
test->ignored = 0;
test->file = file;
test->line = line;
- test->logs = xbt_dynar_new(sizeof(xbt_test_log_t),NULL);
+ test->logs = xbt_dynar_new(sizeof(xbt_test_log_t),xbt_test_log_free);
xbt_dynar_push(unit->tests,&test);
return;
}
xbt_dynar_push(unit->tests,&test);
return;
}
/* Got all my tests to do */
res = xbt_test_run(selection);
/* Got all my tests to do */
res = xbt_test_run(selection);
xbt_exit();
return res;
}
xbt_exit();
return res;
}