teknoraver / rpms / systemd

Forked from rpms/systemd 3 months ago
Clone

Blame SOURCES/0542-test-udev_test.pl-add-expected-good-count.patch

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