|
|
6136c1 |
From 8ee1cc626f616a2022d641a464fbde9108dd8ad9 Mon Sep 17 00:00:00 2001
|
|
|
6136c1 |
From: Martin Wilck <mwilck@suse.com>
|
|
|
6136c1 |
Date: Tue, 24 Apr 2018 10:50:24 +0200
|
|
|
6136c1 |
Subject: [PATCH] test/udev-test.pl: test correctness of symlink targets
|
|
|
6136c1 |
|
|
|
6136c1 |
Test if symlinks are created correctly by comparing the symlink
|
|
|
6136c1 |
targets to the devnode path. This implies (for the symlink) that
|
|
|
6136c1 |
major/minor numbers and permissions are correct, as we have tested
|
|
|
6136c1 |
that on the devnode already.
|
|
|
6136c1 |
|
|
|
6136c1 |
(cherry picked from commit 997683c8f152e1c139a7ce537de81a0aeae4627f)
|
|
|
6136c1 |
|
|
|
6136c1 |
Related: #1642728
|
|
|
6136c1 |
---
|
|
|
6136c1 |
test/udev-test.pl | 23 ++++++++++++++++++-----
|
|
|
6136c1 |
1 file changed, 18 insertions(+), 5 deletions(-)
|
|
|
6136c1 |
|
|
|
6136c1 |
diff --git a/test/udev-test.pl b/test/udev-test.pl
|
|
|
6136c1 |
index aa9a8dc2ff..2e3089c5e0 100755
|
|
|
6136c1 |
--- a/test/udev-test.pl
|
|
|
6136c1 |
+++ b/test/udev-test.pl
|
|
|
6136c1 |
@@ -22,6 +22,7 @@ use POSIX qw(WIFEXITED WEXITSTATUS);
|
|
|
6136c1 |
use IPC::SysV qw(IPC_PRIVATE S_IRUSR S_IWUSR IPC_CREAT);
|
|
|
6136c1 |
use IPC::Semaphore;
|
|
|
6136c1 |
use Time::HiRes qw(usleep);
|
|
|
6136c1 |
+use Cwd qw(getcwd abs_path);
|
|
|
6136c1 |
|
|
|
6136c1 |
my $udev_bin = "./test-udev";
|
|
|
6136c1 |
my $valgrind = 0;
|
|
|
6136c1 |
@@ -2243,14 +2244,26 @@ sub check_add {
|
|
|
6136c1 |
|
|
|
6136c1 |
my $devnode = check_devnode($device);
|
|
|
6136c1 |
|
|
|
6136c1 |
- print "device \'$device->{devpath}\' expecting node/link \'$device->{exp_name}\'\n";
|
|
|
6136c1 |
return if (!defined($device->{exp_name}));
|
|
|
6136c1 |
|
|
|
6136c1 |
- if ((-e "$udev_dev/$device->{exp_name}") ||
|
|
|
6136c1 |
- (-l "$udev_dev/$device->{exp_name}")) {
|
|
|
6136c1 |
- print "add $device->{devpath}: ok\n";
|
|
|
6136c1 |
+ my @st = lstat("$udev_dev/$device->{exp_name}");
|
|
|
6136c1 |
+ if (-l _) {
|
|
|
6136c1 |
+ my $cwd = getcwd();
|
|
|
6136c1 |
+ my $dir = "$udev_dev/$device->{exp_name}";
|
|
|
6136c1 |
+ $dir =~ s!/[^/]*$!!;
|
|
|
6136c1 |
+ my $tgt = readlink("$udev_dev/$device->{exp_name}");
|
|
|
6136c1 |
+ $tgt = abs_path("$dir/$tgt");
|
|
|
6136c1 |
+ $tgt =~ s!^$cwd/!!;
|
|
|
6136c1 |
+
|
|
|
6136c1 |
+ if ($tgt ne $devnode) {
|
|
|
6136c1 |
+ print "symlink $device->{exp_name}: error, found -> $tgt\n";
|
|
|
6136c1 |
+ $error++;
|
|
|
6136c1 |
+ system("tree", "$udev_dev");
|
|
|
6136c1 |
+ } else {
|
|
|
6136c1 |
+ print "symlink $device->{exp_name}: ok\n";
|
|
|
6136c1 |
+ }
|
|
|
6136c1 |
} else {
|
|
|
6136c1 |
- print "add $device->{devpath}: error";
|
|
|
6136c1 |
+ print "symlink $device->{exp_name}: error";
|
|
|
6136c1 |
if ($device->{exp_add_error}) {
|
|
|
6136c1 |
print " as expected\n";
|
|
|
6136c1 |
} else {
|