From 7cadc6105b00f8d8ef166929118a95ce69221603 Mon Sep 17 00:00:00 2001 From: Arkadiusz Hiler Date: Mon, 1 Apr 2019 08:57:22 +0300 Subject: runner: Reinitialize compiled dmesg regexp each parsing session Which regexp gets compiled is settings specific, depending whether we run piglit-style or not. If it's optimized to be initialized only once and it is a global variable, it will be "stuck" in the mode we have selected with the first run, which may break tests. Let's remove this optimization and initialize it each time, as it takes less 0.002s on my hardware. Signed-off-by: Arkadiusz Hiler Reviewed-by: Simon Ser --- runner/resultgen.c | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) (limited to 'runner') diff --git a/runner/resultgen.c b/runner/resultgen.c index 32b59d59..23eb8903 100644 --- a/runner/resultgen.c +++ b/runner/resultgen.c @@ -499,27 +499,18 @@ static const char igt_dmesg_whitelist[] = static const char igt_piglit_style_dmesg_blacklist[] = "(\\[drm:|drm_|intel_|i915_)"; -static regex_t re; - -static int init_regex_whitelist(struct settings *settings) +static bool init_regex_whitelist(struct settings* settings, regex_t* re) { - static int status = -1; - - if (status == -1) { - const char *regex = settings->piglit_style_dmesg ? - igt_piglit_style_dmesg_blacklist : - igt_dmesg_whitelist; - - if (regcomp(&re, regex, REG_EXTENDED | REG_NOSUB) != 0) { - fprintf(stderr, "Cannot compile dmesg regexp\n"); - status = 1; - return false; - } + const char *regex = settings->piglit_style_dmesg ? + igt_piglit_style_dmesg_blacklist : + igt_dmesg_whitelist; - status = 0; + if (regcomp(re, regex, REG_EXTENDED | REG_NOSUB) != 0) { + fprintf(stderr, "Cannot compile dmesg regexp\n"); + return false; } - return status; + return true; } static bool parse_dmesg_line(char* line, @@ -639,12 +630,13 @@ static bool fill_from_dmesg(int fd, char piglit_name[256]; ssize_t read; size_t i; + regex_t re; if (!f) { return false; } - if (init_regex_whitelist(settings)) { + if (!init_regex_whitelist(settings, &re)) { fclose(f); return false; } @@ -723,6 +715,7 @@ static bool fill_from_dmesg(int fd, free(dmesg); free(warnings); + regfree(&re); fclose(f); return true; } -- cgit v1.2.3