Parse parameter list
This commit is contained in:
@@ -43,17 +43,33 @@ namespace elna
|
||||
return in_build_directory() / path;
|
||||
}
|
||||
|
||||
test_result run_for_output(boost::asio::io_context& context, const std::filesystem::path& binary,
|
||||
std::initializer_list<boost::string_view> arguments)
|
||||
boost::process::v2::process_stdio get_output_streams(const std::uint8_t stream_number,
|
||||
boost::asio::readable_pipe& read_pipe)
|
||||
{
|
||||
if (stream_number == 1)
|
||||
{
|
||||
return boost::process::v2::process_stdio{ nullptr, read_pipe };
|
||||
}
|
||||
if (stream_number == 2)
|
||||
{
|
||||
return boost::process::v2::process_stdio{ nullptr, {}, read_pipe };
|
||||
}
|
||||
return boost::process::v2::process_stdio{ nullptr, read_pipe, read_pipe };
|
||||
}
|
||||
|
||||
test_result run_for_output(boost::asio::io_context& context, const std::uint8_t stream_number,
|
||||
const std::filesystem::path& binary, std::initializer_list<boost::string_view> arguments)
|
||||
{
|
||||
boost::asio::readable_pipe read_pipe{ context };
|
||||
test_result result{};
|
||||
std::string output;
|
||||
boost::asio::dynamic_string_buffer buffer = boost::asio::dynamic_buffer(output);
|
||||
boost::system::error_code ec;
|
||||
|
||||
boost::process::v2::process_stdio process_stdio;
|
||||
boost::process::v2::process elna_child(context,
|
||||
binary, arguments,
|
||||
boost::process::v2::process_stdio{ nullptr, read_pipe, read_pipe });
|
||||
get_output_streams(stream_number, read_pipe));
|
||||
do
|
||||
{
|
||||
std::size_t transferred = read_pipe.read_some(buffer.prepare(512), ec);
|
||||
@@ -84,7 +100,7 @@ namespace elna
|
||||
std::filesystem::remove(test_binary);
|
||||
std::filesystem::remove(test_object);
|
||||
|
||||
test_result result = run_for_output(context, "./build/bin/elna",
|
||||
test_result result = run_for_output(context, 2, "./build/bin/elna",
|
||||
{ "-o", test_object.string(), test_entry.path().string() });
|
||||
|
||||
if (result.code != 0)
|
||||
@@ -157,7 +173,7 @@ namespace elna
|
||||
std::filesystem::path test_binary = in_build_directory(test_filename);
|
||||
test_binary.replace_extension();
|
||||
|
||||
return run_for_output(context,
|
||||
return run_for_output(context, 1,
|
||||
boost::process::search_path("qemu-riscv32"),
|
||||
{ test_binary.string() });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user