public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
* [igt-dev] [PATCH i-g-t 1/3] runner: Reinitialize compiled dmesg regexp each parsing session
@ 2019-04-01  6:46 Arkadiusz Hiler
  2019-04-01  6:46 ` [igt-dev] [PATCH i-g-t 2/3] runner: Refactor metadata parsing Arkadiusz Hiler
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: Arkadiusz Hiler @ 2019-04-01  6:46 UTC (permalink / raw)
  To: igt-dev

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>
---
 runner/resultgen.c | 29 +++++++++++------------------
 1 file changed, 11 insertions(+), 18 deletions(-)

diff --git a/runner/resultgen.c b/runner/resultgen.c
index 32b59d59..73fda64f 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;
+	const char *regex = settings->piglit_style_dmesg ?
+		igt_piglit_style_dmesg_blacklist :
+		igt_dmesg_whitelist;
 
-	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;
-		}
-
-		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;
 }
-- 
2.20.1

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2019-04-01 11:10 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-04-01  6:46 [igt-dev] [PATCH i-g-t 1/3] runner: Reinitialize compiled dmesg regexp each parsing session Arkadiusz Hiler
2019-04-01  6:46 ` [igt-dev] [PATCH i-g-t 2/3] runner: Refactor metadata parsing Arkadiusz Hiler
2019-04-01 10:24   ` Petri Latvala
2019-04-01  6:46 ` [igt-dev] [PATCH i-g-t 3/3] runner: Add --dmesg-warn-level switch Arkadiusz Hiler
2019-04-01 11:10   ` Petri Latvala
2019-04-01  7:20 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,1/3] runner: Reinitialize compiled dmesg regexp each parsing session Patchwork
2019-04-01  7:23 ` [igt-dev] [PATCH i-g-t 1/3] " Ser, Simon
2019-04-01  8:16 ` [igt-dev] ✓ Fi.CI.IGT: success for series starting with [i-g-t,1/3] " Patchwork

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox