section: Call close_module for open_module_self

Commit a3df2ab abstracted the section handling into several functions.
For ELF, the newly created open_module_self opens a file descriptor to
the executable file which should be closed from close_module.  The
close_module call is missing in report.c and runner.c, causing EMFILE
errors during test runs when the available file descriptors are
exhausted.  This commit fixes the issue.

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
This commit is contained in:
Kevin Locke 2016-09-12 20:53:08 -06:00
parent 39c14abdcc
commit 7581417dfa
2 changed files with 6 additions and 1 deletions

View File

@ -44,11 +44,14 @@
if (!open_module_self(&self)) \
abort(); \
void *start = map_section_data(&self, CR_HSEC_STR(Kind), &sect); \
if (!start) \
if (!start) { \
close_module(&self); \
return; \
} \
void *end = (char *) start + sect.sec_len; \
for (f_report_hook *hook = start; hook < (f_report_hook *) end; ++hook) \
(*hook ? *hook : nothing)(data); \
close_module(&self); \
}
IMPL_CALL_REPORT_HOOKS(PRE_ALL)

View File

@ -168,6 +168,8 @@ struct criterion_test_set *criterion_init(void)
criterion_register_test(set, *test);
}
close_module(&self);
return set;
}