2022-12-19 14:37:51 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <gtest/gtest.h>
|
|
|
|
|
|
|
|
#include <boost/asio.hpp>
|
|
|
|
#include <boost/process.hpp>
|
|
|
|
#include <boost/property_tree/ptree.hpp>
|
|
|
|
#include <filesystem>
|
|
|
|
#include <future>
|
|
|
|
#include <iostream>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
struct OidOpts {
|
2023-03-22 16:16:17 +00:00
|
|
|
boost::asio::io_context& ctx;
|
2022-12-19 14:37:51 +00:00
|
|
|
std::string targetArgs;
|
|
|
|
std::string script;
|
|
|
|
std::string scriptSource;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Proc {
|
2023-03-22 16:16:17 +00:00
|
|
|
boost::asio::io_context& ctx;
|
2022-12-19 14:37:51 +00:00
|
|
|
boost::process::child proc;
|
|
|
|
boost::process::child tee_stdout;
|
|
|
|
boost::process::child tee_stderr;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct OidProc {
|
|
|
|
Proc target;
|
|
|
|
Proc oid;
|
|
|
|
};
|
|
|
|
|
|
|
|
class IntegrationBase : public ::testing::Test {
|
|
|
|
protected:
|
|
|
|
virtual ~IntegrationBase() = default;
|
|
|
|
|
|
|
|
virtual std::string TmpDirStr() = 0;
|
|
|
|
|
|
|
|
void TearDown() override;
|
|
|
|
void SetUp() override;
|
2023-03-22 16:16:17 +00:00
|
|
|
int exit_code(Proc& proc);
|
2023-04-17 19:13:59 +01:00
|
|
|
std::filesystem::path createCustomConfig(const std::string& prefix,
|
|
|
|
const std::string& suffix);
|
2022-12-19 14:37:51 +00:00
|
|
|
|
|
|
|
std::filesystem::path workingDir;
|
|
|
|
|
|
|
|
std::string stdout_;
|
|
|
|
std::string stderr_;
|
|
|
|
};
|
|
|
|
|
|
|
|
class OidIntegration : public IntegrationBase {
|
|
|
|
protected:
|
|
|
|
std::string TmpDirStr() override;
|
|
|
|
|
2023-04-18 18:02:37 +01:00
|
|
|
OidProc runOidOnProcess(OidOpts opts,
|
|
|
|
std::vector<std::string> extra_args,
|
|
|
|
std::string configPrefix,
|
|
|
|
std::string configSuffix);
|
2022-12-19 14:37:51 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* compare_json
|
|
|
|
*
|
|
|
|
* Compares two JSON objects for equality if "expect_eq" is true, or for
|
|
|
|
* inequality if "expect_eq" is false.
|
|
|
|
*/
|
2023-03-22 16:16:17 +00:00
|
|
|
void compare_json(const boost::property_tree::ptree& expected_json,
|
|
|
|
const boost::property_tree::ptree& actual_json,
|
|
|
|
const std::string& full_key = "root",
|
2022-12-19 14:37:51 +00:00
|
|
|
bool expect_eq = true);
|
|
|
|
};
|
|
|
|
|
|
|
|
class OilIntegration : public IntegrationBase {
|
|
|
|
protected:
|
|
|
|
std::string TmpDirStr() override;
|
|
|
|
|
2023-04-18 18:02:37 +01:00
|
|
|
Proc runOilTarget(OidOpts opts,
|
|
|
|
std::string configPrefix,
|
2023-04-17 19:13:59 +01:00
|
|
|
std::string configSuffix);
|
2022-12-19 14:37:51 +00:00
|
|
|
};
|