richardphibel / rpms / systemd

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