chiark / gitweb /
[PATCH] add tests for NAME="foo-%c{N}"
[elogind.git] / test / udev-test.pl
index 6e031c4c2c3a7876478984a8d651d0afd4f31f72..60cf16901c13d90a3daf668e1ed013d62241975d 100644 (file)
@@ -191,6 +191,24 @@ EOF
                expected => "Major:8:minor:3:kernelnumber:3:bus:0:0:0:0" ,
                conf     => <<EOF
 BUS="scsi", PLACE="0:0:0:0", NAME="Major:%M:minor:%m:kernelnumber:%n:bus:%b"
+EOF
+       },
+       {
+               desc     => "test NAME substitution chars (with length limit)",
+               subsys   => "block",
+               devpath  => "block/sda/sda3",
+               expected => "M8-m3-n3-b0:0-sIBM" ,
+               conf     => <<EOF
+BUS="scsi", PLACE="0:0:0:0", NAME="M%M-m%m-n%n-b%3b-s%3s{vendor}"
+EOF
+       },
+       {
+               desc     => "old style SYSFS_ attribute",
+               subsys   => "block",
+               devpath  => "block/sda",
+               expected => "good" ,
+               conf     => <<EOF
+BUS="scsi", SYSFS_vendor="IBM-ESXS", NAME="good"
 EOF
        },
        {
@@ -232,6 +250,33 @@ EOF
                expected => "escape-3" ,
                conf     => <<EOF
 BUS="scsi", PROGRAM="/bin/echo -n escape-%%n", KERNEL="sda3", NAME="%c"
+EOF
+       },
+       {
+               desc     => "program with lots of arguments",
+               subsys   => "block",
+               devpath  => "block/sda/sda3",
+               expected => "foo9" ,
+               conf     => <<EOF
+BUS="scsi", PROGRAM="/bin/echo -n foo3 foo4 foo5 foo6 foo7 foo8 foo9", KERNEL="sda3", NAME="%c{7}"
+EOF
+       },
+       {
+               desc     => "characters before the %c{N} substitution",
+               subsys   => "block",
+               devpath  => "block/sda/sda3",
+               expected => "my-foo9" ,
+               conf     => <<EOF
+BUS="scsi", PROGRAM="/bin/echo -n foo3 foo4 foo5 foo6 foo7 foo8 foo9", KERNEL="sda3", NAME="my-%c{7}"
+EOF
+       },
+       {
+               desc     => "substitute the second to last argument",
+               subsys   => "block",
+               devpath  => "block/sda/sda3",
+               expected => "my-foo8" ,
+               conf     => <<EOF
+BUS="scsi", PROGRAM="/bin/echo -n foo3 foo4 foo5 foo6 foo7 foo8 foo9", KERNEL="sda3", NAME="my-%c{6}"
 EOF
        },
        {