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" ,
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/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
},
{
exp_name => "my-foo8" ,
rules => <<EOF
BUS=="scsi", PROGRAM=="/bin/echo -n foo3 foo4 foo5 foo6 foo7 foo8 foo9", KERNEL=="sda3", NAME="my-%c{6}"
+EOF
+ },
+ {
+ desc => "test substitution by variable name",
+ subsys => "block",
+ devpath => "/block/sda/sda3",
+ exp_name => "Major:8-minor:3-kernelnumber:3-bus:0:0:0:0" ,
+ rules => <<EOF
+BUS=="scsi", ID=="0:0:0:0", NAME="Major:\$major-minor:\$minor-kernelnumber:\$number-bus:\$id"
+EOF
+ },
+ {
+ desc => "test substitution by variable name 2",
+ subsys => "block",
+ devpath => "/block/sda/sda3",
+ exp_name => "Major:8-minor:3-kernelnumber:3-bus:0:0:0:0" ,
+ rules => <<EOF
+BUS=="scsi", ID=="0:0:0:0", DEVPATH="*/sda/*", NAME="Major:\$major-minor:%m-kernelnumber:\$number-bus:%b"
+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
},
{
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
},
{
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"
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
},
{
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
},
{
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
},
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
},
{
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
},
);