mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-04-14 14:41:42 +03:00
Run single subtest from a test file
Add mechanism to be able to select a test to run from a test file. The test harness will read the JEMALLOC_TEST_NAME env and, if set, it will only run subtests with that name.
This commit is contained in:
parent
34ace9169b
commit
0fa27fd28f
2 changed files with 23 additions and 6 deletions
|
|
@ -520,12 +520,15 @@ typedef void(test_t)(void);
|
||||||
|
|
||||||
#define TEST_BEGIN(f) \
|
#define TEST_BEGIN(f) \
|
||||||
static void f(void) { \
|
static void f(void) { \
|
||||||
p_test_init(#f);
|
const bool skip_test = p_test_init(#f); \
|
||||||
|
if (skip_test) { \
|
||||||
|
goto label_test_end; \
|
||||||
|
}
|
||||||
|
|
||||||
#define TEST_END \
|
#define TEST_END \
|
||||||
goto label_test_end; \
|
goto label_test_end; \
|
||||||
label_test_end: \
|
label_test_end: \
|
||||||
p_test_fini(); \
|
p_test_fini(skip_test); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define test(...) p_test(__VA_ARGS__, NULL)
|
#define test(...) p_test(__VA_ARGS__, NULL)
|
||||||
|
|
@ -552,6 +555,6 @@ void test_fail(const char *format, ...) JEMALLOC_FORMAT_PRINTF(1, 2);
|
||||||
test_status_t p_test(test_t *t, ...);
|
test_status_t p_test(test_t *t, ...);
|
||||||
test_status_t p_test_no_reentrancy(test_t *t, ...);
|
test_status_t p_test_no_reentrancy(test_t *t, ...);
|
||||||
test_status_t p_test_no_malloc_init(test_t *t, ...);
|
test_status_t p_test_no_malloc_init(test_t *t, ...);
|
||||||
void p_test_init(const char *name);
|
bool p_test_init(const char *name);
|
||||||
void p_test_fini(void);
|
void p_test_fini(bool skip_test);
|
||||||
void p_test_fail(bool may_abort, const char *prefix, const char *message);
|
void p_test_fail(bool may_abort, const char *prefix, const char *message);
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ static unsigned test_count = 0;
|
||||||
static test_status_t test_counts[test_status_count] = {0, 0, 0};
|
static test_status_t test_counts[test_status_count] = {0, 0, 0};
|
||||||
static test_status_t test_status = test_status_pass;
|
static test_status_t test_status = test_status_pass;
|
||||||
static const char *test_name = "";
|
static const char *test_name = "";
|
||||||
|
static const char *selected_test_name = NULL;
|
||||||
|
|
||||||
/* Reentrancy testing helpers. */
|
/* Reentrancy testing helpers. */
|
||||||
|
|
||||||
|
|
@ -100,15 +101,26 @@ test_status_string(test_status_t current_status) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
bool
|
||||||
p_test_init(const char *name) {
|
p_test_init(const char *name) {
|
||||||
|
if (selected_test_name != NULL && strcmp(selected_test_name, name)) {
|
||||||
|
/* skip test */
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
test_count++;
|
test_count++;
|
||||||
test_status = test_status_pass;
|
test_status = test_status_pass;
|
||||||
test_name = name;
|
test_name = name;
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
p_test_fini(void) {
|
p_test_fini(bool skip_test) {
|
||||||
|
if (skip_test) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
test_counts[test_status]++;
|
test_counts[test_status]++;
|
||||||
malloc_printf("%s (%s): %s\n", test_name, reentrancy_t_str(reentrancy),
|
malloc_printf("%s (%s): %s\n", test_name, reentrancy_t_str(reentrancy),
|
||||||
test_status_string(test_status));
|
test_status_string(test_status));
|
||||||
|
|
@ -130,6 +142,8 @@ check_global_slow(test_status_t *status) {
|
||||||
|
|
||||||
static test_status_t
|
static test_status_t
|
||||||
p_test_impl(bool do_malloc_init, bool do_reentrant, test_t *t, va_list ap) {
|
p_test_impl(bool do_malloc_init, bool do_reentrant, test_t *t, va_list ap) {
|
||||||
|
selected_test_name = getenv("JEMALLOC_TEST_NAME");
|
||||||
|
|
||||||
test_status_t ret;
|
test_status_t ret;
|
||||||
|
|
||||||
if (do_malloc_init) {
|
if (do_malloc_init) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue