From: kay.sievers@vrfy.org Date: Sat, 26 Mar 2005 23:10:03 +0000 (+0100) Subject: [PATCH] test-suite: remove UDEV_TEST, it's not needed anymore X-Git-Tag: 057~30 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=65005a7f81f86590f7f03bd3d4019c485d0e3c77;p=systemd [PATCH] test-suite: remove UDEV_TEST, it's not needed anymore --- diff --git a/test/devd_test b/test/devd_test index 269c2b11..534e787f 100644 --- a/test/devd_test +++ b/test/devd_test @@ -3,7 +3,6 @@ RULES=label_test.rules CONFIG=label_test.conf -export UDEV_TEST=yes export SYSFS_PATH=$PWD/sys/ export UDEV_CONFIG_FILE=$PWD/$CONFIG diff --git a/test/net_test b/test/net_test index 9686f992..9daf8da0 100644 --- a/test/net_test +++ b/test/net_test @@ -3,7 +3,6 @@ RULES=label_test.rules CONFIG=label_test.conf -export UDEV_TEST=yes export SYSFS_PATH=$PWD/sys/ export UDEV_CONFIG_FILE=$PWD/$CONFIG diff --git a/test/replace_test b/test/replace_test index 19260765..6e01f28e 100644 --- a/test/replace_test +++ b/test/replace_test @@ -3,7 +3,6 @@ RULES=replace_test.rules CONFIG=replace_test.conf -export UDEV_TEST=yes export SYSFS_PATH=$PWD/sys/ export UDEV_CONFIG_FILE=$PWD/$CONFIG diff --git a/test/udev-test.pl b/test/udev-test.pl index 6cde54ff..50ea5858 100644 --- a/test/udev-test.pl +++ b/test/udev-test.pl @@ -9,7 +9,7 @@ # Every test is driven by its own temporary config file. # This program prepares the environment, creates the config and calls udev. # -# udev reads the config, looks at the provided sysfs and +# udev parses the rules, looks at the provided sysfs and # first creates and then removes the device node. # After creation and removal the result is checked against the # expected value and the result is printed. @@ -20,13 +20,13 @@ use warnings; use strict; -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 $main_conf = "udev-test.conf"; -my $conf_tmp = "udev-test.rules"; +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"; # uncomment following line to run udev with valgrind. # Should make this a runtime option to the script someday... @@ -38,7 +38,7 @@ my @tests = ( subsys => "block", devpath => "/block/sda", exp_name => "boot_disk" , - conf => < < "block", devpath => "/block/sda/sda1", exp_name => "boot_disk1" , - conf => < < "block", devpath => "/block/sda/sda1", exp_name => "boot_disk1" , - conf => < < "block", devpath => "/block/sda/sda1", exp_name => "boot_disk1" , - conf => < < "block", devpath => "/block/sda/sda1", exp_name => "boot_disk1" , - conf => < < "tty", devpath => "/class/tty/ttyUSB0", exp_name => "visor/0" , - conf => < < "tty", devpath => "/class/tty/ttyUSB0", exp_name => "visor/0" , - conf => < < "tty", devpath => "/class/tty/ttyUSB0", exp_name => "visor/0" , - conf => < < "tty", devpath => "/class/tty/ttyUSB0", exp_name => "visor/0" , - conf => < < "tty", devpath => "/class/tty/ttyUSB0", exp_name => "visor" , - conf => < < "tty", devpath => "/class/tty/ttyUSB0", exp_name => "visor" , - conf => < < "tty", devpath => "/class/tty/ttyUSB0", exp_name => "visor" , - conf => < < "tty", devpath => "/class/tty/ttyUSB0", exp_name => "whitespace" , - conf => < < "tty", devpath => "/class/tty/ttyUSB0", exp_name => "visor" , - conf => < < "tty", devpath => "/class/tty/ttyUSB0", exp_name => "visor" , - conf => < < "tty", devpath => "/class/tty/ttyUSB0", exp_name => "aaa", - conf => < < "tty", devpath => "/class/tty/ttyUSB0", exp_name => "visor" , - conf => < < "tty", devpath => "/class/tty/ttyUSB0", exp_name => "sub/direct/ory/visor" , - conf => < < "block", devpath => "/block/sda/sda3", exp_name => "first_disk3" , - conf => < < "block", devpath => "/block/sda/sda3", exp_name => "Major:8:minor:3:kernelnumber:3:bus:0:0:0:0" , - conf => < < "block", devpath => "/block/sda/sda3", exp_name => "M8-m3-n3-b0:0-sIBM" , - conf => < < "block", devpath => "/block/sda", exp_name => "disk-IBM-ESXS-sda" , - conf => < < "block", devpath => "/block/sda/sda3", exp_name => "special-device-3" , - conf => < < "block", devpath => "/block/sda/sda3", exp_name => "subsys_block" , - conf => < < "block", devpath => "/block/sda/sda3", exp_name => "newline_removed" , - conf => < < "block", devpath => "/block/sda/sda3", exp_name => "test-0:0:0:0" , - conf => < < "block", devpath => "/block/sda/sda3", exp_name => "escape-3" , - conf => < < "block", devpath => "/block/sda/sda3", exp_name => "foo9" , - conf => < < "block", devpath => "/block/sda/sda3", exp_name => "bar9" , - conf => < < "block", devpath => "/block/sda/sda3", exp_name => "foo7" , - conf => < < "block", devpath => "/block/sda/sda3", exp_name => "my-foo9" , - conf => < < "block", devpath => "/block/sda/sda3", exp_name => "my-foo8" , - conf => < < "tty", devpath => "/class/tty/console", exp_name => "TTY" , - conf => < < "tty", devpath => "/class/tty/console", exp_name => "foo" , - conf => < < "tty", devpath => "/class/tty/console", exp_name => "TTY" , - conf => < < "tty", devpath => "/class/tty/console", exp_name => "foo" , - conf => < < "block", devpath => "/block/sda", exp_name => "scsi-0:0:0:0" , - conf => < < "block", devpath => "/block/sda", exp_name => "boot_disk15" , - conf => < < "tty", devpath => "/class/tty/ttyUSB0", exp_name => "visor" , - conf => < < "block", devpath => "/block/rd!c0d0", exp_name => "rd/c0d0" , - conf => < < "block", devpath => "/block/rd!c0d0", exp_name => "rd/c0d0" , - conf => < < "block", devpath => "/block/cciss!c0d0/cciss!c0d0p1", exp_name => "cciss/c0d0p1" , - conf => < < "block", devpath => "/block/sda", exp_name => "scsi-0:0:0:0", - conf => < < "block", devpath => "/block/sda", exp_name => "scsi-0:0:0:0", - conf => < < "block", devpath => "/block/sda", exp_name => "scsi-0:0:0:0", - conf => < < "block", devpath => "/block/sda", exp_name => "scsi-0:0:0:0", - conf => < < "block", devpath => "/block/sda", exp_name => "ignored", - conf => < < "block", devpath => "/block/sda", exp_name => "matched-with-space", - conf => < < "/class/tty/tty33", exp_name => "tty33", exp_perms => "0:0:0660", - conf => < < "/block/sda", exp_name => "node", exp_perms => "5000::0660", - conf => < < "/block/sda", exp_name => "node", exp_perms => ":100:0660", - conf => < < "/block/sda", exp_name => "node", exp_perms => "nobody::0660", - conf => < < "/block/sda", exp_name => "node", exp_perms => ":daemon:0660", - conf => < < "/block/sda", exp_name => "node", exp_perms => "root:mail:0660", - conf => < < "/block/sda", exp_name => "node", exp_perms => "::0777", - conf => < < "/block/sda", exp_name => "node", exp_perms => "5000:100:0777", - conf => < < "/class/tty/ttyUSB0", exp_name => "ttyUSB0", exp_perms => "5000::", - conf => < < "/class/tty/ttyUSB0", exp_name => "ttyUSB0", exp_perms => ":100:0660", - conf => < < "/class/tty/ttyUSB0", exp_name => "ttyUSB0", exp_perms => "::0060", - conf => < < "/class/tty/ttyUSB0", exp_name => "ttyUSB0", exp_perms => "5000:100:0777", - conf => < < "/class/tty/ttyUSB0", exp_name => "ttyUSB0", exp_perms => "5000:100:0777", - conf => < < "/class/tty/ttyUSB0", exp_name => "ttyUSB0", exp_perms => "3000:4000:0777", - conf => < < "/class/tty/ttyUSB0", exp_name => "ttyUSB0", exp_perms => "3000:8000:0777", - conf => < < "/block/sda", exp_name => "node", exp_majorminor => "8:0", - conf => < < "/class/i2c-dev/i2c-300", exp_name => "node", exp_majorminor => "89:300", - conf => < < "/class/i2c-dev/i2c-fake1", exp_name => "node", exp_majorminor => "4095:1", - conf => < < "/class/i2c-dev/i2c-fake2", exp_name => "node", exp_majorminor => "4094:89999", - conf => < < "/class/tty/ttyUSB0", exp_name => "symlink2-ttyUSB0", exp_target => "ttyUSB0", - conf => < < "/class/tty/ttyUSB0", exp_name => "visor0", exp_target => "ttyUSB0", - conf => < < "/block/sda/sda2", exp_name => "1/2/symlink" , exp_target => "a/b/node", - conf => < < "/block/sda/sda2", exp_name => "1/2/c/d/symlink" , exp_target => "../../a/b/node", - conf => < < "/class/tty/ttyUSB0", exp_name => "second-0" , exp_target => "visor" , - conf => < < "/block/sda", exp_name => "symlink-only2", exp_target => "link", - conf => < < "link", exp_add_error => "yes", exp_rem_error => "yes", - conf => < < "link", exp_rem_error => "yes", option => "clear", - conf => < < "/class/tty/ttyUSB0", exp_name => "symlink0", exp_target => "ttyUSB0", - conf => < < "/class/tty/ttyUSB0", exp_name => "symlink-ttyUSB0", exp_target => "ttyUSB0", - conf => < < "/class/tty/ttyUSB0", exp_name => "major-188:0", exp_target => "ttyUSB0", - conf => < < "/block/sda", exp_name => "symlink-0:0:0:0", exp_target => "node", - conf => < < "/class/tty/ttyUSB0", exp_name => "test", exp_target => "ttyUSB0", - conf => < < "/class/tty/ttyUSB0", exp_name => "test", exp_target => "ttyUSB0", - conf => < < "/class/tty/ttyUSB0", exp_name => "this", exp_target => "ttyUSB0", - conf => < < "/block/sda", exp_name => "test", exp_target => "link", - conf => < < "/class/tty/ttyUSB0", exp_name => "188:0", exp_target => "ttyUSB0", - conf => < < "/class/tty/ttyUSB0", exp_name => "188", exp_target => "ttyUSB0", - conf => < < "/class/tty/ttyUSB0", exp_name => "percent%sign", exp_target => "ttyUSB0", - conf => < < "/class/tty/ttyUSB0", exp_name => "%ttyUSB0_name", exp_target => "ttyUSB0", - conf => < < "/block/sda/sda3", exp_name => "link1", exp_target => "node", - conf => < < "/block/sda/sda3", exp_name => "link4", exp_target => "node", - conf => < < "block", devpath => "/block/sda", exp_name => "cdrom", - conf => < < "/block/sda", exp_name => "cdrom", option => "keep", - conf => < < "/block/sda/sda1", exp_name => "enum", option => "keep", - conf => < < "/block/sda/sda2", exp_name => "cdrom1", option => "keep", - conf => < < "/block/sda/sda3", exp_name => "enum1", option => "keep", - conf => < < "/block/sda/sda4", exp_name => "cdrom2", option => "clear", - conf => < < "block", devpath => "/block/sda", exp_name => "cdrom", - conf => < < "/block/sda", exp_name => "node", exp_add_error => "yes", - conf => < < "block", devpath => "/block/sda", exp_name => "node6", - conf => < < "/block/sda/sda1", exp_name => "node6", exp_add_error => "yes", - conf => < < "/block/sda", exp_name => "node", exp_rem_error => "yes", - conf => < < "node14", exp_rem_error => "yes", option => "clear", - conf => < < "block", devpath => "/block/sda", exp_name => "node", - conf => < < "block", devpath => "/block/sda", exp_name => "node", - conf => < < "block", devpath => "/block/sda", exp_name => "node", - conf => < < "block", devpath => "/block/sda", exp_name => "sda", - conf => < < "/block/sda", exp_name => "main_device", option => "keep", - conf => < < "/block/sda/sda1", exp_name => "main_device-part-1", option => "clean", - conf => < < "block", devpath => "/block/sda/sda1", exp_name => "start-udev-root-end", - conf => < < "block", devpath => "/block/sda/sda1", exp_name => "last", - conf => < < "block", devpath => "/block/sda/sda1", exp_name => "match", - conf => < < "block", devpath => "/block/sda/sda1", exp_name => "not-anything", - conf => < < "block", devpath => "/block/sda/sda1", exp_name => "nonzero-program", - conf => < < "block", devpath => "/block/sda/sda1", exp_name => "true", - conf => < < "block", devpath => "/block/sda/sda1", exp_name => "true", - conf => < < "block", devpath => "/block/sda/sda1", exp_name => "true", - conf => < <$conf_tmp" || die "unable to create config file: $conf_tmp"; - print CONF $$config; + # create temporary rules + open CONF, ">$udev_rules" || die "unable to create rules file: $udev_rules"; + print CONF $$rules; close CONF; $ENV{ACTION} = $action; @@ -1242,13 +1242,13 @@ sub udev { my $error = 0; sub permissions_test { - my($config, $uid, $gid, $mode) = @_; + my($rules, $uid, $gid, $mode) = @_; my $wrong = 0; my $userid; my $groupid; - $config->{exp_perms} =~ m/^(.*):(.*):(.*)$/; + $rules->{exp_perms} =~ m/^(.*):(.*):(.*)$/; if ($1 ne "") { if (defined(getpwnam($1))) { $userid = int(getpwnam($1)); @@ -1279,13 +1279,13 @@ sub permissions_test { } sub major_minor_test { - my($config, $rdev) = @_; + my($rules, $rdev) = @_; my $major = ($rdev >> 8) & 0xfff; my $minor = ($rdev & 0xff) | (($rdev >> 12) & 0xfff00); my $wrong = 0; - $config->{exp_majorminor} =~ m/^(.*):(.*)$/; + $rules->{exp_majorminor} =~ m/^(.*):(.*)$/; if ($1 ne "") { if ($major != $1) { $wrong = 1; }; } @@ -1303,18 +1303,18 @@ sub major_minor_test { } sub symlink_test { - my ($config) = @_; + my ($rules) = @_; - my $output = `ls -l $PWD/$udev_root$config->{exp_name}`; + my $output = `ls -l $PWD/$udev_root$rules->{exp_name}`; if ($output =~ m/(.*)-> (.*)/) { - if ($2 eq $config->{exp_target}) { + if ($2 eq $rules->{exp_target}) { print "symlink: ok\n"; } else { - print " expected symlink from: \'$config->{exp_name}\' to \'$config->{exp_target}\'\n"; - print " created symlink from: \'$config->{exp_name}\' to \'$2\'\n"; + print " expected symlink from: \'$rules->{exp_name}\' to \'$rules->{exp_target}\'\n"; + print " created symlink from: \'$rules->{exp_name}\' to \'$2\'\n"; print "symlink: error"; - if ($config->{exp_add_error}) { + if ($rules->{exp_add_error}) { print " as expected\n"; } else { print "\n"; @@ -1322,9 +1322,9 @@ sub symlink_test { } } } else { - print " expected symlink from: \'$config->{exp_name}\' to \'$config->{exp_target}\'\n"; + print " expected symlink from: \'$rules->{exp_name}\' to \'$rules->{exp_target}\'\n"; print "symlink: not created"; - if ($config->{exp_add_error}) { + if ($rules->{exp_add_error}) { print " as expected\n"; } else { print "\n"; @@ -1334,37 +1334,37 @@ sub symlink_test { } sub run_test { - my ($config, $number) = @_; + my ($rules, $number) = @_; - print "TEST $number: $config->{desc}\n"; + print "TEST $number: $rules->{desc}\n"; - if ($config->{exp_target}) { - print "device \'$config->{devpath}\' expecting symlink '$config->{exp_name}' to node \'$config->{exp_target}\'\n"; + if ($rules->{exp_target}) { + print "device \'$rules->{devpath}\' expecting symlink '$rules->{exp_name}' to node \'$rules->{exp_target}\'\n"; } else { - print "device \'$config->{devpath}\' expecting node \'$config->{exp_name}\'\n"; + print "device \'$rules->{devpath}\' expecting node \'$rules->{exp_name}\'\n"; } - udev("add", $config->{subsys}, $config->{devpath}, \$config->{conf}); - if ((-e "$PWD/$udev_root$config->{exp_name}") || - (-l "$PWD/$udev_root$config->{exp_name}")) { + udev("add", $rules->{subsys}, $rules->{devpath}, \$rules->{rules}); + if ((-e "$PWD/$udev_root$rules->{exp_name}") || + (-l "$PWD/$udev_root$rules->{exp_name}")) { my ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, - $atime, $mtime, $ctime, $blksize, $blocks) = stat("$PWD/$udev_root$config->{exp_name}"); + $atime, $mtime, $ctime, $blksize, $blocks) = stat("$PWD/$udev_root$rules->{exp_name}"); - if (defined($config->{exp_perms})) { - permissions_test($config, $uid, $gid, $mode); + if (defined($rules->{exp_perms})) { + permissions_test($rules, $uid, $gid, $mode); } - if (defined($config->{exp_majorminor})) { - major_minor_test($config, $rdev); + if (defined($rules->{exp_majorminor})) { + major_minor_test($rules, $rdev); } - if (defined($config->{exp_target})) { - symlink_test($config); + if (defined($rules->{exp_target})) { + symlink_test($rules); } print "add: ok\n"; } else { print "add: error"; - if ($config->{exp_add_error}) { + if ($rules->{exp_add_error}) { print " as expected\n"; } else { print "\n"; @@ -1374,16 +1374,16 @@ sub run_test { } } - if (defined($config->{option}) && $config->{option} eq "keep") { + if (defined($rules->{option}) && $rules->{option} eq "keep") { print "\n\n"; return; } - udev("remove", $config->{subsys}, $config->{devpath}, \$config->{conf}); - if ((-e "$PWD/$udev_root$config->{exp_name}") || - (-l "$PWD/$udev_root$config->{exp_name}")) { + udev("remove", $rules->{subsys}, $rules->{devpath}, \$rules->{rules}); + if ((-e "$PWD/$udev_root$rules->{exp_name}") || + (-l "$PWD/$udev_root$rules->{exp_name}")) { print "remove: error"; - if ($config->{exp_rem_error}) { + if ($rules->{exp_rem_error}) { print " as expected\n"; } else { print "\n"; @@ -1397,7 +1397,7 @@ sub run_test { print "\n"; - if (defined($config->{option}) && $config->{option} eq "clear") { + if (defined($rules->{option}) && $rules->{option} eq "clear") { system("rm -rf $udev_db"); system("rm -rf $udev_root"); mkdir($udev_root) || die "unable to create udev_root: $udev_root\n"; @@ -1416,11 +1416,11 @@ if (!($<==0)) { system("rm -rf $udev_root"); mkdir($udev_root) || die "unable to create udev_root: $udev_root\n"; -# create initial config file -open CONF, ">$main_conf" || die "unable to create config file: $main_conf"; +# 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=\"$conf_tmp\"\n"; +print CONF "udev_rules=\"$udev_rules\"\n"; close CONF; my $test_num = 1; @@ -1439,8 +1439,8 @@ if ($ARGV[0]) { # test all print "\nudev-test will run ".($#tests + 1)." tests:\n\n"; - foreach my $config (@tests) { - run_test($config, $test_num); + foreach my $rules (@tests) { + run_test($rules, $test_num); $test_num++; } } @@ -1450,6 +1450,6 @@ print "$error errors occured\n\n"; # cleanup system("rm -rf $udev_db"); system("rm -rf $udev_root"); -unlink($conf_tmp); -unlink($main_conf); +unlink($udev_rules); +unlink($udev_conf); diff --git a/test/udevstart-test.pl b/test/udevstart-test.pl index b6f85bb3..1862ffea 100644 --- a/test/udevstart-test.pl +++ b/test/udevstart-test.pl @@ -13,16 +13,15 @@ use strict; my $PWD = $ENV{PWD}; my $sysfs = "sys/"; -my $udev_bin = "../udev"; +my $udevstart_bin = "../udevstart"; my $udev_root = "udev-root/"; # !!! directory will be removed !!! my $udev_db = ".udevdb"; -my $main_conf = "udev-test.conf"; -my $conf_tmp = "udev-test.rules"; +my $udev_conf = "udev-test.conf"; +my $udev_rules = "udev-test.rules"; # set env -$ENV{UDEV_TEST} = "yes"; $ENV{SYSFS_PATH} = $sysfs; -$ENV{UDEV_CONFIG_FILE} = $main_conf; +$ENV{UDEV_CONFIG_FILE} = $udev_conf; $ENV{UDEV_NO_DEVD} = "yes"; $ENV{UDEV_NO_HOTPLUGD} = "yes"; @@ -36,23 +35,29 @@ if (!($<==0)) { system("rm -rf $udev_root"); mkdir($udev_root) || die "unable to create udev_root: $udev_root\n"; -# create initial config file -open CONF, ">$main_conf" || die "unable to create config file: $main_conf"; +# 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=\"$conf_tmp\"\n"; +print CONF "udev_rules=\"$udev_rules\"\n"; close CONF; -system("$udev_bin udevstart"); -my $block = int( `find $udev_root -type b -print | wc -l`); -my $char = int( `find $udev_root -type c -print | wc -l`); +# create rules file +open RULES, ">$udev_rules" || die "unable to create rules file: $udev_rules"; +print RULES "\n"; +close RULES; + +system("$udevstart_bin"); +my $block = int(`find $udev_root -type b -print | wc -l`); +my $char = int(`find $udev_root -type c -print | wc -l`); print "block devices: $block/10\n"; print "char devices: $char/91\n"; +print "\n"; # cleanup system("rm -rf $udev_db"); system("rm -rf $udev_root"); -unlink($conf_tmp); -unlink($main_conf); +unlink($udev_rules); +unlink($udev_conf); diff --git a/udev_config.c b/udev_config.c index 45b11de2..1b6b6142 100644 --- a/udev_config.c +++ b/udev_config.c @@ -219,24 +219,14 @@ static int parse_config_file(void) void udev_init_config(void) { + const char *config; init_variables(); sysfs_get_mnt_path(sysfs_path, sizeof(sysfs_path)); - /* see if we should try to override any of the default values */ - if (getenv("UDEV_TEST") != NULL) { - char *temp; - - temp = getenv("SYSFS_PATH"); - if (temp != NULL) { - strlcpy(sysfs_path, temp, sizeof(sysfs_path)); - no_trailing_slash(sysfs_path); - } - - temp = getenv("UDEV_CONFIG_FILE"); - if (temp != NULL) - strlcpy(udev_config_filename, temp, sizeof(udev_config_filename)); - } + config = getenv("UDEV_CONFIG_FILE"); + if (config != NULL) + strlcpy(udev_config_filename, config, sizeof(udev_config_filename)); parse_config_file(); dbg("sysfs_path='%s'", sysfs_path);