From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D02E9C3DA64 for ; Tue, 6 Aug 2024 14:43:44 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8EF2910E39C; Tue, 6 Aug 2024 14:43:44 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="FItr86Bl"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.14]) by gabe.freedesktop.org (Postfix) with ESMTPS id B025510E39C for ; Tue, 6 Aug 2024 14:43:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1722955424; x=1754491424; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=nzSUalsUTlKvVVRbfqyQuSytW23WwydBssr68GteWNU=; b=FItr86BlzEtPRRdy4/dmmKodTuKz6RFCqzfG+KMPT7JYi+KliWMfWXgZ sx20NO2IfRpVv7882kjwPTswVDpmmN/GWbKkpN4tCBgsD1cEx+jJqEyrc hj4+YPHQ/Ri2bqqlr64kRjjna6tzLgyGyXjloOfwywqboUsUnZMSrPnTK ukL/5ZYiG0lrv5cBEjDLepej8DrwXGe4/7E9H07ySQKK7Yg4XtCQk3n9J 1jcaKhGUQIiyQ7qS93YZESgc93zsEILbkY61kKQ6fmEQE3fH95zY8fmHA G+fjBZUbUOKsXcEBMRlxOqiMnu64Jh3fGcBmZvLG4/cYH73fNSoadWxyj w==; X-CSE-ConnectionGUID: SnZSPAzgTbm/zF4MELuozg== X-CSE-MsgGUID: uJ1ExeRdTSSy4HbJyuI9+g== X-IronPort-AV: E=McAfee;i="6700,10204,11156"; a="24766612" X-IronPort-AV: E=Sophos;i="6.09,268,1716274800"; d="scan'208";a="24766612" Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Aug 2024 07:43:44 -0700 X-CSE-ConnectionGUID: K2hmrzYQTUyEHoIkDmmlzw== X-CSE-MsgGUID: n+GEsXZxTSOMfcw7S8sBqQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,268,1716274800"; d="scan'208";a="56606666" Received: from oandoniu-mobl3.ger.corp.intel.com (HELO localhost) ([10.245.244.78]) by fmviesa010-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Aug 2024 07:43:42 -0700 From: Kamil Konieczny To: igt-dev@lists.freedesktop.org Cc: Kamil Konieczny Subject: [PATCH i-g-t v2 1/4] runner/resultgen: Added dynamically ignored dmesg messages Date: Tue, 6 Aug 2024 16:43:29 +0200 Message-ID: <20240806144332.80609-2-kamil.konieczny@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240806144332.80609-1-kamil.konieczny@linux.intel.com> References: <20240806144332.80609-1-kamil.konieczny@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: igt-dev@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development mailing list for IGT GPU Tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: igt-dev-bounces@lists.freedesktop.org Sender: "igt-dev" Some messages generated by driver are triggered by test itself and are not meant to rise error nor warn within runner, yet they should be catched in other circumstances so they are not suitable to be ignored permanently. Instead of hard-coding such situations check dmesg for info from a test and add such regex on a fly and then ignore next dmesg errors or warns which match it. Ignored regex will be removed after end of current subtest, just before a new subtest or dynamic subtest starts. v2: removed local copy for regex string (Zbigniew), clarify description, free regex before creating new (Kamil) Signed-off-by: Kamil Konieczny --- runner/output_strings.h | 8 ++++++ runner/resultgen.c | 60 +++++++++++++++++++++++++++++++++++------ 2 files changed, 60 insertions(+), 8 deletions(-) diff --git a/runner/output_strings.h b/runner/output_strings.h index 892895ead..91ef5f2c3 100644 --- a/runner/output_strings.h +++ b/runner/output_strings.h @@ -54,6 +54,14 @@ static const char STARTING_SUBTEST_DMESG[] = ": starting subtest "; */ static const char STARTING_DYNAMIC_SUBTEST_DMESG[] = ": starting dynamic subtest "; +/* + * Output in dmesg when a test wants runner to dynamically ignore error or warn. + * + * Example: + * [IGT] add ignored dmesg regex: CRITICAL: Xe has declared device [0-9:.]* as wedged + */ +static const char IGT_ADD_IGNORED_REGEX_DMESG[] = "add ignored dmesg regex: "; + /* * Output when a test process is executed. * diff --git a/runner/resultgen.c b/runner/resultgen.c index 63f5b26d7..ce7433b65 100644 --- a/runner/resultgen.c +++ b/runner/resultgen.c @@ -829,16 +829,13 @@ static const char igt_dmesg_whitelist[] = static const char igt_piglit_style_dmesg_blacklist[] = "(\\[drm:|drm_|intel_|i915_|\\[drm\\])"; -static bool init_regex_whitelist(struct settings* settings, GRegex **re) +static bool init_dmesg_regex(GRegex **re, const char *regex, const char *msg) { GError *err = NULL; - const char *regex = settings->piglit_style_dmesg ? - igt_piglit_style_dmesg_blacklist : - igt_dmesg_whitelist; *re = g_regex_new(regex, G_REGEX_OPTIMIZE, 0, &err); if (err) { - fprintf(stderr, "Cannot compile dmesg regexp\n"); + fprintf(stderr, "Cannot compile dmesg regexp for %s\n", msg); g_error_free(err); return false; } @@ -846,6 +843,43 @@ static bool init_regex_whitelist(struct settings* settings, GRegex **re) return true; } +static bool init_regex_whitelist(struct settings *settings, GRegex **re) +{ + const char *regex = settings->piglit_style_dmesg ? + igt_piglit_style_dmesg_blacklist : + igt_dmesg_whitelist; + const char *what = settings->piglit_style_dmesg ? + "piglit style dmesg blocklist" : + "igt dmesg whitelist"; + + return init_dmesg_regex(re, regex, what); +} + +static bool not_ignored(GRegex *re, const char *msg) +{ + if (!re) + return true; + + return !g_regex_match(re, msg, 0, NULL); +} + +static void clean_regex(GRegex **re) +{ + if (*re) + g_regex_unref(*re); + + *re = NULL; +} + +static void add_ignored_regex(GRegex **re, char *src) +{ + if (*re) + g_regex_unref(*re); + + init_dmesg_regex(re, src, "ignore match"); + fprintf(stderr, "igt_resultgen: Added ignore regex '%s'\n", src); +} + static bool parse_dmesg_line(char* line, unsigned *flags, unsigned long long *ts_usec, char *continuation, char **message) @@ -979,6 +1013,7 @@ static bool fill_from_dmesg(int fd, char dynamic_piglit_name[256]; size_t i; GRegex *re; + GRegex *re_ignore; /* regex for dynamically ignored dmesg line */ if (!f) { return false; @@ -989,12 +1024,13 @@ static bool fill_from_dmesg(int fd, return false; } + re_ignore = NULL; while (getline(&line, &linelen, f) > 0) { char *formatted; unsigned flags; unsigned long long ts_usec; char continuation; - char *message, *subtest, *dynamic_subtest; + char *message, *subtest, *dynamic_subtest, *ignore; if (!parse_dmesg_line(line, &flags, &ts_usec, &continuation, &message)) continue; @@ -1024,6 +1060,7 @@ static bool fill_from_dmesg(int fd, subtest += strlen(STARTING_SUBTEST_DMESG); generate_piglit_name(binary, subtest, piglit_name, sizeof(piglit_name)); current_test = get_or_create_json_object(tests, piglit_name); + clean_regex(&re_ignore); } if (current_test != NULL && @@ -1041,18 +1078,24 @@ static bool fill_from_dmesg(int fd, dynamic_subtest += strlen(STARTING_DYNAMIC_SUBTEST_DMESG); generate_piglit_name_for_dynamic(piglit_name, dynamic_subtest, dynamic_piglit_name, sizeof(dynamic_piglit_name)); current_dynamic_test = get_or_create_json_object(tests, dynamic_piglit_name); + clean_regex(&re_ignore); } + if ((ignore = strstr(message, IGT_ADD_IGNORED_REGEX_DMESG)) != NULL) + add_ignored_regex(&re_ignore, ignore + strlen(IGT_ADD_IGNORED_REGEX_DMESG)); + if (settings->piglit_style_dmesg) { if ((flags & 0x07) <= settings->dmesg_warn_level && continuation != 'c' && - g_regex_match(re, message, 0, NULL)) { + g_regex_match(re, message, 0, NULL) && + not_ignored(re_ignore, message)) { append_line(&warnings, &warningslen, formatted); if (current_test != NULL) append_line(&dynamic_warnings, &dynamic_warnings_len, formatted); } } else { if ((flags & 0x07) <= settings->dmesg_warn_level && continuation != 'c' && - !g_regex_match(re, message, 0, NULL)) { + !g_regex_match(re, message, 0, NULL) && + not_ignored(re_ignore, message)) { append_line(&warnings, &warningslen, formatted); if (current_test != NULL) append_line(&dynamic_warnings, &dynamic_warnings_len, formatted); @@ -1099,6 +1142,7 @@ static bool fill_from_dmesg(int fd, free(dynamic_dmesg); free(warnings); free(dynamic_warnings); + clean_regex(&re_ignore); g_regex_unref(re); fclose(f); return true; -- 2.43.0