chiark / gitweb /
[PATCH] allow multiple symlinks
[elogind.git] / test / udev-test.pl
index 97f75edc94377b1b8bb3cf97365db527712d2b59..39d8450c34a9a52075013a763cb916e9fdb87fd8 100644 (file)
@@ -39,7 +39,7 @@ my @tests = (
                expected => "boot_disk" ,
                conf     => <<EOF
 LABEL, BUS="scsi", vendor="IBM-ESXS", NAME="boot_disk%n"
-REPLACE, KERNEL="ttyUSB0", NAME="visor""
+REPLACE, KERNEL="ttyUSB0", NAME="visor"
 EOF
        },
        {
@@ -49,6 +49,18 @@ EOF
                expected => "boot_disk1" ,
                conf     => <<EOF
 LABEL, BUS="scsi", vendor="IBM-ESXS", NAME="boot_disk%n"
+EOF
+       },
+       {
+               desc     => "label test of pattern match",
+               subsys   => "block",
+               devpath  => "block/sda/sda1",
+               expected => "boot_disk1" ,
+               conf     => <<EOF
+LABEL, BUS="scsi", vendor="?IBM-ESXS", NAME="boot_disk%n-1"
+LABEL, BUS="scsi", vendor="IBM-ESXS?", NAME="boot_disk%n-2"
+LABEL, BUS="scsi", vendor="IBM-ES??", NAME="boot_disk%n"
+LABEL, BUS="scsi", vendor="IBM-ESXSS", NAME="boot_disk%n-3"
 EOF
        },
        {
@@ -167,6 +179,51 @@ EOF
 CALLOUT, BUS="usb", PROGRAM="/bin/echo -n usb-%b", ID="*", NAME="%c"
 CALLOUT, BUS="scsi", PROGRAM="/bin/echo -n scsi-%b", ID="*", NAME="%c"
 CALLOUT, BUS="foo", PROGRAM="/bin/echo -n foo-%b", ID="*", NAME="%c"
+EOF
+       },
+       {
+               desc     => "symlink creation (same directory)",
+               subsys   => "tty",
+               devpath  => "class/tty/ttyUSB0",
+               expected => "visor0" ,
+               conf     => <<EOF
+REPLACE, KERNEL="ttyUSB[0-9]*", NAME="ttyUSB%n", SYMLINK="visor%n"
+EOF
+       },
+       {
+               desc     => "symlink creation (relative link back)",
+               subsys   => "block",
+               devpath  => "block/sda/sda2",
+               expected => "1/2/a/b/symlink" ,
+               conf     => <<EOF
+LABEL, BUS="scsi", vendor="IBM-ESXS", NAME="1/2/node", SYMLINK="1/2/a/b/symlink"
+EOF
+       },
+       {
+               desc     => "symlink creation (relative link forward)",
+               subsys   => "block",
+               devpath  => "block/sda/sda2",
+               expected => "1/2/symlink" ,
+               conf     => <<EOF
+LABEL, BUS="scsi", vendor="IBM-ESXS", NAME="1/2/a/b/node", SYMLINK="1/2/symlink"
+EOF
+       },
+       {
+               desc     => "symlink creation (relative link back and forward)",
+               subsys   => "block",
+               devpath  => "block/sda/sda2",
+               expected => "1/2/c/d/symlink" ,
+               conf     => <<EOF
+LABEL, BUS="scsi", vendor="IBM-ESXS", NAME="1/2/a/b/node", SYMLINK="1/2/c/d/symlink"
+EOF
+       },
+       {
+               desc     => "multiple symlinks",
+               subsys   => "tty",
+               devpath  => "class/tty/ttyUSB0",
+               expected => "second-0" ,
+               conf     => <<EOF
+REPLACE, KERNEL="ttyUSB0", NAME="visor", SYMLINK="first-%n second-%n third-%n"
 EOF
        },
 );
@@ -226,7 +283,8 @@ foreach my $config (@tests) {
        }
 
        udev("remove", $config->{subsys}, $config->{devpath}, \$config->{conf});
-       if (-e "$PWD/$udev_root$config->{expected}") {
+       if ((-e "$PWD/$udev_root$config->{expected}") ||
+           (-l "$PWD/$udev_root$config->{expected}")) {
                print "remove: error\n\n";
                system("tree $udev_root");
                $error++;