chiark / gitweb /
[PATCH] udev-test.pl: remove useless tests
[elogind.git] / test / udev-test.pl
index 5a519ef13b40145e57e6839f4f788c05c809e3a6..9699f2e8f50fdcecac17ea0b318ac4ebaaa25659 100644 (file)
 # 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;
@@ -198,6 +192,15 @@ 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
        },
        {
@@ -761,17 +764,6 @@ 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
        },
        {
@@ -780,31 +772,10 @@ 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
-       },
-       {
-               desc            => "symlink to empty name",
-               subsys          => "block",
-               devpath         => "/block/sda",
-               exp_name        => "symlink",
-               exp_target      => "",
-               exp_error       => "yes",
-               conf            => <<EOF
-BUS="scsi", KERNEL="sda", NAME="", SYMLINK="symlink"
-EOF
-       },
-       {
-               desc            => "symlink and name empty",
-               subsys          => "block",
-               devpath         => "/block/sda",
-               exp_name        => "",
-               exp_target      => "",
-               exp_error       => "yes",
-               conf            => <<EOF
-BUS="scsi", KERNEL="sda", NAME="", SYMLINK=""
 EOF
        },
        {
@@ -813,6 +784,8 @@ 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
@@ -1024,6 +997,37 @@ EOF
                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
        },
        {
@@ -1031,9 +1035,9 @@ 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
        },
        {
@@ -1041,10 +1045,10 @@ 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
        },
        {
@@ -1072,9 +1076,9 @@ EOF
                desc            => "temporary node creation test",
                subsys          => "block",
                devpath         => "/block/sda",
-               exp_name        => "sda",
+               exp_name        => "node",
                conf            => <<EOF
-BUS="scsi", KERNEL="sda", PROGRAM="/usr/bin/test -b %N" NAME="%N"
+BUS="scsi", KERNEL="sda", PROGRAM="/usr/bin/test -b %N" NAME="node"
 EOF
        },
        {
@@ -1200,7 +1204,7 @@ sub symlink_test {
                } 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++;
@@ -1209,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++;
@@ -1248,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";
@@ -1267,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";