summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2016-04-05 20:36:01 -0400
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2016-04-05 20:36:01 -0400
commite8ceb82e219d730399891da589e30e5cf057843e (patch)
tree33bd79e6de6d49e804698346b1079c8ee88adbd8
parent050d7e19983e6123cba650907d7d33acf2640956 (diff)
parent2ce8d27b1f4e7c53e57d345ba471fb1f547d390c (diff)
Merge pull request #2966 from evverx/udev-test-dont-rely-on-underlying-fs
tests: don't rely on underlying fs in udev-test, use tmpfs instead
-rw-r--r--src/test/test-udev.c10
-rwxr-xr-xtest/udev-test.pl9
2 files changed, 14 insertions, 5 deletions
diff --git a/src/test/test-udev.c b/src/test/test-udev.c
index d01789fe08..64ef08652c 100644
--- a/src/test/test-udev.c
+++ b/src/test/test-udev.c
@@ -40,11 +40,11 @@ static int fake_filesystems(void) {
const char *target;
const char *error;
} fakefss[] = {
- { "test/sys", "/sys", "failed to mount test /sys" },
- { "test/dev", "/dev", "failed to mount test /dev" },
- { "test/run", "/run", "failed to mount test /run" },
- { "test/run", "/etc/udev/rules.d", "failed to mount empty /etc/udev/rules.d" },
- { "test/run", UDEVLIBEXECDIR "/rules.d","failed to mount empty " UDEVLIBEXECDIR "/rules.d" },
+ { "test/tmpfs/sys", "/sys", "failed to mount test /sys" },
+ { "test/dev", "/dev", "failed to mount test /dev" },
+ { "test/run", "/run", "failed to mount test /run" },
+ { "test/run", "/etc/udev/rules.d", "failed to mount empty /etc/udev/rules.d" },
+ { "test/run", UDEVLIBEXECDIR "/rules.d","failed to mount empty " UDEVLIBEXECDIR "/rules.d" },
};
unsigned int i;
int err;
diff --git a/test/udev-test.pl b/test/udev-test.pl
index b047493f6b..3c8a480d0f 100755
--- a/test/udev-test.pl
+++ b/test/udev-test.pl
@@ -29,6 +29,7 @@ my $udev_bin_gdb = "gdb --args $udev_bin";
my $udev_bin_strace = "strace -efile $udev_bin";
my $udev_dev = "test/dev";
my $udev_run = "test/run";
+my $udev_tmpfs = "test/tmpfs";
my $udev_rules_dir = "$udev_run/udev/rules.d";
my $udev_rules = "$udev_rules_dir/udev-test.rules";
my $EXIT_TEST_SKIP = 77;
@@ -1412,6 +1413,12 @@ sub udev_setup {
chown (0, 0, $udev_dev) || die "unable to chown $udev_dev\n";
chmod (0755, $udev_dev) || die "unable to chmod $udev_dev\n";
+ system("umount", "$udev_tmpfs");
+ system("rm", "-rf", "$udev_tmpfs");
+ mkdir($udev_tmpfs) || die "unable to create udev_tmpfs: $udev_tmpfs\n";
+ system("mount", "-o", "rw,mode=755,nosuid,noexec,nodev", "-t", "tmpfs", "tmpfs", "$udev_tmpfs") && die "unable to mount tmpfs";
+ system("cp", "-r", "test/sys/", "$udev_tmpfs") && die "unable to copy test/sys";
+
system("rm", "-rf", "$udev_run");
}
@@ -1545,6 +1552,8 @@ print "$error errors occurred\n\n";
# cleanup
system("rm", "-rf", "$udev_dev");
system("rm", "-rf", "$udev_run");
+system("umount", "$udev_tmpfs");
+system("rm", "-rf", "$udev_tmpfs");
if ($error > 0) {
exit(1);