richardphibel / rpms / systemd

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