bd1529
From e0cee95e0cc401ce120a1b56cdb7a8b9afbd6bcf Mon Sep 17 00:00:00 2001
bd1529
From: Martin Wilck <mwilck@suse.com>
bd1529
Date: Thu, 26 Apr 2018 14:07:27 +0200
bd1529
Subject: [PATCH] test/udev_test.pl: add "expected good" count
bd1529
bd1529
Since 'test/udev-test.pl: count "good" results', we know how many
bd1529
checks succeeded. Add an "expected good" count to make that number
bd1529
more meaningful.
bd1529
bd1529
(cherry picked from commit cbeb23d863d540408cd1fb274d78213f59639df2)
bd1529
bd1529
Related: #1642728
bd1529
---
bd1529
 test/udev-test.pl | 21 +++++++++++++++++++--
bd1529
 1 file changed, 19 insertions(+), 2 deletions(-)
bd1529
bd1529
diff --git a/test/udev-test.pl b/test/udev-test.pl
bd1529
index 33a76ad292..cf6ca6b80c 100755
bd1529
--- a/test/udev-test.pl
bd1529
+++ b/test/udev-test.pl
bd1529
@@ -2338,6 +2338,7 @@ sub udev {
bd1529
 
bd1529
 my $error = 0;
bd1529
 my $good = 0;
bd1529
+my $exp_good = 0;
bd1529
 
bd1529
 sub permissions_test {
bd1529
         my($rules, $uid, $gid, $mode) = @_;
bd1529
@@ -2685,12 +2686,27 @@ sub run_test {
bd1529
         my ($rules, $number, $sema) = @_;
bd1529
         my $rc;
bd1529
         my @devices;
bd1529
+        my $ntests;
bd1529
+        my $cur_good = $good;
bd1529
+        my $cur_error = $error;
bd1529
 
bd1529
         if (!defined $rules->{devices}) {
bd1529
                 $rules->{devices} = all_block_devs($rules->{generator});
bd1529
         }
bd1529
         @devices = @{$rules->{devices}};
bd1529
+        # For each device: exit status and devnode test for add & remove
bd1529
+        $ntests += 4 * ($#devices + 1);
bd1529
 
bd1529
+        foreach my $dev (@devices) {
bd1529
+                $ntests += 2 * ($#{$dev->{exp_links}} + 1)
bd1529
+                    + ($#{$dev->{not_exp_links}} + 1)
bd1529
+                    + (defined $dev->{exp_perms} ? 1 : 0)
bd1529
+                    + (defined $dev->{exp_majorminor} ? 1 : 0);
bd1529
+        }
bd1529
+        if (defined $rules->{repeat}) {
bd1529
+                $ntests *= $rules->{repeat};
bd1529
+        }
bd1529
+        $exp_good += $ntests;
bd1529
         print "TEST $number: $rules->{desc}\n";
bd1529
         create_rules(\$rules->{rules});
bd1529
 
bd1529
@@ -2712,10 +2728,11 @@ sub run_test {
bd1529
                 check_remove($dev);
bd1529
         }
bd1529
 
bd1529
-        print "\n";
bd1529
         if (defined($rules->{repeat}) && --($rules->{repeat}) > 0) {
bd1529
                 goto REPEAT;
bd1529
         }
bd1529
+        printf "TEST $number: errors: %d good: %d/%d\n\n", $error-$cur_error,
bd1529
+            $good-$cur_good, $ntests;
bd1529
 
bd1529
         if (defined($rules->{option}) && $rules->{option} eq "clean") {
bd1529
                 udev_setup();
bd1529
@@ -2794,7 +2811,7 @@ if ($list[0]) {
bd1529
 }
bd1529
 
bd1529
 $sema->remove;
bd1529
-print "$error errors occurred. $good good results.\n\n";
bd1529
+print "$error errors occurred. $good/$exp_good good results.\n\n";
bd1529
 
bd1529
 cleanup();
bd1529