From 7913cdbdfe6ca3fa0a1221c60702806eb51aa707 Mon Sep 17 00:00:00 2001
From: Martin Wilck <mwilck@suse.com>
Date: Tue, 24 Apr 2018 20:55:01 +0200
Subject: [PATCH] test/udev-test.pl: count "good" results
This is helpful to catch possible regressions in the test.
Also, don't count wait() errors, they are likely not udev errors.
(cherry picked from commit b95c43982ab7d0253b552ad56cffb3d68fcbb4f6)
Related: #1642728
---
test/udev-test.pl | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/test/udev-test.pl b/test/udev-test.pl
index 0344d2e89c..813be70739 100755
--- a/test/udev-test.pl
+++ b/test/udev-test.pl
@@ -2114,6 +2114,7 @@ sub udev {
}
my $error = 0;
+my $good = 0;
sub permissions_test {
my($rules, $uid, $gid, $mode) = @_;
@@ -2144,6 +2145,7 @@ sub permissions_test {
}
if ($wrong == 0) {
print "permissions: ok\n";
+ $good++;
} else {
printf " expected permissions are: %s:%s:%#o\n", $1, $2, oct($3);
printf " created permissions are : %i:%i:%#o\n", $uid, $gid, $mode & 07777;
@@ -2169,6 +2171,7 @@ sub major_minor_test {
}
if ($wrong == 0) {
print "major:minor: ok\n";
+ $good++;
} else {
printf " expected major:minor is: %i:%i\n", $1, $2;
printf " created major:minor is : %i:%i\n", $major, $minor;
@@ -2254,6 +2257,7 @@ sub check_devnode {
major_minor_test($device, $rdev);
}
print "add $devnode: ok\n";
+ $good++;
return $devnode;
}
@@ -2282,11 +2286,13 @@ sub check_link_add {
system("tree", "$udev_dev");
} else {
print "symlink $link: ok\n";
+ $good++;
}
} else {
print "symlink $link: error";
if ($err_expected) {
print " as expected\n";
+ $good++;
} else {
print "\n";
system("tree", "$udev_dev");
@@ -2305,10 +2311,12 @@ sub check_link_nonexistent {
if ($tgt ne $devnode) {
print "nonexistent: '$link' points to other device (ok)\n";
+ $good++;
} else {
print "nonexistent: error \'$link\' should not be there";
if ($err_expected) {
print " (as expected)\n";
+ $good++;
} else {
print "\n";
system("tree", "$udev_dev");
@@ -2319,6 +2327,7 @@ sub check_link_nonexistent {
}
} else {
print "nonexistent $link: ok\n";
+ $good++;
}
}
@@ -2353,6 +2362,7 @@ sub check_remove_devnode {
sleep(1);
} else {
print "remove $devnode: ok\n";
+ $good++;
}
}
@@ -2364,6 +2374,7 @@ sub check_link_remove {
print "remove $link: error";
if ($err_expected) {
print " as expected\n";
+ $good++;
} else {
print "\n";
system("tree", "$udev_dev");
@@ -2373,6 +2384,7 @@ sub check_link_remove {
}
} else {
print "remove $link: ok\n";
+ $good++;
}
}
@@ -2432,7 +2444,6 @@ sub fork_and_run_udev {
$pid = waitpid($dev->{pid}, 0);
if ($pid == -1) {
print "error waiting for pid dev->{pid}\n";
- $error += 1;
}
if (WIFEXITED($?)) {
$rc = WEXITSTATUS($?);
@@ -2440,6 +2451,8 @@ sub fork_and_run_udev {
if ($rc) {
print "$udev_bin $action for $dev->{devpath} failed with code $rc\n";
$error += 1;
+ } else {
+ $good++;
}
}
}
@@ -2549,7 +2562,7 @@ if ($list[0]) {
}
$sema->remove;
-print "$error errors occurred\n\n";
+print "$error errors occurred. $good good results.\n\n";
cleanup();