From ef2dc6d3f4fe10251e5ed67375723ec20b87e096 Mon Sep 17 00:00:00 2001 From: David Steele Date: Sun, 24 Jan 2021 15:48:32 -0500 Subject: [PATCH] Add chmod to make file removal after tests more reliable. MacOS does not allow files to be removed recursively unless the owner has write and execute permissions on all the directories. Some tests leave the permissions in a bad state so fix them up before trying to delete. --- test/lib/pgBackRestTest/Common/JobTest.pm | 2 +- test/src/common/harnessTest.c | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/test/lib/pgBackRestTest/Common/JobTest.pm b/test/lib/pgBackRestTest/Common/JobTest.pm index 7b5368dbc..921724866 100644 --- a/test/lib/pgBackRestTest/Common/JobTest.pm +++ b/test/lib/pgBackRestTest/Common/JobTest.pm @@ -701,7 +701,7 @@ sub end containerRemove("test-$self->{iVmIdx}"); } - executeTest("rm -rf ${strHostTestPath}"); + executeTest("chmod -R 700 ${strHostTestPath}/* 2>&1;rm -rf ${strHostTestPath}"); } $bDone = true; diff --git a/test/src/common/harnessTest.c b/test/src/common/harnessTest.c index a50878de5..789e13025 100644 --- a/test/src/common/harnessTest.c +++ b/test/src/common/harnessTest.c @@ -169,7 +169,9 @@ testBegin(const char *name) // Clear out the test directory so the next test starts clean char buffer[2048]; - snprintf(buffer, sizeof(buffer), "%srm -rf %s/" "*", testContainer() ? "sudo " : "", testPath()); + snprintf( + buffer, sizeof(buffer), "%schmod -R 700 %s/" "*;%srm -rf %s/" "*", testContainer() ? "sudo " : "", testPath(), + testContainer() ? "sudo " : "", testPath()); if (system(buffer) != 0) { @@ -179,7 +181,9 @@ testBegin(const char *name) } // Clear out the data directory so the next test starts clean - snprintf(buffer, sizeof(buffer), "%srm -rf %s/" "*", testContainer() ? "sudo " : "", testDataPath()); + snprintf( + buffer, sizeof(buffer), "%schmod -R 700 %s/" "*;%srm -rf %s/" "*", testContainer() ? "sudo " : "", + testDataPath(), testContainer() ? "sudo " : "", testDataPath()); if (system(buffer) != 0) {