From 7581417dfa8901af9b8acc8a93c0bf0cf7bdc266 Mon Sep 17 00:00:00 2001 From: Kevin Locke Date: Mon, 12 Sep 2016 20:53:08 -0600 Subject: [PATCH] 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 --- src/core/report.c | 5 ++++- src/core/runner.c | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/core/report.c b/src/core/report.c index 9d1b8b3..3938949 100644 --- a/src/core/report.c +++ b/src/core/report.c @@ -44,11 +44,14 @@ if (!open_module_self(&self)) \ abort(); \ void *start = map_section_data(&self, CR_HSEC_STR(Kind), §); \ - 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) diff --git a/src/core/runner.c b/src/core/runner.c index 024dd45..7f2157e 100644 --- a/src/core/runner.c +++ b/src/core/runner.c @@ -168,6 +168,8 @@ struct criterion_test_set *criterion_init(void) criterion_register_test(set, *test); } + close_module(&self); + return set; }