aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorkay.sievers@vrfy.org <kay.sievers@vrfy.org>2004-03-12 00:58:33 -0800
committerGreg KH <gregkh@suse.de>2005-04-26 21:35:09 -0700
commitc612a0acc8c45303b5c40538b87e406ac22a26ef (patch)
tree8954ad097f7be38eff787b539d931bd371812033 /test
parent656703759d7d3eac6e8c86f1121cde7dfd6d8cbd (diff)
downloadudev-c612a0acc8c45303b5c40538b87e406ac22a26ef.tar.gz
[PATCH] add permission tests
> Any chance on being able to add a test for this kind of stuff to the > udev-test.pl script? Sure, not brilliant but seems to work :) Only numeric id's are supported so far.
Diffstat (limited to 'test')
-rw-r--r--test/udev-test.pl30
1 files changed, 30 insertions, 0 deletions
diff --git a/test/udev-test.pl b/test/udev-test.pl
index c12a21ee..e345b20c 100644
--- a/test/udev-test.pl
+++ b/test/udev-test.pl
@@ -524,6 +524,16 @@ BUS="scsi", KERNEL="sda", SYMLINK="symlink-only2"
BUS="scsi", KERNEL="sda", NAME="link", SYMLINK="symlink0"
EOF
},
+ {
+ desc => "permissions test",
+ subsys => "block",
+ devpath => "block/sda",
+ expected => "node",
+ perms => "5000::0444",
+ conf => <<EOF
+BUS="scsi", KERNEL="sda", NAME="node", OWNER="5000", MODE="0444"
+EOF
+ },
);
# set env
@@ -556,6 +566,26 @@ sub run_test {
udev("add", $config->{subsys}, $config->{devpath}, \$config->{conf});
if (-e "$PWD/$udev_root$config->{expected}") {
+ if (defined($config->{perms})) {
+ my $wrong = 0;
+ my ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size,
+ $atime, $mtime, $ctime, $blksize, $blocks) = stat("$PWD/$udev_root$config->{expected}");
+
+ $config->{perms} =~ m/^(.*):(.*):(.*)$/;
+ if ($1 ne "") {
+ if ($uid != $1) { $wrong = 1; };
+ }
+ if ($2 ne "") {
+ if ($gid != $2) { $wrong = 1; };
+ }
+ if ($3 ne "") {
+ if (($mode & 07777) != oct($3)) { $wrong = 1; };
+ }
+ if ($wrong == 1) {
+ printf "expected permissions are: %i:%i:%#o\n", $1, $2, oct($3);
+ printf "created permissions are : %i:%i:%#o\n", $uid, $gid, $mode & 07777;
+ }
+ }
print "add: ok ";
} else {
print "add: error\n";