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 --- test/utils/test_env.hpp | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 test/utils/test_env.hpp (limited to 'test/utils/test_env.hpp') diff --git a/test/utils/test_env.hpp b/test/utils/test_env.hpp new file mode 100644 index 00000000..3bc49901 --- /dev/null +++ b/test/utils/test_env.hpp @@ -0,0 +1,44 @@ +#ifndef INCLUDED_SRC_TEST_UTILS_TEST_ENV_HPP +#define INCLUDED_SRC_TEST_UTILS_TEST_ENV_HPP + +#include +#include +#include +#include +#include + +#include "test/utils/logging/log_config.hpp" + +[[nodiscard]] static inline auto ReadPlatformPropertiesFromEnv() + -> std::map { + std::map properties{}; + auto* execution_props = std::getenv("REMOTE_EXECUTION_PROPERTIES"); + if (execution_props not_eq nullptr) { + std::istringstream pss(std::string{execution_props}); + std::string keyval_pair; + while (std::getline(pss, keyval_pair, ';')) { + std::istringstream kvss{keyval_pair}; + std::string key; + std::string val; + if (not std::getline(kvss, key, ':') or + not std::getline(kvss, val, ':')) { + Logger::Log(LogLevel::Error, + "parsing property '{}' failed.", + keyval_pair); + std::exit(EXIT_FAILURE); + } + properties.emplace(std::move(key), std::move(val)); + } + } + return properties; +} + +[[nodiscard]] static inline auto ReadRemoteAddressFromEnv() + -> std::optional { + auto* execution_address = std::getenv("REMOTE_EXECUTION_ADDRESS"); + return execution_address == nullptr + ? std::nullopt + : std::make_optional(std::string{execution_address}); +} + +#endif // INCLUDED_SRC_TEST_UTILS_TEST_ENV_HPP -- cgit v1.2.3