mirror of
https://github.com/JakeHillion/object-introspection.git
synced 2024-11-09 21:24:14 +00:00
Integration tests: Pass config to OIL tests on the command line
Instead of using an environment variable, pass the path to the config file as a command line argument. This makes it possible to directly copy the command being run (as show with --verbose) and run it in a debugger outside of the test framework. Old verbose output: Running: /home/ajor/src/object-introspection3/build/test/integration/integration_test_target oil cycles_unique_ptr New verbose output: Running: /home/ajor/src/object-introspection3/build/test/integration/integration_test_target oil cycles_unique_ptr /home/ajor/src/object-introspection3/build/testing.oid.toml
This commit is contained in:
parent
56f7147d39
commit
512163f98e
@ -131,7 +131,7 @@ def add_test_setup(f, config):
|
||||
oil_func_body = (
|
||||
f"\n"
|
||||
f"ObjectIntrospection::options opts{{\n"
|
||||
f' .configFilePath = std::getenv("CONFIG_FILE_PATH"),\n'
|
||||
f" .configFilePath = configFile,\n"
|
||||
f" .debugLevel = 3,\n"
|
||||
f' .sourceFileDumpPath = "oil_jit_code.cpp",\n'
|
||||
f"}};"
|
||||
@ -160,21 +160,36 @@ def add_test_setup(f, config):
|
||||
def add_common_code(f):
|
||||
f.write(
|
||||
"""
|
||||
void usage(const std::string &argv0) {
|
||||
std::cerr << "usage: " << argv0 << " oid CASE ITERATIONS" << std::endl;
|
||||
std::cerr << " " << argv0 << " oil CASE CONFIG_FILE" << std::endl;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
if (argc < 3 || argc > 4) {
|
||||
std::cerr << "usage: " << argv[0] << " oid/oil CASE [ITER]" << std::endl;
|
||||
if (argc != 4) {
|
||||
usage(argv[0]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
std::string mode = argv[1];
|
||||
std::string test_case = argv[2];
|
||||
|
||||
int iterations = 1000;
|
||||
if (argc == 4) {
|
||||
int iterations = 1;
|
||||
|
||||
if (mode == "oid") {
|
||||
std::istringstream iss(argv[3]);
|
||||
iss >> iterations;
|
||||
if (iss.fail())
|
||||
iterations = 1000;
|
||||
if (iss.fail()) {
|
||||
usage(argv[0]);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else if (mode == "oil") {
|
||||
configFile = argv[3];
|
||||
}
|
||||
else {
|
||||
usage(argv[0]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
"""
|
||||
@ -224,6 +239,7 @@ def gen_target(output_target_name, test_configs):
|
||||
f"thrift/annotation/gen-cpp2/{config['suite']}_types.h"
|
||||
]
|
||||
add_headers(f, sorted(headers), thrift_headers)
|
||||
f.write("std::string configFile;")
|
||||
|
||||
for config in test_configs:
|
||||
add_test_setup(f, config)
|
||||
@ -334,7 +350,7 @@ def add_oil_integration_test(f, config, case_name, case):
|
||||
f" ba::io_context ctx;\n"
|
||||
f" auto target = runOilTarget({{\n"
|
||||
f" .ctx = ctx,\n"
|
||||
f' .targetArgs = "oil {case_str} 1",\n'
|
||||
f' .targetArgs = "oil {case_str}",\n'
|
||||
f" }}, std::move(configOptions));\n\n"
|
||||
f" ASSERT_EQ(exit_code(target), {exit_code});\n"
|
||||
f"\n"
|
||||
|
@ -172,7 +172,8 @@ OidProc OidIntegration::runOidOnProcess(OidOpts opts,
|
||||
std::vector<std::string> extra_args,
|
||||
std::string extra_config) {
|
||||
// Binary paths are populated by CMake
|
||||
std::string targetExe = std::string(TARGET_EXE_PATH) + " " + opts.targetArgs;
|
||||
std::string targetExe =
|
||||
std::string(TARGET_EXE_PATH) + " " + opts.targetArgs + " 1000";
|
||||
|
||||
/* Spawn the target process with all IOs redirected to /dev/null to not polute
|
||||
* the terminal */
|
||||
@ -256,8 +257,8 @@ OidProc OidIntegration::runOidOnProcess(OidOpts opts,
|
||||
// clang-format off
|
||||
bp::child oidProcess(
|
||||
oidExe,
|
||||
bp::env["OID_METRICS_TRACE"] = "time",
|
||||
bp::args(oid_args),
|
||||
bp::env["OID_METRICS_TRACE"] = "time",
|
||||
bp::std_in < bp::null,
|
||||
bp::std_out > std_out_pipe,
|
||||
bp::std_err > std_err_pipe,
|
||||
@ -337,7 +338,10 @@ std::string OilIntegration::TmpDirStr() {
|
||||
}
|
||||
|
||||
Proc OilIntegration::runOilTarget(OidOpts opts, std::string extra_config) {
|
||||
std::string targetExe = std::string(TARGET_EXE_PATH) + " " + opts.targetArgs;
|
||||
fs::path thisConfig = createCustomConfig(extra_config);
|
||||
|
||||
std::string targetExe = std::string(TARGET_EXE_PATH) + " " + opts.targetArgs +
|
||||
" " + thisConfig.string();
|
||||
|
||||
if (verbose) {
|
||||
std::cerr << "Running: " << targetExe << std::endl;
|
||||
@ -375,8 +379,6 @@ Proc OilIntegration::runOilTarget(OidOpts opts, std::string extra_config) {
|
||||
// clang-format on
|
||||
}
|
||||
|
||||
fs::path thisConfig = createCustomConfig(extra_config);
|
||||
|
||||
/* Spawn target with tracing on and IOs redirected in custom pipes to be read
|
||||
* later */
|
||||
// clang-format off
|
||||
@ -385,7 +387,6 @@ Proc OilIntegration::runOilTarget(OidOpts opts, std::string extra_config) {
|
||||
bp::std_in < bp::null,
|
||||
bp::std_out > std_out_pipe,
|
||||
bp::std_err > std_err_pipe,
|
||||
bp::env["CONFIG_FILE_PATH"] = thisConfig.string(),
|
||||
opts.ctx);
|
||||
// clang-format on
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user