summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArkadiusz Hiler <arkadiusz.hiler@intel.com>2019-04-01 08:57:22 +0300
committerArkadiusz Hiler <arkadiusz.hiler@intel.com>2019-04-01 14:49:08 +0300
commit7cadc6105b00f8d8ef166929118a95ce69221603 (patch)
tree1c8a3f3f0fc6f7e5c0f9d3f64d5e50885b5e6029
parent2b4ede5c974228d2dcf02a581a1c7548d1483c3f (diff)
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 <arkadiusz.hiler@intel.com> Reviewed-by: Simon Ser <simon.ser@intel.com>
-rw-r--r--runner/resultgen.c29
1 files changed, 11 insertions, 18 deletions
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;
}