Added string identifier precompilation to avoid dynamic generation in pattern matching

This commit is contained in:
Snaipe 2015-03-24 11:23:38 +01:00
parent 2faf341c9d
commit 576dc9d97e
3 changed files with 3 additions and 5 deletions

View file

@ -17,6 +17,7 @@
# define Test_(Category, Name, ...) \
TEST_PROTOTYPE_(Category, Name); \
struct criterion_test_extra_data IDENTIFIER_(Category, Name, extra) = { \
.identifier_ = #Category "/" #Name, \
.file_ = __FILE__, \
.line_ = __LINE__, \
__VA_ARGS__ \

View file

@ -29,6 +29,7 @@
struct criterion_test_extra_data {
int sentinel_;
const char *const identifier_;
const char *const file_;
const unsigned line_;
void (*init)(void);

View file

@ -59,12 +59,8 @@ IMPL_REPORT_HOOK(PRE_ALL)(struct criterion_test_set *set) {
continue;
FOREACH_SET(struct criterion_test *test, s->tests) {
char *name = NULL;
asprintf(&name, "%s/%s", s->suite.name, test->name);
if (fnmatch(criterion_options.pattern, name, 0))
if (fnmatch(criterion_options.pattern, test->data->identifier_, 0))
test->data->disabled = true;
free(name);
}
}
}