chiark / gitweb /
Merge gregkh@ehlo.org:/home/kay/public_html/pub/scm/linux/hotplug/udev-kay
[elogind.git] / test / udev-test.pl
index 922535213068bfca07058065f1f4549c887fdddf..1bb60bb76e522f57929bf0b818885afbdbb48cb4 100755 (executable)
@@ -256,6 +256,26 @@ EOF
                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/sys/node" ,
+               rules           => <<EOF
+BUS=="scsi", IMPORT{file}="test.all", NAME="subdir%E{SYSFSDIR}/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
        },
        {
@@ -779,6 +799,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
        },
        {
@@ -1070,7 +1101,8 @@ 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"
@@ -1372,6 +1404,15 @@ 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
        },
        {
@@ -1386,6 +1427,71 @@ 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
        },
 );