X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=test%2Fudev-test.pl;h=c7e1a9d47e7f4d3898f9a070e1e4b7d2853888a1;hp=d584579584ba2b7bb7606ba2ebaed0d32ba26d93;hb=882af735ec18cb4e6ba6f59ca60f8266cc96c330;hpb=b1e95455d2683f43f47ea94a7b79af64f0738d36 diff --git a/test/udev-test.pl b/test/udev-test.pl index d58457958..c7e1a9d47 100644 --- a/test/udev-test.pl +++ b/test/udev-test.pl @@ -14,14 +14,8 @@ # After creation and removal the result is checked against the # expected value and the result is printed. # -# happy testing, # Kay Sievers , 2003 -# -# Modified April 9, 2004 by Leann Ogasawara -# - 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 , 2004 use warnings; use strict; @@ -31,10 +25,12 @@ my $sysfs = "sys/"; my $udev_bin = "../udev"; my $udev_root = "udev-root/"; # !!! directory will be removed !!! my $udev_db = ".udevdb"; -my $perm = "udev.permissions"; my $main_conf = "udev-test.conf"; my $conf_tmp = "udev-test.rules"; +# uncomment following line to run udev with valgrind. +# Should make this a runtime option to the script someday... +#my $udev_bin = "valgrind --tool=memcheck --leak-check=yes ../udev"; my @tests = ( { @@ -185,6 +181,45 @@ EOF 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 => < "preserve backslashes, if they are not for a newline", + subsys => "tty", + devpath => "/class/tty/ttyUSB0", + exp_name => "aaa", + conf => < "Handle stupid backslashed multi lines in config file (and replace kernel name)", + subsys => "tty", + devpath => "/class/tty/ttyUSB0", + exp_name => "visor" , + conf => < "/block/sda/sda3", exp_name => "first_disk3" , conf => < "/block/sda/sda3", exp_name => "Major:8:minor:3:kernelnumber:3:bus:0:0:0:0" , conf => < "/block/sda/sda3", exp_name => "M8-m3-n3-b0:0-sIBM" , conf => < "permissions test", - subsys => "block", - devpath => "/block/sda", - exp_name => "node", - exp_perms => "5000::0444", - conf => < "permissions ttyUSB0:root:uucp:0660", - subsys => "tty", - devpath => "/class/tty/ttyUSB0", - exp_name => "ttyUSB0", - exp_perms => "0:14:0660", - conf => < "permissions tty0::root:0444", - subsys => "tty", - devpath => "/class/tty/tty0", - exp_name => "tty0", - exp_perms => "0:0:0444", - conf => < "permissions tty1:root::0555", - subsys => "tty", - devpath => "/class/tty/tty1", - exp_name => "tty1", - exp_perms => "0:0:0555", - conf => < "permissions tty2:::0777", - subsys => "tty", - devpath => "/class/tty/tty2", - exp_name => "tty2", - exp_perms => "0:0:0777", - conf => < "permissions tty3::: (default mode applied)", - subsys => "tty", - devpath => "/class/tty/tty3", - exp_name => "tty3", - exp_perms => "0:0:600", - conf => < "permissions i2c-300:root:sys:0744", - subsys => "i2c-dev", - devpath => "/class/i2c-dev/i2c-300", - exp_name => "i2c-300", - exp_perms => "0:3:0744", - conf => < "permissions i2c-fake1:root:7:0007", - subsys => "i2c-dev", - devpath => "/class/i2c-dev/i2c-fake1", - exp_name => "i2c-fake1", - exp_perms => "0:7:0007", - conf => < "permissions ttyS[01]:0:5:0700", - subsys => "tty", - devpath => "/class/tty/ttyS1", - exp_name => "ttyS1", - exp_perms => "0:5:0700", - conf => < "permissions ttyS[4-9]:tty:5:0060", - subsys => "tty", - devpath => "/class/tty/ttyS7", - exp_name => "ttyS7", - exp_perms => "0:5:0060", - conf => < "permissions tty4:0:5:0707", - subsys => "ttyS4", - devpath => "/class/tty/tty4", - exp_name => "tty4", - exp_perms => "0:5:0707", - conf => < "permissions tty4?:0:5:0007", - subsys => "tty", - devpath => "/class/tty/tty44", - exp_name => "tty44", - exp_perms => "0:5:0007", - conf => < "permissions tty3[!3]:::0467", - subsys => "tty", - devpath => "/class/tty/tty35", - exp_name => "tty35", - exp_perms => "0:0:0467", - conf => < "permissions tty33:bad:name:0500", + desc => "permissions USER=bad GROUP=name", subsys => "tty", devpath => "/class/tty/tty33", exp_name => "tty33", - exp_perms => "0:0:0500", - conf => < "permissions rtc:0:users:0600", - subsys => "misc", - devpath => "/class/misc/rtc", - exp_name => "misc/rtc", - exp_perms => "0:100:0600", + exp_perms => "0:0:0660", conf => < "permissions misc:0:users:0600", - subsys => "misc", - devpath => "/class/misc/psaux", - exp_name => "misc/psaux", - exp_perms => "0:100:0600", - conf => < "permissions set OWNER=5000", + desc => "permissions OWNER=5000", subsys => "block", devpath => "/block/sda", exp_name => "node", - exp_perms => "5000::0600", + exp_perms => "5000::0660", conf => < "permissions set GROUP=100", + desc => "permissions GROUP=100", subsys => "block", devpath => "/block/sda", exp_name => "node", - exp_perms => ":100:0600", + exp_perms => ":100:0660", conf => < "permissions set mode=0777", + desc => "permissions MODE=0777", subsys => "block", devpath => "/block/sda", exp_name => "node", @@ -690,7 +575,7 @@ BUS="scsi", KERNEL="sda", NAME="node", MODE="0777" EOF }, { - desc => "permissions set OWNER=5000 GROUP=100 MODE=0777", + desc => "permissions OWNER=5000 GROUP=100 MODE=0777", subsys => "block", devpath => "/block/sda", exp_name => "node", @@ -700,17 +585,17 @@ BUS="scsi", KERNEL="sda", NAME="node", OWNER="5000", GROUP="100", MODE="0777" EOF }, { - desc => "permissions override OWNER to 5000", + desc => "permissions OWNER to 5000", subsys => "tty", devpath => "/class/tty/ttyUSB0", exp_name => "ttyUSB0", - exp_perms => "5000:14:0660", + exp_perms => "5000::", conf => < "permissions override GROUP to 100", + desc => "permissions GROUP to 100", subsys => "tty", devpath => "/class/tty/ttyUSB0", exp_name => "ttyUSB0", @@ -720,23 +605,63 @@ KERNEL="ttyUSB[0-9]*", NAME="ttyUSB%n", GROUP="100" EOF }, { - desc => "permissions override MODE to 0060", + desc => "permissions MODE to 0060", subsys => "tty", devpath => "/class/tty/ttyUSB0", exp_name => "ttyUSB0", - exp_perms => ":14:0060", + exp_perms => "::0060", conf => < "permissions override OWNER, GROUP, MODE", + desc => "permissions OWNER, GROUP, MODE", subsys => "tty", devpath => "/class/tty/ttyUSB0", exp_name => "ttyUSB0", exp_perms => "5000:100:0777", conf => < "permissions only rule", + subsys => "tty", + devpath => "/class/tty/ttyUSB0", + exp_name => "ttyUSB0", + exp_perms => "5000:100:0777", + conf => < "multiple permissions only rule", + subsys => "tty", + devpath => "/class/tty/ttyUSB0", + exp_name => "ttyUSB0", + exp_perms => "3000:4000:0777", + conf => < "permissions only rule with override at NAME rule", + subsys => "tty", + devpath => "/class/tty/ttyUSB0", + exp_name => "ttyUSB0", + exp_perms => "3000:8000:0777", + conf => < "symlink name empty", - subsys => "block", - devpath => "/block/sda", - exp_name => "", - exp_target => "link", - exp_error => "yes", - conf => < "/block/sda", exp_name => ".", exp_target => "link", - exp_error => "yes", + exp_add_error => "yes", + exp_rem_error => "yes", conf => < "symlink to empty name", - subsys => "block", - devpath => "/block/sda", - exp_name => "symlink", - exp_target => "", - exp_error => "yes", - conf => < "symlink and name empty", - subsys => "block", - devpath => "/block/sda", - exp_name => "", - exp_target => "", - exp_error => "yes", - conf => < "/class/tty/tty0", exp_name => "link", exp_target => "link", + exp_rem_error => "yes", + option => "clear", conf => < "enumeration char test sequence (1/5 keep)", + desc => "enumeration char test sequence 1/5 (keep)", subsys => "block", devpath => "/block/sda", exp_name => "cdrom", @@ -1102,6 +997,37 @@ EOF exp_name => "cdrom", conf => < "ignore rule test", + subsys => "block", + devpath => "/block/sda", + exp_name => "node", + exp_add_error => "yes", + conf => < "all_partitions, option-only rule", + subsys => "block", + devpath => "/block/sda", + exp_name => "node6", + conf => < "all_partitions, option-only rule (fail on partition)", + subsys => "block", + devpath => "/block/sda/sda1", + exp_name => "node6", + exp_add_error => "yes", + conf => < "block", devpath => "/block/sda", exp_name => "node", - exp_error => "yes", + exp_rem_error => "yes", conf => < "block", devpath => "/block/sda", exp_name => "node14", - exp_error => "yes", + exp_rem_error => "yes", option => "clear", conf => < < "temporary node creation test", + subsys => "block", + devpath => "/block/sda", + exp_name => "node", + conf => < "devpath substitution test", + subsys => "block", + devpath => "/block/sda", + exp_name => "sda", + conf => < "parent node name substitution test sequence 1/2 (keep)", + subsys => "block", + devpath => "/block/sda", + exp_name => "main_device", + option => "keep", + conf => < "parent node name substitution test sequence 2/2 (clean)", + subsys => "block", + devpath => "/block/sda/sda1", + exp_name => "main_device-part-1", + option => "clean", + conf => < "udev_root substitution", + subsys => "block", + devpath => "/block/sda/sda1", + exp_name => "start-udev-root-end", + option => "clean", + conf => <{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++; @@ -1238,7 +1213,7 @@ sub symlink_test { } 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++; @@ -1259,7 +1234,6 @@ sub run_test { udev("add", $config->{subsys}, $config->{devpath}, \$config->{conf}); - if ((-e "$PWD/$udev_root$config->{exp_name}") || (-l "$PWD/$udev_root$config->{exp_name}")) { @@ -1278,7 +1252,7 @@ sub run_test { print "add: ok "; } else { print "add: error "; - if ($config->{exp_error}) { + if ($config->{exp_add_error}) { print "as expected "; } else { print "\n\n"; @@ -1297,7 +1271,7 @@ sub run_test { 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"; @@ -1333,7 +1307,6 @@ open CONF, ">$main_conf" || die "unable to create config file: $main_conf"; print CONF "udev_root=\"$udev_root\"\n"; print CONF "udev_db=\"$udev_db\"\n"; print CONF "udev_rules=\"$conf_tmp\"\n"; -print CONF "udev_permissions=\"$perm\"\n"; close CONF; my $test_num = 1;