chiark / gitweb /
[PATCH] add test for callout rule with a device that has no bus.
[elogind.git] / test / udev-test.pl
index 08b99f041ffc9b39c01c10f16a783f2e0aedbb74..ea1d8611efa6f377966c87d30dd7657d62e9d11e 100644 (file)
@@ -61,6 +61,26 @@ LABEL, BUS="scsi", SYSFS_vendor="?IBM-ESXS", NAME="boot_disk%n-1"
 LABEL, BUS="scsi", SYSFS_vendor="IBM-ESXS?", NAME="boot_disk%n-2"
 LABEL, BUS="scsi", SYSFS_vendor="IBM-ES??", NAME="boot_disk%n"
 LABEL, BUS="scsi", SYSFS_vendor="IBM-ESXSS", NAME="boot_disk%n-3"
+EOF
+       },
+       {
+               desc     => "label test of multiple sysfs files",
+               subsys   => "block",
+               devpath  => "block/sda/sda1",
+               expected => "boot_disk1" ,
+               conf     => <<EOF
+LABEL, BUS="scsi", SYSFS_vendor="IBM-ESXS", SYSFS_model="ST336605LW   !#", NAME="boot_diskX%n"
+LABEL, BUS="scsi", SYSFS_vendor="IBM-ESXS", SYSFS_model="ST336605LW    !#", NAME="boot_disk%n"
+EOF
+       },
+       {
+               desc     => "label test of max sysfs files",
+               subsys   => "block",
+               devpath  => "block/sda/sda1",
+               expected => "boot_disk1" ,
+               conf     => <<EOF
+LABEL, BUS="scsi", SYSFS_vendor="IBM-ESXS", SYSFS_model="ST336605LW    !#", SYSFS_scsi_level="4", SYSFS_rev="B245", SYSFS_type="2", SYSFS_queue_depth="32", NAME="boot_diskXX%n"
+LABEL, BUS="scsi", SYSFS_vendor="IBM-ESXS", SYSFS_model="ST336605LW    !#", SYSFS_scsi_level="4", SYSFS_rev="B245", SYSFS_type="0", NAME="boot_disk%n"
 EOF
        },
        {
@@ -101,6 +121,39 @@ EOF
                expected => "visor" ,
                conf     => <<EOF
 REPLACE, KERNEL="ttyUSB0", NAME="visor"
+EOF
+       },
+       {
+               desc     => "Handle comment lines in config file (and replace kernel name)",
+               subsys   => "tty",
+               devpath  => "class/tty/ttyUSB0",
+               expected => "visor" ,
+               conf     => <<EOF
+# this is a comment
+REPLACE, KERNEL="ttyUSB0", NAME="visor"
+
+EOF
+       },
+       {
+               desc     => "Handle comment lines in config file with whitespace (and replace kernel name)",
+               subsys   => "tty",
+               devpath  => "class/tty/ttyUSB0",
+               expected => "visor" ,
+               conf     => <<EOF
+ # this is a comment with whitespace before the comment 
+REPLACE, KERNEL="ttyUSB0", NAME="visor"
+
+EOF
+       },
+       {
+               desc     => "Handle empty lines in config file (and replace kernel name)",
+               subsys   => "tty",
+               devpath  => "class/tty/ttyUSB0",
+               expected => "visor" ,
+               conf     => <<EOF
+
+REPLACE, KERNEL="ttyUSB0", NAME="visor"
+
 EOF
        },
        {
@@ -159,6 +212,16 @@ EOF
                expected => "link1" ,
                conf     => <<EOF
 CALLOUT, BUS="scsi", PROGRAM="/bin/echo -n node link1 link2", ID="node *", NAME="%1c", SYMLINK="%2c %3c"
+EOF
+       },
+       {
+               desc     => "callout for device with no bus",
+               subsys   => "tty",
+               devpath  => "class/tty/console",
+               expected => "TTY" ,
+               conf     => <<EOF
+CALLOUT, BUS="scsi", PROGRAM="/bin/echo -n foo", ID="foo", NAME="foo"
+REPLACE, KERNEL="console", NAME="TTY"
 EOF
        },
        {
@@ -275,7 +338,7 @@ print CONF "udev_permissions=\"$perm\"\n";
 close CONF;
 
 foreach my $config (@tests) {
-       $config->{conf} =~ m/^([A-Z]*).*/;
+       $config->{conf} =~ m/([A-Z]+)\s*,/;
        my $method  = $1;
 
        print "TEST: $config->{desc}\n";