richardphibel / rpms / systemd

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