From patchwork Mon Feb 13 18:56:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Rowand X-Patchwork-Id: 56472 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2515474wrn; Mon, 13 Feb 2023 10:58:38 -0800 (PST) X-Google-Smtp-Source: AK7set9qdxeOmWZHe098Vc1rvITPzdCh1gP0CmYbgodoh37OhdSI9o4egz7WHEzj/aijYBP+8tw7 X-Received: by 2002:a17:906:2302:b0:878:6b39:6d2a with SMTP id l2-20020a170906230200b008786b396d2amr28341204eja.46.1676314717978; Mon, 13 Feb 2023 10:58:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676314717; cv=none; d=google.com; s=arc-20160816; b=a5IQHRuCQ/X9u553BLfpsXcdXReBGxmz8fpeNDcctcyvC5UmgLUTP+z0fxj6VlGjZV 3ZpQ8qhv0NcEG7xjKIt8dqHKZJOlKAeL5k40fBOzVeVIwQgnB9p0lqkAGgDlvVRYTRIe 8/x1vK7xQ0jRWN0jUCUEi32nIkufbyLMD5t7rVuQwwnnJhxAiJqT27aEIrRB1GcDLjVU SNHDlDeEANieIQXWWZfU6H6M31wVPo7yWNiT392S/85Vvd9Qu0/fX4JtCRCam06i12vo RKyoIlPw05JO2I8veqdMBuZBgx3gvbe+4F9EBOAUENiTIjyI3McEXI+CjdD/JyKhSm4n tgFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=l2Ija/xk/Xo2pgXxKw0oJtRB4E5NlGaSmHRfzbCfeiQ=; b=LP99wlmmdMXnyCuj+n0Jr3IlgdPwy/sj1RVtIONRZSnDIrYCD5EwjxdCm+MkzeoO1Y ZJT5KOqqa2+ijXsmrxRyp496nv3QXjUQAZEPzzjBgGVtiU80pVrLHRmLCZDMo9P8J0vd KP+mkeNIalEvZo+dLkjR7KLa886dQx9Qff0dg1XjIFOw1QuzpQLnTjally0dSruv64Oh I7OsvV8RIAm82UNqqOZIN9byXlLUd58Uf1IA6ccd43YBkDo8QtB+D7viiuljBfBDYZ5v X8G5CCOeFf5Wwi56g7XvDdcCy8C9rKgCRdlnSntl2/jvdIubL0dGbwOmbWVj7VBZL6wD EqHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Xd6GCFHf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 2-20020a17090601c200b008b120f21062si1271264ejj.584.2023.02.13.10.58.15; Mon, 13 Feb 2023 10:58:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Xd6GCFHf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230211AbjBMS5w (ORCPT + 99 others); Mon, 13 Feb 2023 13:57:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230157AbjBMS5q (ORCPT ); Mon, 13 Feb 2023 13:57:46 -0500 Received: from mail-oa1-x2b.google.com (mail-oa1-x2b.google.com [IPv6:2001:4860:4864:20::2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 92DE9DBEE; Mon, 13 Feb 2023 10:57:45 -0800 (PST) Received: by mail-oa1-x2b.google.com with SMTP id 586e51a60fabf-16debd2786aso6418684fac.7; Mon, 13 Feb 2023 10:57:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=l2Ija/xk/Xo2pgXxKw0oJtRB4E5NlGaSmHRfzbCfeiQ=; b=Xd6GCFHfxB5FndpuQ2ZmtVl7YnsK2pEcHH4HNYPU10TMvtQZ2tnTN8Id5adCWNTzN7 nRRQcfjQ9WDSQYxA7uvOQwOrmDSk9ec5ZLk2N0g5gsDVG9GLtKPJSMIPQnieoU26/Tn4 PZhiJapmfRLK1q7/22I3+sAd2I8jMKSyEX53jUde2LA+vVJv+h5R25d2bGonYd07dL+e 3jIG47LwbIVSzP2279Fo/1DG8XXae3HtE4vgS26HJH3TVWQJmVn35cC6lBHl1pnT+HQK OLCr2s3iRQy9YY5750lI6FJ2wBgzJyglW4CDOF3IwD2V7rBIBVEZeFHYU/7tzP/N7XPg dgIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=l2Ija/xk/Xo2pgXxKw0oJtRB4E5NlGaSmHRfzbCfeiQ=; b=XLV/RRL7FdJc3CxCIXlSnpXx17dFoHdsroFRxE63xnyST5RjMMAM3BW//3l34hj8ys 09cjhRr6MYW5L5xflBJoGM5WewgtqQx/nyniRcp8j/b85ZcSS9qwQFFJ6xz8CZDH8Ojx vJyN1qWHbf8bw6gOw1vEmuBjVSS/UgsCLR6uyebCOyyN2faZm+n0pYceBnsKEyfiNcyO jf4kYDgWEGeFofKfwHZHW2zFgy11cKAvSuoNlRWBp+DRA64YQCW6G01qWHT/VA4eBSbf jEcW+OMpHVu+ggRpKy0d3s1y7JzcNP6I85aAZ7RCcQi+15ZWulzOVwv5nK3AGteHt0Dq 6CEg== X-Gm-Message-State: AO0yUKXUxvXt6h8OYzsBnsXZp+dYG+kjETqT/t6osbmoZJsq6e80KKeP H0Os3kddvCWBpm2tDei4r34= X-Received: by 2002:a05:6871:68e:b0:16e:121b:7e69 with SMTP id l14-20020a056871068e00b0016e121b7e69mr2198173oao.6.1676314664899; Mon, 13 Feb 2023 10:57:44 -0800 (PST) Received: from xps8900.attlocal.net ([2600:1700:2442:6db0:5829:dabf:a50e:e9f2]) by smtp.gmail.com with ESMTPSA id ef15-20020a0568701a8f00b0016df97ab05bsm1654958oab.31.2023.02.13.10.57.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Feb 2023 10:57:44 -0800 (PST) From: Frank Rowand To: Rob Herring Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/7] of: add processing of EXPECT_NOT to of_unittest_expect Date: Mon, 13 Feb 2023 12:56:57 -0600 Message-Id: <20230213185702.395776-3-frowand.list@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230213185702.395776-1-frowand.list@gmail.com> References: <20230213185702.395776-1-frowand.list@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757743381868948953?= X-GMAIL-MSGID: =?utf-8?q?1757743381868948953?= scripts/dtc/of_unittest_expect processes EXPECT messages that document expected kernel messages triggered by unittest. Add processing of EXPECT_NOT messages that document kernel messages triggered by unittest that are not expected. This is commit 2 of 2, implementing the processing of EXPECT_NOT messages. Signed-off-by: Frank Rowand --- scripts/dtc/of_unittest_expect | 157 ++++++++++++++++++++++++++++++--- 1 file changed, 145 insertions(+), 12 deletions(-) diff --git a/scripts/dtc/of_unittest_expect b/scripts/dtc/of_unittest_expect index 7b25bb693162..0a535a8e9821 100755 --- a/scripts/dtc/of_unittest_expect +++ b/scripts/dtc/of_unittest_expect @@ -9,7 +9,7 @@ # on the console log that results from executing the Linux kernel # devicetree unittest (drivers/of/unitest.c). -$VUFX = "230121a"; +$VUFX = "230211a"; use strict 'refs'; use strict subs; @@ -62,6 +62,8 @@ sub compare { } else { return 0; } + } elsif ($type eq "all") { + return 1; } elsif ($type eq "") { if ($expect_next ne $got_next) { return 0; @@ -130,6 +132,7 @@ usage: <> matches: [+-]*[0-9]+ <> matches: (0x)*[0-9a-f]+ + <> matches: anything to end of line 'EXPECT \\' (begin) and 'EXPECT /' (end) lines are suppressed. @@ -240,6 +243,8 @@ if ($#ARGV != 0) { $pr_fmt = "### dt-test ### "; $exp_begin = "${pr_fmt}EXPECT \\\\ : "; $exp_end = "${pr_fmt}EXPECT / : "; +$expnot_begin = "${pr_fmt}EXPECT_NOT \\\\ : "; +$expnot_end = "${pr_fmt}EXPECT_NOT / : "; $line_num = ""; @@ -250,6 +255,8 @@ while ($line = ) { chomp $line; + $suppress_line = 0; + $prefix = " "; ## 2 characters @@ -306,6 +313,7 @@ while ($line = ) { $begin = pop @exp_found_or_begin; if (compare($data, $begin)) { $found = 1; + $exp_found++; } } elsif (@begin > 0) { $begin = pop @exp_begin_stack; @@ -316,7 +324,7 @@ while ($line = ) { if ($no_begin) { $exp_missing_begin++; - print "** ERROR: EXPECT end without any EXPECT begin:\n"; + print "** ERROR: EXPECT end without matching EXPECT begin:\n"; print " end ---> $line\n"; } elsif (! $found) { @@ -329,17 +337,97 @@ while ($line = ) { printf "** %s%s$script_name WARNING - not found ---> %s\n", $line_num, $timestamp, $data; - } elsif (! compare($data, $begin)) { + } elsif (! compare($data, $begin) and ($data ne $begin)) { $exp_missing_end++; print "** ERROR: EXPECT end does not match EXPECT begin:\n"; print " begin -> $begin\n"; print " end ---> $line\n"; + } + + next LINE; + } + + + # ----- find EXPECT_NOT begin + + if ($line =~ /^\s*$expnot_begin/) { + $data = $line; + $data =~ s/^\s*$expnot_begin//; + push @expnot_begin_stack, $data; + + if ($verbose) { + if ($print_line_num) { + $line_num = sprintf("%4s ", $.); + } + printf "%s %s%s%s\n", $prefix, $line_num, $timestamp, $line; + } + + next LINE; + } + + + # ----- find EXPECT_NOT end + + if ($line =~ /^\s*$expnot_end/) { + $data = $line; + $data =~ s/^\s*$expnot_end//; + + if ($verbose) { + if ($print_line_num) { + $line_num = sprintf("%4s ", $.); + } + printf "%s %s%s%s\n", $prefix, $line_num, $timestamp, $line; + } + + $found = 0; + $no_begin = 0; + if (@expnot_found_or_begin > 0) { + $begin = pop @expnot_found_or_begin; + if (compare($data, $begin)) { + $found = 1; + $expnot_found++; + } + } elsif (@expnot_begin_stack <= 0) { + $no_begin = 1; + } + + if ($no_begin) { + + $expnot_missing_begin++; + print "** ERROR: EXPECT_NOT end without matching EXPECT_NOT begin:\n"; + print " end ---> $line\n"; + + } + + if ($found) { + + if ($print_line_num) { + $line_num = sprintf("%4s ", $.); + } + + printf "** %s%s$script_name WARNING - next line matches EXPECT_NOT\n", + $line_num, $timestamp; + printf "** %s%s%s\n", $line_num, $timestamp, $line; + } else { - $exp_found++; + $expnot_missing++; + + } + + if (@expnot_begin_stack > 0) { + $begin = pop @expnot_begin_stack; + + if (! compare($data, $begin) and ($data ne $begin)) { + $expnot_missing_end++; + print "** ERROR: EXPECT_NOT end does not match EXPECT_NOT begin:\n"; + print " begin -> $begin\n"; + print " end ---> $line\n"; + + } } next LINE; @@ -374,12 +462,38 @@ while ($line = ) { if ($hide_expect) { $suppress_line = 1; - next LINE; } $prefix = "ok"; # 2 characters } + $found = 0; + foreach $begin (@expnot_begin_stack) { + if (compare($begin, $line)) { + $found = 1; + last; + } + } + + if ($found) { + $begin = shift @begin; + while (! compare($begin, $line)) { + push @expnot_found_or_begin, $begin; + $begin = shift @begin; + } + push @expnot_found_or_begin, $line; + + if ($hide_expect) { + $suppress_line = 1; + } + $prefix = "**"; # 2 characters + } + + + if ($suppress_line) { + next LINE; + } + if ($print_line_num) { $line_num = sprintf("%4s ", $.); } @@ -391,18 +505,37 @@ if (! $no_expect_stats) { print "\n"; print "** EXPECT statistics:\n"; print "**\n"; - printf "** EXPECT found : %4i\n", $exp_found; - printf "** EXPECT not found : %4i\n", $exp_missing; - printf "** missing EXPECT begin : %4i\n", $exp_missing_begin; - printf "** missing EXPECT end : %4i\n", $exp_missing_end; - printf "** unittest FAIL : %4i\n", $unittest_fail; - printf "** internal error : %4i\n", $internal_err; + printf "** non-zero values expected:\n"; + print "**\n"; + printf "** EXPECT found : %4i\n", $exp_found; + printf "** EXPECT_NOT not found : %4i\n", $expnot_missing; + print "**\n"; + printf "** zero values expected:\n"; + print "**\n"; + printf "** EXPECT not found : %4i\n", $exp_missing; + printf "** missing EXPECT begin : %4i\n", $exp_missing_begin; + printf "** missing EXPECT end : %4i\n", $exp_missing_end; + print "**\n"; + printf "** EXPECT_NOT found : %4i\n", $expnot_found; + printf "** missing EXPECT_NOT begin : %4i\n", $expnot_missing_begin; + printf "** missing EXPECT_NOT end : %4i\n", $expnot_missing_end; + print "**\n"; + printf "** unittest FAIL : %4i\n", $unittest_fail; + printf "** internal error : %4i\n", $internal_err; } if (@exp_begin_stack) { - print "** ERROR: EXPECT begin without any EXPECT end:\n"; + print "** ERROR: EXPECT begin without matching EXPECT end:\n"; print " This list may be misleading.\n"; foreach $begin (@exp_begin_stack) { print " begin ---> $begin\n"; } } + +if (@expnot_begin_stack) { + print "** ERROR: EXPECT_NOT begin without matching EXPECT_NOT end:\n"; + print " This list may be misleading.\n"; + foreach $begin (@expnot_begin_stack) { + print " begin ---> $begin\n"; + } +}