ryantimwilson / rpms / systemd

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