teknoraver / rpms / systemd

Forked from rpms/systemd 2 months ago
Clone

Blame SOURCES/0526-test-udev-test.pl-create-rules-only-once.patch

bd1529
From 9aa12f2f564c208c4c1eaef613d18d1c0b481a16 Mon Sep 17 00:00:00 2001
bd1529
From: Martin Wilck <mwilck@suse.com>
bd1529
Date: Mon, 23 Apr 2018 21:58:12 +0200
bd1529
Subject: [PATCH] test/udev-test.pl: create rules only once
bd1529
bd1529
It's not necessary to write the rules for every udev run, as we
bd1529
now may have many (rather than just 2) per test.
bd1529
bd1529
(cherry picked from commit af7ee3eae689f9c31b49ea13758ad9c901918ce3)
bd1529
bd1529
Related: #1642728
bd1529
---
bd1529
 test/udev-test.pl | 13 +++++++++----
bd1529
 1 file changed, 9 insertions(+), 4 deletions(-)
bd1529
bd1529
diff --git a/test/udev-test.pl b/test/udev-test.pl
bd1529
index bd5401da75..8b5a97ad61 100755
bd1529
--- a/test/udev-test.pl
bd1529
+++ b/test/udev-test.pl
bd1529
@@ -2069,14 +2069,18 @@ EOF
bd1529
         },
bd1529
 );
bd1529
 
bd1529
-sub udev {
bd1529
-        my ($action, $devpath, $rules) = @_;
bd1529
+sub create_rules {
bd1529
+        my ($rules) = @_;
bd1529
 
bd1529
         # create temporary rules
bd1529
         system("mkdir", "-p", "$udev_rules_dir");
bd1529
         open CONF, ">$udev_rules" || die "unable to create rules file: $udev_rules";
bd1529
         print CONF $$rules;
bd1529
         close CONF;
bd1529
+}
bd1529
+
bd1529
+sub udev {
bd1529
+        my ($action, $devpath) = @_;
bd1529
 
bd1529
         if ($valgrind > 0) {
bd1529
                 return system("$udev_bin_valgrind $action $devpath");
bd1529
@@ -2259,9 +2263,10 @@ sub run_test {
bd1529
         my @devices = @{$rules->{devices}};
bd1529
 
bd1529
         print "TEST $number: $rules->{desc}\n";
bd1529
+        create_rules(\$rules->{rules});
bd1529
         foreach my $dev (@devices) {
bd1529
                 print "device \'$dev->{devpath}\' expecting node/link \'$dev->{exp_name}\'\n";
bd1529
-                $rc = udev("add", $dev->{devpath}, \$rules->{rules});
bd1529
+                $rc = udev("add", $dev->{devpath});
bd1529
                 if ($rc != 0) {
bd1529
                         print "$udev_bin add failed with code $rc\n";
bd1529
                         $error++;
bd1529
@@ -2278,7 +2283,7 @@ sub run_test {
bd1529
         }
bd1529
 
bd1529
         foreach my $dev (@devices) {
bd1529
-                $rc = udev("remove", $dev->{devpath}, \$rules->{rules});
bd1529
+                $rc = udev("remove", $dev->{devpath});
bd1529
                 if ($rc != 0) {
bd1529
                         print "$udev_bin remove failed with code $rc\n";
bd1529
                         $error++;