From 619def44c1cca9f3cdf63544d5f24f2c7a7d9b77 Mon Sep 17 00:00:00 2001 From: Klaus Aehlig Date: Tue, 22 Feb 2022 17:03:21 +0100 Subject: Initial self-hosting commit This is the initial version of our tool that is able to build itself. In can be bootstrapped by ./bin/bootstrap.py Co-authored-by: Oliver Reiche Co-authored-by: Victor Moreno --- .../remote_execution/main-remote-execution.cpp | 50 ++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100755 test/utils/remote_execution/main-remote-execution.cpp (limited to 'test/utils/remote_execution/main-remote-execution.cpp') diff --git a/test/utils/remote_execution/main-remote-execution.cpp b/test/utils/remote_execution/main-remote-execution.cpp new file mode 100755 index 00000000..3f435dcc --- /dev/null +++ b/test/utils/remote_execution/main-remote-execution.cpp @@ -0,0 +1,50 @@ +#define CATCH_CONFIG_RUNNER +#include +#include +#include +#include +#include + +#include "catch2/catch.hpp" +#include "src/buildtool/execution_api/remote/config.hpp" +#include "test/utils/logging/log_config.hpp" +#include "test/utils/test_env.hpp" + +namespace { + +void wait_for_grpc_to_shutdown() { + // grpc_shutdown_blocking(); // not working + std::this_thread::sleep_for(std::chrono::seconds(1)); +} + +/// \brief Configure remote execution from test environment. In case the +/// environment variable is malformed, we write a message and stop execution. +/// \returns true If remote execution was successfully configured. +[[nodiscard]] auto ConfigureRemoteExecution() -> bool { + auto address = ReadRemoteAddressFromEnv(); + auto& config = RemoteExecutionConfig::Instance(); + if (address and not config.SetAddress(*address)) { + Logger::Log(LogLevel::Error, "parsing address '{}' failed.", *address); + std::exit(EXIT_FAILURE); + } + return config.IsValidAddress(); +} + +} // namespace + +auto main(int argc, char* argv[]) -> int { + ConfigureLogging(); + + // In case remote execution address is not valid, we skip tests. This is in + // order to avoid tests being dependent on the environment. + if (not ConfigureRemoteExecution()) { + return EXIT_SUCCESS; + } + + int result = Catch::Session().run(argc, argv); + + // valgrind fails if we terminate before grpc's async shutdown threads exit + wait_for_grpc_to_shutdown(); + + return result; +} -- cgit v1.2.3