# After creation and removal the result is checked against the
# expected value and the result is printed.
#
-# happy testing,
# Kay Sievers <kay.sievers@vrfy.org>, 2003
-#
-# Modified April 9, 2004 by Leann Ogasawara <ogasawara@osdl.org>
-# - expanded @tests array to add more symlinks and permissions tests
-# - some of the symlinks tests also test lack of node creation
-# - added symlink_test() function
-# - moved permissions and major_minor tests into their own functions
+# Leann Ogasawara <ogasawara@osdl.org>, 2004
use warnings;
use strict;
KERNEL="ttyUSB0", NAME="visor"
+EOF
+ },
+ {
+ desc => "Handle backslashed multi lines in config file (and replace kernel name)",
+ subsys => "tty",
+ devpath => "/class/tty/ttyUSB0",
+ exp_name => "visor" ,
+ conf => <<EOF
+KERNEL="ttyUSB0", \\
+NAME="visor"
+
+EOF
+ },
+ {
+ desc => "preserve backslashes, if they are not for a newline",
+ subsys => "tty",
+ devpath => "/class/tty/ttyUSB0",
+ exp_name => "aaa",
+ conf => <<EOF
+KERNEL="ttyUSB0", PROGRAM="/bin/echo -e \\101", RESULT="A", NAME="aaa"
+EOF
+ },
+ {
+ desc => "Handle stupid backslashed multi lines in config file (and replace kernel name)",
+ subsys => "tty",
+ devpath => "/class/tty/ttyUSB0",
+ exp_name => "visor" ,
+ conf => <<EOF
+
+#
+\\
+
+\\\\
+
+#\\
+
+KERNEL="ttyUSB0", \\
+ NAME="visor"
+
EOF
},
{
exp_perms => "5000:100:0777",
conf => <<EOF
KERNEL="ttyUSB[0-9]*", NAME="ttyUSB%n", OWNER="5000", GROUP="100", MODE="0777"
+EOF
+ },
+ {
+ desc => "permissions only rule",
+ subsys => "tty",
+ devpath => "/class/tty/ttyUSB0",
+ exp_name => "ttyUSB0",
+ exp_perms => "5000:100:0777",
+ conf => <<EOF
+KERNEL="ttyUSB[0-9]*", OWNER="5000", GROUP="100", MODE="0777"
+KERNEL="ttyUSX[0-9]*", OWNER="5001", GROUP="101", MODE="0444"
+KERNEL="ttyUSB[0-9]*", NAME="ttyUSB%n"
+EOF
+ },
+ {
+ desc => "multiple permissions only rule",
+ subsys => "tty",
+ devpath => "/class/tty/ttyUSB0",
+ exp_name => "ttyUSB0",
+ exp_perms => "3000:4000:0777",
+ conf => <<EOF
+SUBSYSTEM="tty", OWNER="3000"
+SUBSYSTEM="tty", GROUP="4000"
+SUBSYSTEM="tty", MODE="0777"
+KERNEL="ttyUSX[0-9]*", OWNER="5001", GROUP="101", MODE="0444"
+KERNEL="ttyUSB[0-9]*", NAME="ttyUSB%n"
+EOF
+ },
+ {
+ desc => "permissions only rule with override at NAME rule",
+ subsys => "tty",
+ devpath => "/class/tty/ttyUSB0",
+ exp_name => "ttyUSB0",
+ exp_perms => "3000:8000:0777",
+ conf => <<EOF
+SUBSYSTEM="tty", OWNER="3000"
+SUBSYSTEM="tty", GROUP="4000"
+SUBSYSTEM="tty", MODE="0777"
+KERNEL="ttyUSX[0-9]*", OWNER="5001", GROUP="101", MODE="0444"
+KERNEL="ttyUSB[0-9]*", NAME="ttyUSB%n", GROUP="8000"
EOF
},
{
BUS="scsi", KERNEL="sda", SYMLINK="symlink-only1"
BUS="scsi", KERNEL="sda", SYMLINK="symlink-only2"
BUS="scsi", KERNEL="sda", NAME="link", SYMLINK="symlink0"
-EOF
- },
- {
- desc => "symlink name empty",
- subsys => "block",
- devpath => "/block/sda",
- exp_name => "",
- exp_target => "link",
- exp_error => "yes",
- conf => <<EOF
-BUS="scsi", KERNEL="sda", NAME="link", SYMLINK=""
EOF
},
{
devpath => "/block/sda",
exp_name => ".",
exp_target => "link",
- exp_error => "yes",
+ exp_add_error => "yes",
+ exp_rem_error => "yes",
conf => <<EOF
BUS="scsi", KERNEL="sda", NAME="link", SYMLINK="."
EOF
devpath => "/block/sda",
exp_name => "symlink",
exp_target => "",
- exp_error => "yes",
+ exp_add_error => "yes",
conf => <<EOF
BUS="scsi", KERNEL="sda", NAME="", SYMLINK="symlink"
EOF
devpath => "/block/sda",
exp_name => "",
exp_target => "",
- exp_error => "yes",
+ exp_add_error => "yes",
+ exp_rem_error => "yes",
conf => <<EOF
BUS="scsi", KERNEL="sda", NAME="", SYMLINK=""
EOF
devpath => "/class/tty/tty0",
exp_name => "link",
exp_target => "link",
+ exp_rem_error => "yes",
+ option => "clear",
conf => <<EOF
KERNEL="tty0", NAME="link", SYMLINK="link"
EOF
EOF
},
{
- desc => "enumeration char test sequence (1/5 keep)",
+ desc => "enumeration char test sequence 1/5 (keep)",
subsys => "block",
devpath => "/block/sda",
exp_name => "cdrom",
exp_name => "cdrom",
conf => <<EOF
KERNEL="sda", NAME="cdrom%e"
+EOF
+ },
+ {
+ desc => "ignore rule test",
+ subsys => "block",
+ devpath => "/block/sda",
+ exp_name => "node",
+ exp_add_error => "yes",
+ conf => <<EOF
+BUS="scsi", KERNEL="sda", NAME="node", OPTIONS="ignore"
+EOF
+ },
+ {
+ desc => "all_partitions, option-only rule",
+ subsys => "block",
+ devpath => "/block/sda",
+ exp_name => "node6",
+ conf => <<EOF
+SUBSYSTEM="block", OPTIONS="all_partitions"
+BUS="scsi", KERNEL="sda", NAME="node"
+EOF
+ },
+ {
+ desc => "all_partitions, option-only rule (fail on partition)",
+ subsys => "block",
+ devpath => "/block/sda/sda1",
+ exp_name => "node6",
+ exp_add_error => "yes",
+ conf => <<EOF
+SUBSYSTEM="block", OPTIONS="all_partitions"
+BUS="scsi", KERNEL="sda", NAME="node"
EOF
},
{
subsys => "block",
devpath => "/block/sda",
exp_name => "node",
- exp_error => "yes",
+ exp_rem_error => "yes",
conf => <<EOF
-BUS="scsi", KERNEL="sda", NAME{ignore_remove}="node"
+BUS="scsi", KERNEL="sda", NAME="node", OPTIONS="ignore_remove"
EOF
},
{
subsys => "block",
devpath => "/block/sda",
exp_name => "node14",
- exp_error => "yes",
+ exp_rem_error => "yes",
option => "clear",
conf => <<EOF
-BUS="scsi", KERNEL="sda", NAME{ignore_remove, all_partitions}="node"
+BUS="scsi", KERNEL="sda", NAME="node", OPTIONS="ignore_remove, all_partitions"
EOF
},
{
conf => <<EOF
BUS="scsi", KERNEL="sda", NAME="should_not_match", DRIVER="sd-wrong"
BUS="scsi", KERNEL="sda", NAME="node", DRIVER="sd"
+EOF
+ },
+ {
+ desc => "temporary node creation test",
+ subsys => "block",
+ devpath => "/block/sda",
+ exp_name => "node",
+ conf => <<EOF
+BUS="scsi", KERNEL="sda", PROGRAM="/usr/bin/test -b %N" NAME="node"
+EOF
+ },
+ {
+ desc => "devpath substitution test",
+ subsys => "block",
+ devpath => "/block/sda",
+ exp_name => "sda",
+ conf => <<EOF
+BUS="scsi", KERNEL="sda", PROGRAM="/bin/echo %p", RESULT="/block/sda" NAME="%k"
+EOF
+ },
+ {
+ desc => "parent node name substitution test sequence 1/2 (keep)",
+ subsys => "block",
+ devpath => "/block/sda",
+ exp_name => "main_device",
+ option => "keep",
+ conf => <<EOF
+BUS="scsi", KERNEL="sda", NAME="main_device"
+EOF
+ },
+ {
+ desc => "parent node name substitution test sequence 2/2 (clean)",
+ subsys => "block",
+ devpath => "/block/sda/sda1",
+ exp_name => "main_device-part-1",
+ option => "clean",
+ conf => <<EOF
+BUS="scsi", KERNEL="sda1", NAME="%P-part-1"
+EOF
+ },
+ {
+ desc => "udev_root substitution",
+ subsys => "block",
+ devpath => "/block/sda/sda1",
+ exp_name => "start-udev-root-end",
+ option => "clean",
+ conf => <<EOF
+BUS="scsi", KERNEL="sda1", NAME="start-%r-end"
EOF
},
);
} else {
print "expected symlink from: \'$config->{exp_name}\' to \'$config->{exp_target}\'\n";
print "created symlink from: \'$config->{exp_name}\' to \'$2\'\n";
- if ($config->{exp_error}) {
+ if ($config->{exp_add_error}) {
print "as expected ";
} else {
$error++;
} else {
print "expected symlink from: \'$config->{exp_name}\' to \'$config->{exp_target}\'\n";
print "symlink: not created ";
- if ($config->{exp_error}) {
+ if ($config->{exp_add_error}) {
print "as expected ";
} else {
$error++;
print "add: ok ";
} else {
print "add: error ";
- if ($config->{exp_error}) {
+ if ($config->{exp_add_error}) {
print "as expected ";
} else {
print "\n\n";
if ((-e "$PWD/$udev_root$config->{exp_name}") ||
(-l "$PWD/$udev_root$config->{exp_name}")) {
print "remove: error ";
- if ($config->{exp_error}) {
+ if ($config->{exp_rem_error}) {
print "as expected\n\n";
} else {
print "\n\n";
print CONF "udev_root=\"$udev_root\"\n";
print CONF "udev_db=\"$udev_db\"\n";
print CONF "udev_rules=\"$conf_tmp\"\n";
-print CONF "default_mode=\"0660\"\n";
-print CONF "default_owner=\"root\"\n";
-print CONF "default_group=\"root\"\n";
close CONF;
my $test_num = 1;