]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - test/udev-test.pl
detect-virt: also detect "microsoft" as WSL
[thirdparty/systemd.git] / test / udev-test.pl
index b37b2e975f5e22a7b9ffe88e1a465f4177cdae9f..95013279b8e1aa090cf93688fa6aa0a7fe687af0 100755 (executable)
@@ -1256,6 +1256,72 @@ KERNEL=="dontknow|ttyACM0a|nothing|attyACM0", SYMLINK+="wrong1"
 KERNEL=="X|attyACM0|dontknow|ttyACM0a|nothing|attyACM0", SYMLINK+="wrong2"
 KERNEL=="all|dontknow|ttyACM0", SYMLINK+="right"
 KERNEL=="ttyACM0a|nothing", SYMLINK+="wrong3"
+EOF
+        },
+        {
+                desc            => "test multi matches 5",
+                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
+                exp_name        => "found",
+                not_exp_name    => "bad",
+                rules           => <<EOF
+KERNEL=="sda", TAG="foo"
+TAGS=="|foo", SYMLINK+="found"
+TAGS=="|aaa", SYMLINK+="bad"
+EOF
+        },
+        {
+                desc            => "test multi matches 6",
+                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
+                exp_name        => "found",
+                not_exp_name    => "bad",
+                rules           => <<EOF
+KERNEL=="sda", TAG=""
+TAGS=="|foo", SYMLINK+="found"
+TAGS=="aaa|bbb", SYMLINK+="bad"
+EOF
+        },
+        {
+                desc            => "test multi matches 7",
+                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
+                exp_name        => "found",
+                not_exp_name    => "bad",
+                rules           => <<EOF
+KERNEL=="sda", TAG="foo"
+TAGS=="foo||bar", SYMLINK+="found"
+TAGS=="aaa||bbb", SYMLINK+="bad"
+EOF
+        },
+        {
+                desc            => "test multi matches 8",
+                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
+                exp_name        => "found",
+                not_exp_name    => "bad",
+                rules           => <<EOF
+KERNEL=="sda", TAG=""
+TAGS=="foo||bar", SYMLINK+="found"
+TAGS=="aaa|bbb", SYMLINK+="bad"
+EOF
+        },
+        {
+                desc            => "test multi matches 9",
+                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
+                exp_name        => "found",
+                not_exp_name    => "bad",
+                rules           => <<EOF
+KERNEL=="sda", TAG="foo"
+TAGS=="foo|", SYMLINK+="found"
+TAGS=="aaa|", SYMLINK+="bad"
+EOF
+        },
+        {
+                desc            => "test multi matches 10",
+                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
+                exp_name        => "found",
+                not_exp_name    => "bad",
+                rules           => <<EOF
+KERNEL=="sda", TAG=""
+TAGS=="foo|", SYMLINK+="found"
+TAGS=="aaa|bbb", SYMLINK+="bad"
 EOF
         },
         {
@@ -1713,6 +1779,12 @@ sub run_test {
 
 }
 
+sub cleanup {
+        system("rm", "-rf", "$udev_run");
+        system("umount", "$udev_tmpfs");
+        rmdir($udev_tmpfs);
+}
+
 # only run if we have root permissions
 # due to mknod restrictions
 if (!($<==0)) {
@@ -1729,11 +1801,13 @@ if ($? >> 8 == 0) {
 
 if (!udev_setup()) {
         warn "Failed to set up the environment, skipping the test";
+        cleanup();
         exit($EXIT_TEST_SKIP);
 }
 
 if (system($udev_bin, "check")) {
         warn "$udev_bin failed to set up the environment, skipping the test";
+        cleanup();
         exit($EXIT_TEST_SKIP);
 }
 
@@ -1776,10 +1850,7 @@ if ($list[0]) {
 
 print "$error errors occurred\n\n";
 
-# cleanup
-system("rm", "-rf", "$udev_run");
-system("umount", "$udev_tmpfs");
-rmdir($udev_tmpfs);
+cleanup();
 
 if ($error > 0) {
         exit(1);