dcavalca / rpms / systemd

Forked from rpms/systemd 4 months ago
Clone
bd1529
From dc50d1cc5bf445f1a26dbc646ff52421563e677f Mon Sep 17 00:00:00 2001
bd1529
From: Dan Streetman <ddstreet@canonical.com>
bd1529
Date: Fri, 5 Jul 2019 11:24:55 -0400
bd1529
Subject: [PATCH] test/udev-test.pl: cleanup if skipping test
bd1529
bd1529
In Ubuntu CI, udev-test.pl is run from the debian/test/udev script,
bd1529
in a test dir created for it; but udev-test.pl setup mounts a
bd1529
dir, so if it doesn't cleanup/unmount before exiting, the test dir
bd1529
autopkgtest created for it can't be removed, and autopkgtest
bd1529
aborts the entire test suite, for example this output (from a
bd1529
test run inside an armhf container):
bd1529
bd1529
autopkgtest [12:45:36]: test udev: [-----------------------
bd1529
umount: test/tmpfs: no mount point specified.
bd1529
mknod: test/tmpfs/dev/null: Operation not permitted
bd1529
unable to create test/tmpfs/dev/null at ./udev-test.pl line 1611.
bd1529
Failed to set up the environment, skipping the test at ./udev-test.pl line 1731.
bd1529
autopkgtest [12:45:41]: test udev: -----------------------]
bd1529
autopkgtest [12:45:44]: test udev:  - - - - - - - - - - results - - - - - - - - - -
bd1529
udev                 FAIL non-zero exit status 77
bd1529
rm: cannot remove '/tmp/autopkgtest.ocPFA6/autopkgtest_tmp/test/tmpfs': Device or resource busy
bd1529
autopkgtest [12:46:22]: ERROR: "rm -rf /tmp/autopkgtest.ocPFA6/udev-artifacts /tmp/autopkgtest.ocPFA6/autopkgtest_tmp" failed with stderr "rm:
bd1529
bd1529
(cherry picked from commit abb9cc50afb3949c442849f43301fb33578f3888)
bd1529
bd1529
Related: #1642728
bd1529
---
bd1529
 test/udev-test.pl | 13 +++++++++----
bd1529
 1 file changed, 9 insertions(+), 4 deletions(-)
bd1529
bd1529
diff --git a/test/udev-test.pl b/test/udev-test.pl
bd1529
index 122359e377..2fea72875b 100755
bd1529
--- a/test/udev-test.pl
bd1529
+++ b/test/udev-test.pl
bd1529
@@ -1713,6 +1713,12 @@ sub run_test {
bd1529
 
bd1529
 }
bd1529
 
bd1529
+sub cleanup {
bd1529
+        system("rm", "-rf", "$udev_run");
bd1529
+        system("umount", "$udev_tmpfs");
bd1529
+        rmdir($udev_tmpfs);
bd1529
+}
bd1529
+
bd1529
 # only run if we have root permissions
bd1529
 # due to mknod restrictions
bd1529
 if (!($<==0)) {
bd1529
@@ -1729,11 +1735,13 @@ if ($? >> 8 == 0) {
bd1529
 
bd1529
 if (!udev_setup()) {
bd1529
         warn "Failed to set up the environment, skipping the test";
bd1529
+        cleanup();
bd1529
         exit($EXIT_TEST_SKIP);
bd1529
 }
bd1529
 
bd1529
 if (system($udev_bin, "check")) {
bd1529
         warn "$udev_bin failed to set up the environment, skipping the test";
bd1529
+        cleanup();
bd1529
         exit($EXIT_TEST_SKIP);
bd1529
 }
bd1529
 
bd1529
@@ -1776,10 +1784,7 @@ if ($list[0]) {
bd1529
 
bd1529
 print "$error errors occurred\n\n";
bd1529
 
bd1529
-# cleanup
bd1529
-system("rm", "-rf", "$udev_run");
bd1529
-system("umount", "$udev_tmpfs");
bd1529
-rmdir($udev_tmpfs);
bd1529
+cleanup();
bd1529
 
bd1529
 if ($error > 0) {
bd1529
         exit(1);