From 78a54999cb010af3459e3138d4be9ff982201d67 Mon Sep 17 00:00:00 2001 From: Klemens Morgenstern Date: Thu, 22 Jun 2023 11:12:50 +0800 Subject: [PATCH] fixed popen test. --- test/v2/environment.cpp | 2 +- test/v2/process.cpp | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/test/v2/environment.cpp b/test/v2/environment.cpp index 379e1f709..60fcf793e 100644 --- a/test/v2/environment.cpp +++ b/test/v2/environment.cpp @@ -152,7 +152,7 @@ BOOST_AUTO_TEST_CASE(wenvironment) for (const auto ke : bpe::current()) { std::string key = std::get<0>(ke).string(); - printf("Getting env '%s'\n", key.c_str()); + printf("Getting env '%s' of value '%s' (from '%s')\n", key.c_str(), std::get<1>(key).c_str(), ke.c_str()); BOOST_CHECK_EQUAL(bpe::get(std::get<0>(ke)), std::get<1>(ke)); } diff --git a/test/v2/process.cpp b/test/v2/process.cpp index 063d8845d..2d11ca98a 100644 --- a/test/v2/process.cpp +++ b/test/v2/process.cpp @@ -371,24 +371,22 @@ BOOST_AUTO_TEST_CASE(popen) asio::io_context ctx; - asio::readable_pipe rp{ctx}; - // default CWD bpv::popen proc(/*bpv::default_process_launcher(), */ctx, pth, {"echo"}); BOOST_CHECK_EQUAL(asio::write(proc, asio::buffer("FOOBAR", 6)), 6); + proc.get_stdin().close(); std::string res; boost::system::error_code ec; std::size_t n = asio::read(proc, asio::dynamic_buffer(res), ec); while (ec == asio::error::interrupted) - n += asio::read(rp, asio::dynamic_buffer(res), ec); + n += asio::read(proc, asio::dynamic_buffer(res), ec); BOOST_CHECK_MESSAGE(ec == asio::error::eof - || ec == asio::error::broken_pipe - || ec == asio::error::bad_descriptor, + || ec == asio::error::broken_pipe, ec.message()); BOOST_REQUIRE_GE(n, 1u); BOOST_CHECK_EQUAL(res, "FOOBAR");