From 72ffa78debb1f96488b5e13d3151486563b460e7 Mon Sep 17 00:00:00 2001 From: "greg@kroah.com" Date: Wed, 3 Dec 2003 08:13:53 -0800 Subject: [PATCH] [PATCH] fix up the tests to work without all of the environ variables. --- test/label_test | 23 +++++++++++++++++------ test/modifier_test | 23 +++++++++++++++++------ test/replace_test | 24 +++++++++++++++++------- test/topo_test | 23 +++++++++++++++++------ test/udev-test.pl | 18 ++++++++++++------ 5 files changed, 80 insertions(+), 31 deletions(-) diff --git a/test/label_test b/test/label_test index b0a605cda..c33393743 100644 --- a/test/label_test +++ b/test/label_test @@ -1,13 +1,22 @@ #!/bin/bash +RULES=label_test.rules +CONFIG=label_test.conf + export UDEV_TEST=yes export SYSFS_PATH=$PWD/sys/ -export UDEV_CONFIG_DIR=$PWD/ -export UDEV_ROOT=$PWD/udev/ -export UDEV_DB=udev.tdb -export UDEV_CONFIG_FILE=label_test.config -export UDEV_RULES_FILE=label_test.rules -export UDEV_PERMISSION_FILE=udev.permissions +export UDEV_CONFIG_FILE=$PWD/$CONFIG + +cat > $RULES << EOF +LABEL, BUS="scsi", vendor="IBM-ESXS", NAME="boot_disk%n" +EOF + +cat > $CONFIG << EOF +udev_root="$PWD/udev/" +udev_db="$PWD/udev/.udev.tdb" +udev_rules="$PWD/$RULES" +udev_permissions="$PWD/udev.permissions" +EOF export ACTION=add export DEVPATH=block/sda @@ -32,3 +41,5 @@ export DEVPATH=block/sda/sda3 ls udev +rm $RULES +rm $CONFIG diff --git a/test/modifier_test b/test/modifier_test index a028d20e4..bbe072e58 100644 --- a/test/modifier_test +++ b/test/modifier_test @@ -1,13 +1,22 @@ #!/bin/bash +RULES=modifier_test.rules +CONFIG=modifier_test.conf + export UDEV_TEST=yes export SYSFS_PATH=$PWD/sys/ -export UDEV_CONFIG_DIR=$PWD/ -export UDEV_ROOT=$PWD/udev/ -export UDEV_DB=udev.tdb -export UDEV_CONFIG_FILE=modifier_test.config -export UDEV_RULES_FILE=modifier_test.rules -export UDEV_PERMISSION_FILE=udev.permissions +export UDEV_CONFIG_FILE=$PWD/$CONFIG + +cat > $RULES << EOF +TOPOLOGY, BUS="scsi", place="0:0:0:0", NAME="Major:%M:minor:%m:kernelnumber:%n:bus:%b" +EOF + +cat > $CONFIG << EOF +udev_root="$PWD/udev/" +udev_db="$PWD/udev/.udev.tdb" +udev_rules="$PWD/$RULES" +udev_permissions="$PWD/udev.permissions" +EOF export ACTION=add export DEVPATH=block/sda @@ -31,3 +40,5 @@ export DEVPATH=block/sda/sda3 ../udev block ls udev +rm $RULES +rm $CONFIG diff --git a/test/replace_test b/test/replace_test index aae07b48a..375c8dced 100644 --- a/test/replace_test +++ b/test/replace_test @@ -1,13 +1,22 @@ #!/bin/bash +RULES=replace_test.rules +CONFIG=replace_test.conf + export UDEV_TEST=yes export SYSFS_PATH=$PWD/sys/ -export UDEV_CONFIG_DIR=$PWD/ -export UDEV_ROOT=$PWD/udev/ -export UDEV_DB=udev.tdb -export UDEV_CONFIG_FILE=replace_test.config -export UDEV_RULES_FILE=replace_test.rules -export UDEV_PERMISSION_FILE=udev.permissions +export UDEV_CONFIG_FILE=$PWD/$CONFIG + +cat > $RULES << EOF +REPLACE, KERNEL="ttyUSB0", NAME="visor" +EOF + +cat > $CONFIG << EOF +udev_root="$PWD/udev/" +udev_db="$PWD/udev/.udev.tdb" +udev_rules="$PWD/$RULES" +udev_permissions="$PWD/udev.permissions" +EOF export DEVPATH=class/tty/ttyUSB0 export ACTION=add @@ -19,4 +28,5 @@ export ACTION=remove ../udev tty ls -l udev - +rm $RULES +rm $CONFIG diff --git a/test/topo_test b/test/topo_test index 71121f478..9225685c8 100644 --- a/test/topo_test +++ b/test/topo_test @@ -1,13 +1,22 @@ #!/bin/bash +RULES=replace_test.rules +CONFIG=replace_test.conf + export UDEV_TEST=yes export SYSFS_PATH=$PWD/sys/ -export UDEV_CONFIG_DIR=$PWD/ -export UDEV_ROOT=$PWD/udev/ -export UDEV_DB=udev.tdb -export UDEV_CONFIG_FILE=topo_test.config -export UDEV_RULES_FILE=topo_test.rules -export UDEV_PERMISSION_FILE=udev.permissions +export UDEV_CONFIG_FILE=$PWD/$CONFIG + +cat > $RULES << EOF +TOPOLOGY, BUS="scsi", place="0:0:0:0", NAME="first_disk%n" +EOF + +cat > $CONFIG << EOF +udev_root="$PWD/udev/" +udev_db="$PWD/udev/.udev.tdb" +udev_rules="$PWD/$RULES" +udev_permissions="$PWD/udev.permissions" +EOF export ACTION=add export DEVPATH=block/sda @@ -31,3 +40,5 @@ export DEVPATH=block/sda/sda3 ../udev block ls udev +rm $RULES +rm $CONFIG diff --git a/test/udev-test.pl b/test/udev-test.pl index 47190f6e5..97f75edc9 100644 --- a/test/udev-test.pl +++ b/test/udev-test.pl @@ -27,7 +27,8 @@ my $udev_bin = "../udev"; my $udev_root = "udev-root/"; # !!! directory will be removed !!! my $udev_db = ".udev.tdb"; my $perm = "udev.permissions"; -my $conf_tmp = "udev-test.config"; +my $main_conf = "udev-test.conf"; +my $conf_tmp = "udev-test.rules"; my @tests = ( @@ -173,17 +174,13 @@ EOF # set env $ENV{UDEV_TEST} = "yes"; $ENV{SYSFS_PATH} = $sysfs; -$ENV{UDEV_CONFIG_DIR} = "./"; -$ENV{UDEV_ROOT} = $udev_root; -$ENV{UDEV_DB} = $udev_db; -$ENV{UDEV_PERMISSION_FILE} = $perm; +$ENV{UDEV_CONFIG_FILE} = $main_conf; sub udev { my ($action, $subsys, $devpath, $config) = @_; $ENV{DEVPATH} = $devpath; - $ENV{UDEV_RULES_FILE} = $conf_tmp; # create temporary config open CONF, ">$conf_tmp" || die "unable to create config file: $conf_tmp"; @@ -203,6 +200,14 @@ mkdir($udev_root) || die "unable to create udev_root: $udev_root\n"; my $error = 0; print "\nudev-test will run ".($#tests + 1)." tests:\n\n"; +# create initial config file +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; + foreach my $config (@tests) { $config->{conf} =~ m/^([A-Z]*).*/; my $method = $1; @@ -236,4 +241,5 @@ print "$error errors occured\n\n"; unlink($udev_db); system("rm -rf $udev_root"); unlink($conf_tmp); +unlink($main_conf); -- 2.30.2