Skip to content

Commit

Permalink
fixed windows interrupt & request_exit test.
Browse files Browse the repository at this point in the history
  • Loading branch information
klemens-morgenstern committed Oct 2, 2023
1 parent 1bf2a5a commit 4e69906
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 27 deletions.
9 changes: 6 additions & 3 deletions test/v2/process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ BOOST_AUTO_TEST_CASE(request_exit)
bpv::process proc(ctx, pth, {"sigterm"}
#if defined(BOOST_PROCESS_V2_WINDOWS)
, bpv::windows::show_window_minimized_not_active
, bpv::windows::create_new_console
#endif
);
BOOST_CHECK(proc.running());
Expand Down Expand Up @@ -570,9 +571,10 @@ BOOST_AUTO_TEST_CASE(async_interrupt)
using boost::unit_test::framework::master_test_suite;
const auto pth = bpv::filesystem::absolute(master_test_suite().argv[1]);


bpv::process proc(ctx, pth, {"sigint"}
#if defined(BOOST_PROCESS_V2_WINDOWS)
, bpv::windows::create_new_process_group
, bpv::windows::create_new_process_group
#endif
);

Expand Down Expand Up @@ -600,8 +602,9 @@ BOOST_AUTO_TEST_CASE(async_request_exit)
const auto pth = bpv::filesystem::absolute(master_test_suite().argv[1]);

bpv::process proc(ctx, pth, {"sigterm"}
#if defined(ASIO_WINDOWS)
, asio::windows::show_window_minimized_not_active
#if defined(BOOST_PROCESS_V2_WINDOWS)
, bpv::windows::show_window_minimized_not_active
, bpv::windows::create_new_console
#endif
);

Expand Down
19 changes: 8 additions & 11 deletions test/v2/target.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,6 @@ int main(int argc, char * argv[])
GetStartupInfo(&si);
return static_cast<int>(si.wShowWindow);
}
else if (mode == "creation-flags")
{
STARTUPINFO si;
GetStartupInfo(&si);
return static_cast<int>(si.dwFlags);
}
#endif
else if (mode == "sigterm")
{
Expand All @@ -86,18 +80,20 @@ int main(int argc, char * argv[])
static boost::asio::steady_timer * tim_p = &tim;

#if defined(BOOST_PROCESS_V2_WINDOWS)
BOOST_ASSERT(SetConsoleCtrlHandler(
SetConsoleCtrlHandler(
[](DWORD kind)
{
if (kind == CTRL_CLOSE_EVENT)
{
// windows doesn't like us doing antyhing else
::exit(0);
if (tim_p != nullptr)
tim_p->cancel();
return TRUE;
}
else
return FALSE;
}, TRUE) != 0);
}, TRUE);
#else
signal(SIGTERM, [](int) { if (tim_p != nullptr) tim_p->cancel();});
#endif
Expand All @@ -115,8 +111,8 @@ int main(int argc, char * argv[])
static boost::asio::steady_timer * tim_p = &tim;

#if defined(BOOST_PROCESS_V2_WINDOWS)
BOOST_ASSERT(
SetConsoleCtrlHandler(
SetConsoleCtrlHandler(NULL, FALSE);
auto res = SetConsoleCtrlHandler(
[](DWORD kind)
{
if (kind == CTRL_C_EVENT)
Expand All @@ -127,7 +123,8 @@ int main(int argc, char * argv[])
}
else
return FALSE;
}, TRUE) != 0);
}, TRUE);
BOOST_ASSERT(res != FALSE);
#else
signal(SIGINT, [](int) { if (tim_p != nullptr) tim_p->cancel();});
#endif
Expand Down
13 changes: 0 additions & 13 deletions test/v2/windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,6 @@ BOOST_AUTO_TEST_CASE(show_window)

}

BOOST_AUTO_TEST_CASE(creation_flags)
{
using boost::unit_test::framework::master_test_suite;
const auto pth = master_test_suite().argv[1];
asio::io_context ctx;
bpv::process proc{ctx, pth, {"creation-flags"}};

BOOST_CHECK_EQUAL(proc.wait() & ~EXTENDED_STARTUPINFO_PRESENT, 0);

proc = bpv::process{ctx, master_test_suite().argv[1], {"creation-flags"}, bpv::windows::process_creation_flags<STARTF_TITLEISAPPID>()};
BOOST_CHECK(proc.running());
BOOST_CHECK_EQUAL(proc.wait() & ~EXTENDED_STARTUPINFO_PRESENT, STARTF_TITLEISAPPID);
}

BOOST_AUTO_TEST_CASE(as_user_launcher)
{
Expand Down

0 comments on commit 4e69906

Please sign in to comment.