chiark / gitweb /
don't report an error on overlong comment lines
[elogind.git] / test / udev-test.pl
old mode 100644 (file)
new mode 100755 (executable)
index 3172d33..63715ac
@@ -24,7 +24,6 @@ my $PWD               = $ENV{PWD};
 my $sysfs      = "sys/";
 my $udev_bin   = "../udev";
 my $udev_root  = "udev-root/"; # !!! directory will be removed !!!
-my $udev_db    = ".udevdb";
 my $udev_conf  = "udev-test.conf";
 my $udev_rules = "udev-test.rules";
 
@@ -232,7 +231,7 @@ KERNEL=="ttyUSB0", NAME="sub/direct/ory/visor"
 EOF
        },
        {
-               desc            => "place on bus of scsi partition",
+               desc            => "parent device name match of scsi partition",
                subsys          => "block",
                devpath         => "/block/sda/sda3",
                exp_name        => "first_disk3" ,
@@ -241,21 +240,41 @@ BUS=="scsi", ID=="0:0:0:0", NAME="first_disk%n"
 EOF
        },
        {
-               desc            => "test NAME substitution chars",
+               desc            => "test substitution chars",
                subsys          => "block",
                devpath         => "/block/sda/sda3",
-               exp_name        => "Major:8:minor:3:kernelnumber:3:bus:0:0:0:0" ,
+               exp_name        => "Major:8:minor:3:kernelnumber:3:id:0:0:0:0" ,
                rules           => <<EOF
-BUS=="scsi", ID=="0:0:0:0", NAME="Major:%M:minor:%m:kernelnumber:%n:bus:%b"
+BUS=="scsi", ID=="0:0:0:0", NAME="Major:%M:minor:%m:kernelnumber:%n:id:%b"
 EOF
        },
        {
-               desc            => "test NAME substitution chars (with length limit)",
+               desc            => "test substitution chars (with length limit)",
                subsys          => "block",
                devpath         => "/block/sda/sda3",
                exp_name        => "M8-m3-n3-b0:0-sIBM" ,
                rules           => <<EOF
 BUS=="scsi", ID=="0:0:0:0", NAME="M%M-m%m-n%n-b%3b-s%3s{vendor}"
+EOF
+       },
+       {
+               desc            => "import of shell-value file",
+               subsys          => "block",
+               devpath         => "/block/sda",
+               exp_name        => "subdir/info/node" ,
+               rules           => <<EOF
+BUS=="scsi", IMPORT{file}="udev-test.conf", NAME="subdir/%E{udev_log}/node"
+KERNEL=="ttyUSB0", NAME="visor"
+EOF
+       },
+       {
+               desc            => "import of shell-value returned from program",
+               subsys          => "block",
+               devpath         => "/block/sda",
+               exp_name        => "node12345678",
+               rules           => <<EOF
+BUS=="scsi", IMPORT="/bin/echo -e \' TEST_KEY=12345678  \\n  TEST_key2=98765 \'", NAME="node\$env{TEST_KEY}"
+KERNEL=="ttyUSB0", NAME="visor"
 EOF
        },
        {
@@ -279,15 +298,6 @@ BUS=="scsi", PROGRAM=="/bin/echo -n special-device", RESULT=="special--*", NAME=
 BUS=="scsi", PROGRAM=="/bin/echo -n special-device", RESULT=="special-device-", NAME="%c-3-%n"
 BUS=="scsi", PROGRAM=="/bin/echo -n special-device", RESULT=="special-devic", NAME="%c-4-%n"
 BUS=="scsi", PROGRAM=="/bin/echo -n special-device", RESULT=="special-*", NAME="%c-%n"
-EOF
-       },
-       {
-               desc            => "program result substitution (no argument should be subsystem)",
-               subsys          => "block",
-               devpath         => "/block/sda/sda3",
-               exp_name        => "subsys_block" ,
-               rules           => <<EOF
-BUS=="scsi", PROGRAM=="/bin/echo", RESULT=="block", NAME="subsys_block"
 EOF
        },
        {
@@ -363,27 +373,62 @@ BUS=="scsi", PROGRAM=="/bin/echo -n foo3 foo4 foo5 foo6 foo7 foo8 foo9", KERNEL=
 EOF
        },
        {
-               desc            => "invalid program for device with no bus",
-               subsys          => "tty",
-               devpath         => "/class/tty/console",
-               exp_name        => "TTY" ,
+               desc            => "test substitution by variable name",
+               subsys          => "block",
+               devpath         => "/block/sda/sda3",
+               exp_name        => "Major:8-minor:3-kernelnumber:3-id:0:0:0:0",
                rules           => <<EOF
-BUS=="scsi", PROGRAM=="/bin/echo -n foo", RESULT=="foo", NAME="foo"
-KERNEL=="console", NAME="TTY"
+BUS=="scsi", ID=="0:0:0:0", NAME="Major:\$major-minor:\$minor-kernelnumber:\$number-id:\$id"
 EOF
        },
        {
-               desc            => "valid program for device with no bus",
+               desc            => "test substitution by variable name 2",
+               subsys          => "block",
+               devpath         => "/block/sda/sda3",
+               exp_name        => "Major:8-minor:3-kernelnumber:3-id:0:0:0:0",
+               rules           => <<EOF
+BUS=="scsi", ID=="0:0:0:0", DEVPATH=="*/sda/*", NAME="Major:\$major-minor:%m-kernelnumber:\$number-id:\$id"
+EOF
+       },
+       {
+               desc            => "test substitution by variable name 3",
+               subsys          => "block",
+               devpath         => "/block/sda/sda3",
+               exp_name        => "830:0:0:03" ,
+               rules           => <<EOF
+BUS=="scsi", ID=="0:0:0:0", DEVPATH=="*/sda/*", NAME="%M%m%b%n"
+EOF
+       },
+       {
+               desc            => "test substitution by variable name 4",
+               subsys          => "block",
+               devpath         => "/block/sda/sda3",
+               exp_name        => "833" ,
+               rules           => <<EOF
+BUS=="scsi", ID=="0:0:0:0", DEVPATH=="*/sda/*", NAME="\$major\$minor\$number"
+EOF
+       },
+       {
+               desc            => "test substitution by variable name 5",
+               subsys          => "block",
+               devpath         => "/block/sda/sda3",
+               exp_name        => "8330:0:0:0" ,
+               rules           => <<EOF
+BUS=="scsi", ID=="0:0:0:0", DEVPATH=="*/sda/*", NAME="\$major%m%n\$id"
+EOF
+       },
+       {
+               desc            => "non matching BUS for device with no parent",
                subsys          => "tty",
                devpath         => "/class/tty/console",
-               exp_name        => "foo" ,
+               exp_name        => "TTY",
                rules           => <<EOF
-PROGRAM=="/bin/echo -n foo", RESULT=="foo", NAME="foo"
+BUS=="scsi", PROGRAM=="/bin/echo -n foo", RESULT=="foo", NAME="foo"
 KERNEL=="console", NAME="TTY"
 EOF
        },
        {
-               desc            => "invalid label for device with no bus",
+               desc            => "non matching BUS",
                subsys          => "tty",
                devpath         => "/class/tty/console",
                exp_name        => "TTY" ,
@@ -393,7 +438,7 @@ KERNEL=="console", NAME="TTY"
 EOF
        },
        {
-               desc            => "valid label for device with no bus",
+               desc            => "SYSFS match",
                subsys          => "tty",
                devpath         => "/class/tty/console",
                exp_name        => "foo" ,
@@ -734,6 +779,17 @@ EOF
                exp_target      => "ttyUSB0",
                rules           => <<EOF
 KERNEL=="ttyUSB[0-9]*", NAME="ttyUSB%n", SYMLINK="symlink1-%n symlink2-%k symlink3-%b"
+EOF
+       },
+       {
+               desc            => "multiple symlinks with a lot of s p a c e s",
+               subsys          => "tty",
+               devpath         => "/class/tty/ttyUSB0",
+               exp_name        => "one",
+               not_exp_name    => " ",
+               exp_target      => "ttyUSB0",
+               rules           => <<EOF
+KERNEL=="ttyUSB[0-9]*", NAME="ttyUSB%n", SYMLINK="  one     two        "
 EOF
        },
        {
@@ -783,9 +839,9 @@ EOF
                exp_name        => "symlink-only2",
                exp_target      => "link",
                rules           => <<EOF
-BUS=="scsi", KERNEL=="sda", SYMLINK="symlink-only1"
-BUS=="scsi", KERNEL=="sda", SYMLINK="symlink-only2"
-BUS=="scsi", KERNEL=="sda", NAME="link", SYMLINK="symlink0"
+BUS=="scsi", KERNEL=="sda", SYMLINK+="symlink-only1"
+BUS=="scsi", KERNEL=="sda", SYMLINK+="symlink-only2"
+BUS=="scsi", KERNEL=="sda", NAME="link", SYMLINK+="symlink0"
 EOF
        },
        {
@@ -797,7 +853,7 @@ EOF
                exp_add_error   => "yes",
                exp_rem_error   => "yes",
                rules           => <<EOF
-BUS=="scsi", KERNEL=="sda", NAME="link", SYMLINK="."
+BUS=="scsi", KERNEL=="sda", NAME="link", SYMLINK+="."
 EOF
        },
        {
@@ -806,10 +862,11 @@ EOF
                devpath         => "/class/tty/tty0",
                exp_name        => "link",
                exp_target      => "link",
+               exp_add_error   => "yes",
                exp_rem_error   => "yes",
                option          => "clean",
                rules           => <<EOF
-KERNEL=="tty0", NAME="link", SYMLINK="link"
+KERNEL=="tty0", NAME="link", SYMLINK+="link"
 EOF
        },
        {
@@ -819,7 +876,7 @@ EOF
                exp_name        => "symlink0",
                exp_target      => "ttyUSB0",
                rules           => <<EOF
-KERNEL=="ttyUSB[0-9]*", NAME="ttyUSB%n", SYMLINK="symlink%n"
+KERNEL=="ttyUSB[0-9]*", NAME="ttyUSB%n", SYMLINK+="symlink%n"
 EOF
        },
        {
@@ -829,7 +886,7 @@ EOF
                exp_name        => "symlink-ttyUSB0",
                exp_target      => "ttyUSB0",
                rules           => <<EOF
-KERNEL=="ttyUSB[0-9]*", NAME="ttyUSB%n", SYMLINK="symlink-%k"
+KERNEL=="ttyUSB[0-9]*", NAME="ttyUSB%n", SYMLINK+="symlink-%k"
 EOF
        },
        {
@@ -839,7 +896,7 @@ EOF
                exp_name        => "major-188:0",
                exp_target      => "ttyUSB0",
                rules           => <<EOF
-KERNEL=="ttyUSB[0-9]*", NAME="ttyUSB%n", SYMLINK="major-%M:%m"
+KERNEL=="ttyUSB[0-9]*", NAME="ttyUSB%n", SYMLINK+="major-%M:%m"
 EOF
        },
        {
@@ -849,7 +906,7 @@ EOF
                exp_name        => "symlink-0:0:0:0",
                exp_target      => "node",
                rules           => <<EOF
-BUS=="scsi", KERNEL=="sda", NAME="node", SYMLINK="symlink-%b"
+BUS=="scsi", KERNEL=="sda", NAME="node", SYMLINK+="symlink-%b"
 EOF
        },
        {
@@ -859,7 +916,7 @@ EOF
                exp_name        => "test",
                exp_target      => "ttyUSB0",
                rules           => <<EOF
-KERNEL=="ttyUSB[0-9]*", PROGRAM=="/bin/echo test" NAME="ttyUSB%n", SYMLINK="%c"
+KERNEL=="ttyUSB[0-9]*", PROGRAM=="/bin/echo test" NAME="ttyUSB%n", SYMLINK+="%c"
 EOF
        },
        {
@@ -869,7 +926,7 @@ EOF
                exp_name        => "test",
                exp_target      => "ttyUSB0",
                rules           => <<EOF
-KERNEL=="ttyUSB[0-9]*", PROGRAM=="/bin/echo symlink test this" NAME="ttyUSB%n", SYMLINK="%c{2}"
+KERNEL=="ttyUSB[0-9]*", PROGRAM=="/bin/echo symlink test this" NAME="ttyUSB%n", SYMLINK+="%c{2}"
 EOF
        },
        {
@@ -879,7 +936,7 @@ EOF
                exp_name        => "this",
                exp_target      => "ttyUSB0",
                rules           => <<EOF
-KERNEL=="ttyUSB[0-9]*", PROGRAM=="/bin/echo symlink test this" NAME="ttyUSB%n", SYMLINK="%c{2+}"
+KERNEL=="ttyUSB[0-9]*", PROGRAM=="/bin/echo symlink test this" NAME="ttyUSB%n", SYMLINK+="%c{2+}"
 EOF
        },
        {
@@ -889,8 +946,8 @@ EOF
                exp_name        => "test",
                exp_target      => "link",
                rules           => <<EOF
-BUS=="scsi", KERNEL=="sda", PROGRAM=="/bin/echo link test this" SYMLINK="%c{2+}"
-BUS=="scsi", KERNEL=="sda", NAME="link", SYMLINK="symlink0"
+BUS=="scsi", KERNEL=="sda", PROGRAM=="/bin/echo link test this" SYMLINK+="%c{2+}"
+BUS=="scsi", KERNEL=="sda", NAME="link", SYMLINK+="symlink0"
 EOF
        },
        {
@@ -900,7 +957,7 @@ EOF
                exp_name        => "188:0",
                exp_target      => "ttyUSB0",
                rules           => <<EOF
-KERNEL=="ttyUSB[0-9]*", NAME="ttyUSB%n", SYMLINK="%s{dev}"
+KERNEL=="ttyUSB[0-9]*", NAME="ttyUSB%n", SYMLINK+="%s{dev}"
 EOF
        },
        {
@@ -910,7 +967,7 @@ EOF
                exp_name        => "188",
                exp_target      => "ttyUSB0",
                rules           => <<EOF
-KERNEL=="ttyUSB[0-9]*", NAME="ttyUSB%n", SYMLINK="%3s{dev}"
+KERNEL=="ttyUSB[0-9]*", NAME="ttyUSB%n", SYMLINK+="%3s{dev}"
 EOF
        },
        {
@@ -920,7 +977,7 @@ EOF
                exp_name        => "percent%sign",
                exp_target      => "ttyUSB0",
                rules           => <<EOF
-KERNEL=="ttyUSB[0-9]*", NAME="ttyUSB%n", SYMLINK="percent%%sign"
+KERNEL=="ttyUSB[0-9]*", NAME="ttyUSB%n", SYMLINK+="percent%%sign"
 EOF
        },
        {
@@ -930,7 +987,7 @@ EOF
                exp_name        => "%ttyUSB0_name",
                exp_target      => "ttyUSB0",
                rules           => <<EOF
-KERNEL=="ttyUSB[0-9]*", NAME="ttyUSB%n", SYMLINK="%%%k_name"
+KERNEL=="ttyUSB[0-9]*", NAME="ttyUSB%n", SYMLINK+="%%%k_name"
 EOF
        },
        {
@@ -940,7 +997,7 @@ EOF
                exp_name        => "link1",
                exp_target      => "node",
                rules           => <<EOF
-BUS=="scsi", PROGRAM=="/bin/echo -n node link1 link2", RESULT=="node *", NAME="%c{1}", SYMLINK="%c{2} %c{3}"
+BUS=="scsi", PROGRAM=="/bin/echo -n node link1 link2", RESULT=="node *", NAME="%c{1}", SYMLINK+="%c{2} %c{3}"
 EOF
        },
        {
@@ -950,82 +1007,15 @@ EOF
                exp_name        => "link4",
                exp_target      => "node",
                rules           => <<EOF
-BUS=="scsi", PROGRAM=="/bin/echo -n node link1 link2 link3 link4", RESULT=="node *", NAME="%c{1}", SYMLINK="%c{2+}"
-EOF
-       },
-       {
-               desc            => "enumeration char test (single test)",
-               subsys          => "block",
-               devpath         => "/block/sda",
-               exp_name        => "cdrom",
-               rules           => <<EOF
-KERNEL=="sda", NAME="cdrom%e"
-EOF
-       },
-       {
-               desc            => "enumeration char test sequence 1/5 (keep)",
-               subsys          => "block",
-               devpath         => "/block/sda",
-               exp_name        => "cdrom",
-               option          => "keep",
-               rules           => <<EOF
-KERNEL=="sda", NAME="cdrom%e"
-EOF
-       },
-       {
-               desc            => "enumeration char test sequence 2/5 (keep)",
-               subsys          => "block",
-               devpath         => "/block/sda/sda1",
-               exp_name        => "enum",
-               option          => "keep",
-               rules           => <<EOF
-KERNEL=="sda1", NAME="enum%e"
-EOF
-       },
-       {
-               desc            => "enumeration char test sequence 3/5 (keep)",
-               subsys          => "block",
-               devpath         => "/block/sda/sda2",
-               exp_name        => "cdrom1",
-               option          => "keep",
-               rules           => <<EOF
-KERNEL=="sda2", NAME="cdrom%e"
-EOF
-       },
-       {
-               desc            => "enumeration char test sequence 4/5 (keep)",
-               subsys          => "block",
-               devpath         => "/block/sda/sda3",
-               exp_name        => "enum1",
-               option          => "keep",
-               rules           => <<EOF
-KERNEL=="sda3", NAME="enum%e"
-EOF
-       },
-       {
-               desc            => "enumeration char test sequence 5/5 (clean)",
-               subsys          => "block",
-               devpath         => "/block/sda/sda4",
-               exp_name        => "cdrom2",
-               option          => "clean",
-               rules           => <<EOF
-KERNEL=="sda4", NAME="cdrom%e"
-EOF
-       },
-       {
-               desc            => "enumeration char test after cleanup (single test)",
-               subsys          => "block",
-               devpath         => "/block/sda",
-               exp_name        => "cdrom",
-               rules           => <<EOF
-KERNEL=="sda", NAME="cdrom%e"
+BUS=="scsi", PROGRAM=="/bin/echo -n node link1 link2 link3 link4", RESULT=="node *", NAME="%c{1}", SYMLINK+="%c{2+}"
 EOF
        },
        {
                desc            => "ignore rule test",
                subsys          => "block",
                devpath         => "/block/sda",
-               exp_name        => "node",
+               exp_name        => "nothing",
+               not_exp_name    => "node",
                exp_add_error   => "yes",
                rules           => <<EOF
 BUS=="scsi", KERNEL=="sda", NAME="node", OPTIONS="ignore"
@@ -1147,7 +1137,7 @@ EOF
                devpath         => "/block/sda/sda1",
                exp_name        => "last",
                rules           => <<EOF
-BUS=="scsi", KERNEL=="sda1", SYMLINK="last", OPTIONS="last_rule"
+BUS=="scsi", KERNEL=="sda1", SYMLINK+="last", OPTIONS="last_rule"
 BUS=="scsi", KERNEL=="sda1", NAME="very-last"
 EOF
        },
@@ -1214,6 +1204,31 @@ BUS=="scsi", KERNEL=="sda1", ENV{ENV_KEY_TEST}=="go", NAME="wrong"
 BUS=="scsi", KERNEL=="sda1", ENV{ENV_KEY_TEST}=="yes", ENV{ACTION}=="add", ENV{DEVPATH}=="/block/sda/sdax1", NAME="no"
 BUS=="scsi", KERNEL=="sda1", ENV{ENV_KEY_TEST}=="test", ENV{ACTION}=="add", ENV{DEVPATH}=="/block/sda/sda1", NAME="true"
 BUS=="scsi", KERNEL=="sda1", ENV{ENV_KEY_TEST}=="bad", NAME="bad"
+EOF
+       },
+       {
+               desc            => "ENV{} test (assign)",
+               subsys          => "block",
+               devpath         => "/block/sda/sda1",
+               exp_name        => "true",
+               rules           => <<EOF
+BUS=="scsi", KERNEL=="sda1", ENV{ASSIGN}="true"
+BUS=="scsi", KERNEL=="sda1", ENV{ASSIGN}=="yes", NAME="no"
+BUS=="scsi", KERNEL=="sda1", ENV{ASSIGN}=="true", NAME="true"
+BUS=="scsi", KERNEL=="sda1", NAME="bad"
+EOF
+       },
+       {
+               desc            => "ENV{} test (assign2)",
+               subsys          => "block",
+               devpath         => "/block/sda/sda1",
+               exp_name        => "part",
+               rules           => <<EOF
+SUBSYSTEM=="block", KERNEL=="*[0-9]", ENV{PARTITION}="true", ENV{MAINDEVICE}="false"
+SUBSYSTEM=="block", KERNEL=="*[!0-9]", ENV{PARTITION}="false", ENV{MAINDEVICE}="true"
+ENV{MAINDEVICE}=="true", NAME="disk"
+ENV{PARTITION}=="true", NAME="part"
+NAME="bad"
 EOF
        },
        {
@@ -1222,7 +1237,25 @@ EOF
                devpath         => "/block/sda/sda1",
                exp_name        => "sane",
                rules           => <<EOF
-BUS=="scsi", KERNEL=="sda1", PROGRAM=="/bin/echo -e name; (/sbin/badprogram)", RESULT="name_ _/sbin/badprogram_", NAME="sane"
+BUS=="scsi", KERNEL=="sda1", PROGRAM=="/bin/echo -e name; (/sbin/badprogram)", RESULT=="name_ _/sbin/badprogram_", NAME="sane"
+EOF
+       },
+       {
+               desc            => "untrusted string sanitize (don't replace utf8)",
+               subsys          => "block",
+               devpath         => "/block/sda/sda1",
+               exp_name        => "uber",
+               rules           => <<EOF
+BUS=="scsi", KERNEL=="sda1", PROGRAM=="/bin/echo -e \\xc3\\xbcber" RESULT=="\xc3\xbcber", NAME="uber"
+EOF
+       },
+       {
+               desc            => "untrusted string sanitize (replace invalid utf8)",
+               subsys          => "block",
+               devpath         => "/block/sda/sda1",
+               exp_name        => "replaced",
+               rules           => <<EOF
+BUS=="scsi", KERNEL=="sda1", PROGRAM=="/bin/echo -e \\xef\\xe8garbage", RESULT=="__garbage", NAME="replaced"
 EOF
        },
        {
@@ -1290,7 +1323,7 @@ EOF
                exp_rem_error   => "yes",
                option          => "clean",
                rules           => <<EOF
-KERNEL=="sda", NAME="ok", RUN+="/bin/sh -c 'ln -s `basename \$DEVNAME` %r/testsymlink'"
+KERNEL=="sda", NAME="ok", RUN+="/bin/sh -c 'ln -s `basename \$\$DEVNAME` %r/testsymlink'"
 KERNEL=="sda", NAME="not-ok"
 EOF
        },
@@ -1304,6 +1337,179 @@ EOF
 KERNEL=="sda", NAME="ok2", RUN+="/bin/ln -s ok2 %r/testsymlink2"
 KERNEL=="sda", ACTION=="remove", RUN+="/bin/rm -f %r/testsymlink2"
 KERNEL=="sda", NAME="not-ok2"
+EOF
+       },
+       {
+               desc            => "final assignment",
+               subsys          => "block",
+               devpath         => "/block/sda",
+               exp_name        => "ok",
+               exp_perms       => "root:nobody:0640",
+               rules           => <<EOF
+KERNEL=="sda", GROUP:="nobody"
+KERNEL=="sda", GROUP="not-ok", MODE="0640", NAME="ok"
+EOF
+       },
+       {
+               desc            => "final assignment",
+               subsys          => "block",
+               devpath         => "/block/sda",
+               exp_name        => "ok",
+               exp_perms       => "root:nobody:0640",
+               rules           => <<EOF
+KERNEL=="sda", GROUP:="nobody"
+SUBSYSTEM=="block", MODE:="640"
+KERNEL=="sda", GROUP="not-ok", MODE="0666", NAME="ok"
+EOF
+       },
+       {
+               desc            => "env substitution",
+               subsys          => "block",
+               devpath         => "/block/sda",
+               exp_name        => "node-add-me",
+               rules           => <<EOF
+KERNEL=="sda", MODE="0666", NAME="node-\$env{ACTION}-me"
+EOF
+       },
+       {
+               desc            => "reset list to current value",
+               subsys          => "tty",
+               devpath         => "/class/tty/ttyUSB0",
+               exp_name        => "three",
+               not_exp_name    => "two",
+               exp_target      => "node",
+               rules           => <<EOF
+KERNEL=="ttyUSB[0-9]*", SYMLINK+="one"
+KERNEL=="ttyUSB[0-9]*", SYMLINK+="two"
+KERNEL=="ttyUSB[0-9]*", SYMLINK="three"
+KERNEL=="ttyUSB[0-9]*", NAME="node"
+EOF
+       },
+       {
+               desc            => "test empty NAME",
+               subsys          => "tty",
+               devpath         => "/class/tty/ttyUSB0",
+               exp_name        => "node",
+               not_exp_name    => "wrong",
+               exp_add_error   => "yes",
+               rules           => <<EOF
+KERNEL=="ttyUSB[0-9]*", NAME=""
+KERNEL=="ttyUSB[0-9]*", NAME="wrong"
+EOF
+       },
+       {
+               desc            => "test empty NAME 2",
+               subsys          => "tty",
+               devpath         => "/class/tty/ttyUSB0",
+               exp_name        => "right",
+               rules           => <<EOF
+KERNEL=="ttyUSB[0-9]*", NAME="right"
+KERNEL=="ttyUSB[0-9]*", NAME=""
+KERNEL=="ttyUSB[0-9]*", NAME="wrong"
+EOF
+       },
+       {
+               desc            => "test multi matches",
+               subsys          => "tty",
+               devpath         => "/class/tty/ttyUSB0",
+               exp_name        => "right",
+               rules           => <<EOF
+KERNEL=="ttyUSB*|nothing", NAME="right"
+KERNEL=="ttyUSB*", NAME="wrong"
+EOF
+       },
+       {
+               desc            => "test multi matches 2",
+               subsys          => "tty",
+               devpath         => "/class/tty/ttyUSB0",
+               exp_name        => "right",
+               rules           => <<EOF
+KERNEL=="dontknow*|*nothing", NAME="nomatch"
+KERNEL=="dontknow*|ttyUSB*|nothing*", NAME="right"
+KERNEL=="ttyUSB*", NAME="wrong"
+EOF
+       },
+       {
+               desc            => "IMPORT parent test sequence 1/2 (keep)",
+               subsys          => "block",
+               devpath         => "/block/sda",
+               exp_name        => "parent",
+               option          => "keep",
+               rules           => <<EOF
+KERNEL=="sda", IMPORT="/bin/echo -e \'PARENT_KEY=parent_right\\nWRONG_PARENT_KEY=parent_wrong'"
+KERNEL=="sda", NAME="parent"
+EOF
+       },
+       {
+               desc            => "IMPORT parent test sequence 2/2 (keep)",
+               subsys          => "block",
+               devpath         => "/block/sda/sda1",
+               exp_name        => "parentenv-parent_right",
+               option          => "clean",
+               rules           => <<EOF
+KERNEL=="sda1", IMPORT{parent}="PARENT*", NAME="parentenv-\$env{PARENT_KEY}\$env{WRONG_PARENT_KEY}"
+EOF
+       },
+       {
+               desc            => "GOTO test",
+               subsys          => "block",
+               devpath         => "/block/sda/sda1",
+               exp_name        => "right",
+               rules           => <<EOF
+KERNEL=="sda1", GOTO="TEST"
+KERNEL=="sda1", NAME="wrong"
+KERNEL=="sda1", NAME="", LABEL="NO"
+KERNEL=="sda1", NAME="right", LABEL="TEST"
+KERNEL=="sda1", NAME="wrong2"
+EOF
+       },
+       {
+               desc            => "NAME compare test",
+               subsys          => "block",
+               devpath         => "/block/sda/sda1",
+               exp_name        => "link",
+               exp_target      => "node",
+               not_exp_name    => "wronglink",
+               rules           => <<EOF
+KERNEL=="sda1", NAME="node"
+KERNEL=="sda2", NAME="wrong"
+KERNEL=="sda1", NAME=="wrong*", SYMLINK+="wronglink"
+KERNEL=="sda1", NAME=="?*", SYMLINK+="link"
+KERNEL=="sda1", NAME=="node*", SYMLINK+="link2"
+EOF
+       },
+       {
+               desc            => "NAME compare test 2",
+               subsys          => "block",
+               devpath         => "/block/sda/sda1",
+               exp_name        => "link2",
+               exp_target      => "sda1",
+               not_exp_name    => "link",
+               rules           => <<EOF
+KERNEL=="sda1", NAME=="?*", SYMLINK+="link"
+KERNEL=="sda1", NAME!="?*", SYMLINK+="link2"
+EOF
+       },
+       {
+               desc            => "invalid key operation",
+               subsys          => "block",
+               devpath         => "/block/sda/sda1",
+               exp_name        => "yes",
+               rules           => <<EOF
+KERNEL="sda1", NAME=="no"
+KERNEL=="sda1", NAME="yes"
+EOF
+       },
+       {
+               desc            => "overlong comment line",
+               subsys          => "block",
+               devpath         => "/block/sda/sda1",
+               exp_name        => "yes",
+               rules           => <<EOF
+# 012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
+   # 012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
+KERNEL="sda1", NAME=="no"
+KERNEL=="sda1", NAME="yes"
 EOF
        },
 );
@@ -1443,6 +1649,13 @@ sub run_test {
                my ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size,
                    $atime, $mtime, $ctime, $blksize, $blocks) = stat("$PWD/$udev_root$rules->{exp_name}");
 
+               if (defined($rules->{not_exp_name})) {
+                       if ((-e "$PWD/$udev_root$rules->{not_exp_name}") ||
+                           (-l "$PWD/$udev_root$rules->{not_exp_name}")) {
+                               print "nonexistent: error \'$rules->{not_exp_name}\' not expected to be there\n";
+                               $error++
+                       }
+               }
                if (defined($rules->{exp_perms})) {
                        permissions_test($rules, $uid, $gid, $mode);
                }
@@ -1489,7 +1702,6 @@ sub run_test {
        print "\n";
 
        if (defined($rules->{option}) && $rules->{option} eq "clean") {
-               system("rm -rf $udev_db");
                system("rm -rf $udev_root");
                mkdir($udev_root) || die "unable to create udev_root: $udev_root\n";
        }
@@ -1510,8 +1722,8 @@ mkdir($udev_root) || die "unable to create udev_root: $udev_root\n";
 # create config file
 open CONF, ">$udev_conf" || die "unable to create config file: $udev_conf";
 print CONF "udev_root=\"$udev_root\"\n";
-print CONF "udev_db=\"$udev_db\"\n";
 print CONF "udev_rules=\"$udev_rules\"\n";
+print CONF "udev_log=\"info\"\n";
 close CONF;
 
 my $test_num = 1;
@@ -1539,7 +1751,6 @@ if ($ARGV[0]) {
 print "$error errors occured\n\n";
 
 # cleanup
-system("rm -rf $udev_db");
 system("rm -rf $udev_root");
 unlink($udev_rules);
 unlink($udev_conf);