ryantimwilson / rpms / systemd

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