diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2020-10-25 01:57:29 +0300 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2020-10-25 01:57:29 +0300 |
commit | 1abf2fbac63c90c315cf6e87d6bce0c285bd4019 (patch) | |
tree | 0af5adb917b99d762f75c0407f0f018ecaf72a3e /test/unit_tests | |
parent | remove redundant namespace names (diff) | |
download | winapi-common-1abf2fbac63c90c315cf6e87d6bce0c285bd4019.tar.gz winapi-common-1abf2fbac63c90c315cf6e87d6bce0c285bd4019.zip |
Process: add termination methods
Diffstat (limited to '')
-rw-r--r-- | test/unit_tests/process.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
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 <boost/test/unit_test.hpp> +#include <chrono> +#include <thread> #include <utility> 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() |