summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrank Rowand <frowand.list@gmail.com>2023-02-13 12:56:57 -0600
committerRob Herring <robh@kernel.org>2023-02-17 15:46:20 -0600
commit568a10bfffe88daa42f1b7968352cc6abd948ca3 (patch)
treea385aa5a646b8a11029e3b38a7cd2dce737a80b3
parent511f3aa71029ef4d9408065f94110c0e8f9dccba (diff)
downloadlinux-stable-568a10bfffe88daa42f1b7968352cc6abd948ca3.tar.gz
linux-stable-568a10bfffe88daa42f1b7968352cc6abd948ca3.tar.bz2
linux-stable-568a10bfffe88daa42f1b7968352cc6abd948ca3.zip
of: add processing of EXPECT_NOT to of_unittest_expect
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 <frowand.list@gmail.com> Link: https://lore.kernel.org/r/20230213185702.395776-3-frowand.list@gmail.com Signed-off-by: Rob Herring <robh@kernel.org>
-rwxr-xr-xscripts/dtc/of_unittest_expect157
1 files 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:
<<int>> matches: [+-]*[0-9]+
<<hex>> matches: (0x)*[0-9a-f]+
+ <<all>> 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 = <ARGV>) {
chomp $line;
+ $suppress_line = 0;
+
$prefix = " "; ## 2 characters
@@ -306,6 +313,7 @@ while ($line = <ARGV>) {
$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 = <ARGV>) {
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 = <ARGV>) {
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 = <ARGV>) {
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";
+ }
+}