summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorOliver Reiche <oliver.reiche@huawei.com>2023-03-10 19:08:41 +0100
committerOliver Reiche <oliver.reiche@huawei.com>2023-03-13 17:28:59 +0100
commit9abfd2b14bbaa7cdd4711f56f70f941109e62e54 (patch)
treecafa3334274dd0150502e02bdf66b5d94968c98b /test
parent072265e646ca7624c712ddc9726facb9cdc49b33 (diff)
downloadjustbuild-9abfd2b14bbaa7cdd4711f56f70f941109e62e54.tar.gz
Remote Tests: Ensure writable build root exists
Diffstat (limited to 'test')
-rw-r--r--test/utils/TARGETS2
-rw-r--r--test/utils/remote_execution/main-remote-execution.cpp18
2 files changed, 20 insertions, 0 deletions
diff --git a/test/utils/TARGETS b/test/utils/TARGETS
index 7c57b8c1..92b086d2 100644
--- a/test/utils/TARGETS
+++ b/test/utils/TARGETS
@@ -53,6 +53,8 @@
, "deps":
[ ["@", "catch2", "", "catch2"]
, ["src/buildtool/execution_api/remote", "config"]
+ , ["src/buildtool/storage", "storage"]
+ , ["src/buildtool/file_system", "file_system_manager"]
, ["src/buildtool/compatibility", "compatibility"]
, "log_config"
, "test_env"
diff --git a/test/utils/remote_execution/main-remote-execution.cpp b/test/utils/remote_execution/main-remote-execution.cpp
index 188d3eea..703de7f4 100644
--- a/test/utils/remote_execution/main-remote-execution.cpp
+++ b/test/utils/remote_execution/main-remote-execution.cpp
@@ -22,6 +22,8 @@
#include "catch2/catch.hpp"
#include "src/buildtool/compatibility/compatibility.hpp"
#include "src/buildtool/execution_api/remote/config.hpp"
+#include "src/buildtool/file_system/file_system_manager.hpp"
+#include "src/buildtool/storage/storage.hpp"
#include "test/utils/logging/log_config.hpp"
#include "test/utils/test_env.hpp"
@@ -58,11 +60,27 @@ void wait_for_grpc_to_shutdown() {
return static_cast<bool>(RemoteExecutionConfig::RemoteAddress());
}
+[[nodiscard]] auto ConfigureBuildRoot() -> bool {
+ auto cache_dir = FileSystemManager::GetCurrentDirectory() / "cache";
+ if (not FileSystemManager::CreateDirectoryExclusive(cache_dir) or
+ not StorageConfig::SetBuildRoot(cache_dir)) {
+ return false;
+ }
+ // After the build root has been changed, the file roots of the
+ // static storage instances need to be updated.
+ Storage::Reinitialize();
+ return true;
+}
+
} // namespace
auto main(int argc, char* argv[]) -> int {
ConfigureLogging();
+ if (not ConfigureBuildRoot()) {
+ return EXIT_FAILURE;
+ }
+
if (not ConfigureRemoteExecution()) {
return EXIT_FAILURE;
}