chiark / gitweb /
test: fix some tests when running inside a container
[elogind.git] / test / udev-test.pl
index 14f11df8af94d53e1860ffb135cc2f52ac160a19..3e05b61777aaf50d92f9fe796cb8a2b85dc32f41 100755 (executable)
@@ -27,6 +27,7 @@ my $udev_dev            = "test/dev";
 my $udev_run            = "test/run";
 my $udev_rules_dir      = "$udev_run/udev/rules.d";
 my $udev_rules          = "$udev_rules_dir/udev-test.rules";
+my $EXIT_TEST_SKIP      = 77;
 
 my @tests = (
         {
@@ -1485,6 +1486,13 @@ if (!($<==0)) {
         exit;
 }
 
+# skip the test when running in a container
+system("systemd-detect-virt", "-c", "-q");
+if ($? >> 8 == 0) {
+    print "Running in a container, skipping the test.\n";
+    exit($EXIT_TEST_SKIP);
+}
+
 udev_setup();
 
 my $test_num = 1;