From 1abf2fbac63c90c315cf6e87d6bce0c285bd4019 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Sun, 25 Oct 2020 01:57:29 +0300 Subject: Process: add termination methods --- test/unit_tests/process.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'test') diff --git a/test/unit_tests/process.cpp b/test/unit_tests/process.cpp index 715364f..cfc50f4 100644 --- a/test/unit_tests/process.cpp +++ b/test/unit_tests/process.cpp @@ -15,6 +15,8 @@ #include +#include +#include #include using namespace winapi; @@ -89,4 +91,19 @@ BOOST_FIXTURE_TEST_CASE(echo_runas, WithEchoExe) { BOOST_TEST(process.get_exit_code() == 0); } +BOOST_FIXTURE_TEST_CASE(echo_terminate, WithEchoExe) { + const CommandLine cmd_line{get_echo_exe()}; + const auto process = Process::create(cmd_line); + + // echo.exe is stuck trying to read stdin. + BOOST_TEST(process.is_running()); + std::this_thread::sleep_for(std::chrono::seconds{3}); + BOOST_TEST(process.is_running()); + + process.shut_down(123); + + BOOST_TEST(!process.is_running()); + BOOST_TEST(process.get_exit_code() == 123); +} + BOOST_AUTO_TEST_SUITE_END() -- cgit v1.2.3