use std::sync::{Arc, Mutex};
use std::time::Duration;
use crate::error::Error;
use crate::test_child::{self, Console};
use crate::tokio::stop::{self, StopFuture};
use crate::tokio::test_runtime::{assert_current_thread, never_blocking};
use crate::StopTarget;
type Seen = Arc<Mutex<Vec<(u32, bool)>>>;
fn refused() -> Error {
Error::Unsupported {
op: "the test action".into(),
platform: "test",
detail: "refused by the test action".into(),
source: None,
}
}
fn recording(seen: &Seen) -> impl for<'t, 'c> Fn(&'t StopTarget<'c>) -> StopFuture<'t> + Send + Sync + 'static {
let seen = Arc::clone(seen);
move |target| {
seen.lock().unwrap().push((target.pid(), target.covers_tree()));
Box::pin(async { Ok(()) })
}
}
async fn blocker_stopping_by(
action: impl for<'t, 'c> Fn(&'t StopTarget<'c>) -> StopFuture<'t> + Send + Sync + 'static,
contain: bool,
) -> (crate::tokio::Child, crate::tokio::ChildStdin) {
let mut cmd = test_child::tokio_command(Console::Hidden);
cmd.args(test_child::BLOCKER_ARGV.iter().copied());
cmd.stdin(crate::Stdio::pipe()).expect("set stdin pipe");
cmd.stdout(crate::Stdio::null()).expect("set stdout null");
if contain {
#[cfg(unix)]
test_child::contain_without_cgroup_async(&mut cmd);
#[cfg(windows)]
cmd.contain();
}
cmd.graceful_stop(action);
let mut child = cmd.spawn().await.expect("spawn");
let stdin = child.stdin().expect("piped stdin");
(child, stdin)
}
async fn prepared_send(target: &StopTarget<'_>) -> Result<(), Error> {
#[cfg(unix)]
return stop::send_signal(target, crate::Signal::Usr1).await;
#[cfg(windows)]
return stop::send_ctrl_break_to_group(target).await;
}
async fn assert_nothing_was_sent(child: &mut crate::tokio::Child, stdin: crate::tokio::ChildStdin) {
#[cfg(windows)]
crate::test_child::ctrl_break::assert_no_break_sent();
child.kill().expect("kill");
drop(stdin);
test_child::assert_killed("the blocker", child.wait().await.expect("reap"));
}
#[skuld::test]
async fn async_terminate_runs_the_callers_action_on_a_root_target() {
assert_current_thread();
let seen = Seen::default();
let (mut child, stdin) = blocker_stopping_by(recording(&seen), false).await;
never_blocking(child.terminate())
.await
.expect("the action's Ok is the answer");
assert_eq!(*seen.lock().unwrap(), [(child.pid(), false)]);
assert_nothing_was_sent(&mut child, stdin).await;
}
#[skuld::test]
async fn async_terminate_tree_runs_the_action_on_a_tree_target() {
assert_current_thread();
let seen = Seen::default();
let (mut child, stdin) = blocker_stopping_by(recording(&seen), true).await;
never_blocking(child.terminate_tree())
.await
.expect("the action's Ok is the answer");
assert_eq!(*seen.lock().unwrap(), [(child.pid(), true)]);
assert_nothing_was_sent(&mut child, stdin).await;
}
#[skuld::test]
async fn async_an_actions_error_is_terminates_error() {
assert_current_thread();
let (mut child, stdin) = blocker_stopping_by(|_| Box::pin(async { Err(refused()) }), false).await;
let err = never_blocking(child.terminate()).await.expect_err("the action refused");
assert!(
matches!(&err, Error::Unsupported { detail, .. } if detail == "refused by the test action"),
"{err:?}"
);
let err = never_blocking(child.graceful_shutdown(Duration::ZERO))
.await
.expect_err("the shutdown ends at the action's error");
assert!(
matches!(&err, Error::Unsupported { detail, .. } if detail == "refused by the test action"),
"{err:?}"
);
assert_eq!(
child.is_alive(),
crate::identity::Liveness::Alive,
"nothing was killed, so the child runs"
);
assert_nothing_was_sent(&mut child, stdin).await;
}
#[cfg(unix)]
fn signalling_then_ending_the_input(
held: &test_child::HeldStdin<crate::tokio::ChildStdin>,
) -> impl for<'t, 'c> Fn(&'t StopTarget<'c>) -> StopFuture<'t> + Send + Sync + 'static {
let held = held.clone();
move |target| {
let held = held.clone();
Box::pin(async move {
stop::send_signal(target, crate::Signal::Usr1).await?;
held.end();
Ok(())
})
}
}
#[cfg(unix)]
#[skuld::test]
async fn async_a_chosen_signal_reaches_every_member_of_the_tree() {
use ::tokio::io::AsyncReadExt as _;
assert_current_thread();
for shutdown in [false, true] {
let held = test_child::HeldStdin::default();
let (mut child, stdin, mut stdout) =
test_child::ready_tree_async(test_child::signal_reporting_tree_argv(), |cmd| {
test_child::contain_without_cgroup_async(cmd);
cmd.graceful_stop(signalling_then_ending_the_input(&held));
})
.await;
held.hold(stdin);
if shutdown {
never_blocking(child.graceful_shutdown_tree(Duration::MAX))
.await
.expect("the chosen signal ended the tree");
} else {
never_blocking(child.terminate_tree())
.await
.expect("the chosen signal was sent to the tree");
}
let mut said = String::new();
stdout
.read_to_string(&mut said)
.await
.expect("the tree's stdout, to its end");
let mut reports: Vec<&str> = said.lines().collect();
reports.sort_unstable();
if shutdown {
assert!(reports.contains(&"root SIGUSR1"), "shutdown: {reports:?}");
assert!(
reports.iter().all(|line| line.ends_with("SIGUSR1")),
"shutdown: only the chosen signal was sent: {reports:?}"
);
} else {
assert_eq!(
reports,
["leaf SIGUSR1", "root SIGUSR1"],
"both members got the chosen signal"
);
child.wait().await.expect("the root reported the signal and exited");
}
}
}
#[cfg(unix)]
struct Reports {
stdout: ::tokio::io::BufReader<crate::tokio::ChildStdout>,
lines: Vec<String>,
}
#[cfg(unix)]
impl Reports {
fn new(stdout: crate::tokio::ChildStdout) -> Reports {
Reports {
stdout: ::tokio::io::BufReader::new(stdout),
lines: Vec::new(),
}
}
async fn until(&mut self, wanted: &[&str]) {
use ::tokio::io::AsyncBufReadExt as _;
let mut seen: Vec<String> = Vec::new();
while !wanted.iter().all(|line| seen.iter().any(|got| got == line)) {
let mut line = String::new();
let read = self.stdout.read_line(&mut line).await.expect("a report line");
assert_ne!(read, 0, "the tree's stdout ended before {wanted:?}; read {seen:?}");
let line = line.trim_end().to_owned();
assert!(wanted.contains(&line.as_str()), "{line:?} is no report of {wanted:?}");
self.lines.push(line.clone());
seen.push(line);
}
}
async fn read_rest(&mut self) {
use ::tokio::io::AsyncBufReadExt as _;
let mut lines = (&mut self.stdout).lines();
while let Some(line) = lines.next_line().await.expect("a report line") {
self.lines.push(line);
}
}
fn of(&self, member: &str) -> Vec<&str> {
self.lines
.iter()
.map(String::as_str)
.filter(|line| line.starts_with(member))
.collect()
}
}
#[cfg(unix)]
#[skuld::test]
async fn async_an_action_may_compose_sends_with_a_wait() {
assert_current_thread();
for tree in [false, true] {
let waited = Arc::new(Mutex::new(Vec::new()));
let reports = Arc::new(::tokio::sync::Mutex::new(None::<Reports>));
let held = test_child::HeldStdin::default();
let first: &'static [&'static str] = if tree {
&["root SIGUSR1", "leaf SIGUSR1"]
} else {
&["root SIGUSR1"]
};
let (mut child, stdin, stdout) =
test_child::ready_tree_async(test_child::signal_then_term_tree_argv(), |cmd| {
if tree {
test_child::contain_without_cgroup_async(cmd);
}
let (waited, reports, held) = (Arc::clone(&waited), Arc::clone(&reports), held.clone());
cmd.graceful_stop(move |target| {
let (waited, reports, held) = (Arc::clone(&waited), Arc::clone(&reports), held.clone());
Box::pin(async move {
let sent = crate::send_log::Capture::start();
stop::send_signal(target, crate::Signal::Usr1).await?;
sent.require_a_send(libc::SIGUSR1)?;
let running = stop::wait_exit(target, Duration::ZERO).await?;
waited.lock().unwrap().push(running);
reports.lock().await.as_mut().expect("the reports").until(first).await;
stop::send_signal(target, crate::Signal::Term).await?;
held.end();
let exited = stop::wait_exit(target, Duration::MAX).await?;
waited.lock().unwrap().push(exited);
Ok(())
})
});
})
.await;
held.hold(stdin);
*reports.lock().await = Some(Reports::new(stdout));
if tree {
never_blocking(child.terminate_tree()).await.expect("the composed stop");
} else {
never_blocking(child.terminate()).await.expect("the composed stop");
}
assert_eq!(*waited.lock().unwrap(), [false, true], "tree: {tree}");
let mut reports = reports.lock().await.take().expect("the reports");
reports.read_rest().await;
let repeat = child.containment() == crate::Containment::FdMarker;
test_child::assert_reported_usr1_then_term("root", &reports.of("root"), repeat);
if tree {
test_child::assert_reported_usr1_then_term("leaf", &reports.of("leaf"), repeat);
}
child.wait().await.expect("the root had exited, and is reaped once");
}
}
#[skuld::test]
async fn async_graceful_shutdown_tree_goes_on_after_a_callers_own_action() {
assert_current_thread();
let (mut child, stdin) = blocker_stopping_by(|_| Box::pin(async { Ok(()) }), true).await;
let status = never_blocking(child.graceful_shutdown_tree(Duration::ZERO))
.await
.expect("the sweep ended the tree");
#[cfg(windows)]
crate::test_child::ctrl_break::assert_no_break_sent();
test_child::assert_killed("the blocker, which only the sweep ended", status);
drop(stdin);
}
#[cfg(unix)]
#[skuld::test]
async fn async_graceful_shutdown_tree_keeps_an_error_after_a_send_that_went_out() {
use ::tokio::io::AsyncReadExt as _;
assert_current_thread();
crate::log_capture::install();
let mark = crate::log_capture::mark();
let held = test_child::HeldStdin::default();
let (mut child, stdin, mut stdout) =
test_child::ready_tree_async(test_child::signal_reporting_tree_argv(), |cmd| {
test_child::contain_without_cgroup_async(cmd);
let held = held.clone();
cmd.graceful_stop(move |target| {
let held = held.clone();
Box::pin(async move {
prepared_send(target).await?;
held.end();
Err(refused())
})
});
})
.await;
held.hold(stdin);
let _armed = crate::child::graceful::fault::ArmedKillTreeError::arm();
let err = never_blocking(child.graceful_shutdown_tree(Duration::MAX))
.await
.expect_err("the sweep failed");
assert!(
matches!(&err, Error::Io(e) if e.to_string().contains("forced kill_tree failure")),
"{err:?}"
);
let logged =
crate::log_capture::records_since_on_current_thread(mark, &format!("graceful_shutdown_tree({})", child.pid()));
assert!(
matches!(&logged[..], [(log::Level::Warn, refusal)] if refusal.contains("refused by the test action")),
"the action's error is the call's cooperative error: {logged:?}"
);
let mut said = String::new();
stdout
.read_to_string(&mut said)
.await
.expect("the tree's stdout, to its end");
let mut reports: Vec<&str> = said.lines().collect();
reports.sort_unstable();
assert_eq!(
reports,
["leaf SIGUSR1", "root SIGUSR1"],
"the send that went out reached the tree"
);
}
#[cfg(windows)]
#[skuld::test]
async fn async_graceful_shutdown_tree_keeps_an_error_after_a_send_that_went_out() {
use crate::test_child::ctrl_break::{self, Handler, STATUS_CONTROL_C_EXIT};
assert_current_thread();
crate::log_capture::install();
let mark = crate::log_capture::mark();
let (mut child, sock, _) =
ctrl_break::spawn_member_async(Handler::Default, None, Some(crate::ContainMode::Strongest), |cmd| {
cmd.graceful_stop(|target| {
Box::pin(async move {
prepared_send(target).await?;
Err(refused())
})
});
})
.await;
ctrl_break::assert_in_our_console(child.pid(), "the root");
let pid = child.pid();
let check = crate::graceful_hooks::at_checked(crate::graceful_hooks::HookPoint::AfterTerminate, move || {
ctrl_break::assert_break_sent_to(pid)
});
let status = never_blocking(child.graceful_shutdown_tree(Duration::from_secs(30)))
.await
.expect("the tree drained, which supersedes the action's error");
check.assert_fired();
assert_eq!(
status.code(),
Some(STATUS_CONTROL_C_EXIT),
"the break reached the root: {status:?}"
);
let logged =
crate::log_capture::records_since_on_current_thread(mark, &format!("graceful_shutdown_tree({})", child.pid()));
assert!(
logged.iter().any(|(level, text)| *level == log::Level::Debug
&& text.contains("superseded")
&& text.contains("refused by the test action")),
"the action's error was kept through the grace and then discarded: {logged:?}"
);
drop(sock);
}
#[skuld::test]
async fn async_graceful_shutdown_tree_ends_on_an_error_with_nothing_sent() {
assert_current_thread();
let (mut child, stdin) = blocker_stopping_by(|_| Box::pin(async { Err(refused()) }), true).await;
let err = never_blocking(child.graceful_shutdown_tree(Duration::ZERO))
.await
.expect_err("the action refused");
assert!(
matches!(&err, Error::Unsupported { detail, .. } if detail == "refused by the test action"),
"{err:?}"
);
assert_eq!(
child.is_alive(),
crate::identity::Liveness::Alive,
"no sweep ran, so the tree runs"
);
assert_nothing_was_sent(&mut child, stdin).await;
}
#[cfg(target_os = "linux")]
#[skuld::test]
async fn async_graceful_shutdown_tree_sends_the_actions_signal_once_to_a_root_reachable_only_through_its_pidfd() {
use crate::graceful_hooks::{at, HookPoint};
use crate::signal::Sig::Graceful;
use crate::signal::Signal::Usr1;
use std::os::unix::process::ExitStatusExt as _;
assert_current_thread();
let _old_kernel = crate::containment::unix::fault::refuse_pidfd_group_flag();
crate::log_capture::install();
let mut cmd = test_child::tokio_command(Console::Hidden);
cmd.args(["cat"]);
cmd.contain_with(crate::ContainMode::Session);
cmd.stdin(crate::Stdio::pipe_in()).expect("stdin pipe");
cmd.graceful_stop(|target| Box::pin(stop::send_signal(target, crate::Signal::Usr1)));
let mut child = cmd.spawn().await.expect("spawn");
let stdin = child.stdin().expect("stdin pipe");
let pid = child.pid();
let sends = std::rc::Rc::new(crate::send_log::Capture::start());
let fake = child
.inner
.proc
.script_over(|f| f.peeks([Err(std::io::Error::other("forced peek failure"))]));
let exited_first = at(HookPoint::AfterTerminate, {
let sends = std::rc::Rc::clone(&sends);
move || {
assert_eq!(
sends.entries(),
[(pid, Graceful(Usr1), crate::send_log::Via::Pidfd)],
"the action's signal went out, once, before the grace"
);
drop(stdin);
crate::test_child::wait_until_zombie(pid);
}
});
let err = never_blocking(child.graceful_shutdown_tree(Duration::ZERO))
.await
.expect_err("a group whose root nothing can answer for is not assessable");
drop(exited_first);
fake.assert_peeks_exhausted();
assert!(matches!(err, Error::Unassessable { .. }), "{err:?}");
assert_eq!(
sends.entries(),
[(pid, Graceful(Usr1), crate::send_log::Via::Pidfd)],
"only the action's signal, through the pidfd"
);
let status = child.wait().await.expect("reap the root");
assert_eq!(
status.signal(),
Some(libc::SIGUSR1),
"the action's signal ended the root"
);
}
#[skuld::test]
async fn async_wait_exit_answers_false_when_the_grace_runs_out_with_the_root_running() {
assert_current_thread();
let (member, writer, _) = test_child::over_fake::live_member();
let mut child = crate::tokio::Child { inner: member };
let exited = never_blocking(stop::wait_exit(&StopTarget::from(&child), Duration::from_millis(10))).await;
drop(writer);
assert!(
!exited.expect("a look at the root"),
"the grace ran out with the root running"
);
child.wait().await.expect("the root ended once its input did");
}
#[cfg(windows)]
#[skuld::test]
fn async_wait_exit_on_windows_needs_neither_the_io_nor_the_time_driver() {
let runtime = ::tokio::runtime::Builder::new_current_thread()
.build()
.expect("a runtime with no driver");
runtime.block_on(async {
let (member, writer, _) = test_child::over_fake::live_member();
let mut child = crate::tokio::Child { inner: member };
let exited = never_blocking(stop::wait_exit(&StopTarget::from(&child), Duration::from_millis(10))).await;
assert!(
!exited.expect("a look at the root"),
"the grace ran out with the root running"
);
drop(writer);
let exited = never_blocking(stop::wait_exit(&StopTarget::from(&child), Duration::MAX)).await;
assert!(exited.expect("the wait for the root"), "the root exited");
child.wait().await.expect("the exited root is reaped");
});
}
#[cfg(windows)]
use crate::stop::proxy::proxy_tests::held_proxy::Held;
#[cfg(windows)]
async fn member_stopping_through(held: &Held) -> (crate::tokio::Child, std::net::TcpStream) {
use crate::test_child::ctrl_break::{spawn_member_async, Handler};
let (child, sock, _) = spawn_member_async(Handler::Ignore, None, Some(crate::ContainMode::Strongest), |cmd| {
cmd.no_window();
cmd.ctrl_proxy(held.fixture.setting());
cmd.graceful_stop(|target| Box::pin(stop::send_console_event_via_proxy(target, crate::CtrlEvent::CtrlBreak)));
})
.await;
(child, sock)
}
#[cfg(windows)]
#[skuld::test]
async fn the_wait_for_the_proxy_blocks_no_runtime_thread() {
use std::cell::Cell;
use std::rc::Rc;
use crate::stop::proxy::protocol::{CtrlEvent, ProxyAnswer};
use crate::test_child::ctrl_break::{assert_proxy_answered, kill_release_reap_async};
assert_current_thread();
let mut held = Held::new();
let (mut child, sock) = member_stopping_through(&held).await;
let blocked = Rc::new(Cell::new(false));
let releaser = held.releaser();
let _release_at_a_block = crate::wait::block_probe::on_blocking({
let blocked = blocked.clone();
move || {
blocked.set(true);
_ = releaser.send(());
}
});
let (stopped, ()) = ::tokio::join!(child.terminate(), async {
held.started().await;
held.release();
});
assert!(!blocked.get(), "the call blocked a runtime thread");
stopped.expect("the proxy answered Sent");
assert_proxy_answered(child.pid(), CtrlEvent::CtrlBreak, ProxyAnswer::Sent);
kill_release_reap_async(&mut child, sock, false).await;
}
#[cfg(windows)]
#[skuld::test]
async fn a_dropped_terminate_has_ended_its_proxy() {
use std::future::Future as _;
use std::task::Context;
use crate::test_child::ctrl_break::{assert_no_break_sent, kill_release_reap_async};
assert_current_thread();
let mut held = Held::new();
let (mut child, sock) = member_stopping_through(&held).await;
{
let (waker, wakes) = crate::tokio::test_runtime::counting_waker();
let mut cx = Context::from_waker(&waker);
let mut terminate = Box::pin(child.terminate());
assert!(
terminate.as_mut().poll(&mut cx).is_pending(),
"the proxy is not started yet"
);
wakes.recv().expect("the start of the proxy woke the call");
assert!(
terminate.as_mut().poll(&mut cx).is_pending(),
"the proxy has not answered, so the call waits for it"
);
let proxy = held.started().await;
let id = crate::identity::ProcessId::of(proxy)
.found()
.expect("the proxy runs, and has an identity");
assert!(
!crate::test_child::exited_through_open(id, Some(Duration::ZERO)).expect("a look at the proxy"),
"the proxy runs while the call waits for it"
);
drop(terminate);
assert!(
crate::test_child::exited_through_open(id, Some(Duration::ZERO)).expect("a look at the proxy"),
"the drop of the call ended the proxy"
);
}
assert_no_break_sent();
held.release();
kill_release_reap_async(&mut child, sock, false).await;
}
#[cfg(windows)]
#[skuld::test]
async fn async_a_proxy_that_has_not_answered_is_warned_of_once_and_waited_for() {
use crate::stop::proxy::protocol::{CtrlEvent, ProxyAnswer};
use crate::test_child::ctrl_break::{assert_proxy_answered, kill_release_reap_async};
crate::log_capture::install();
assert_current_thread();
let mut held = Held::new();
let (mut child, sock) = member_stopping_through(&held).await;
let marker = format!("for child {} has not answered", child.pid());
let mark = crate::log_capture::mark();
let releaser = held.releaser();
let release_at_the_warning = std::thread::spawn({
let marker = marker.clone();
move || {
crate::log_capture::wait_for_since(mark, &marker);
_ = releaser.send(());
}
});
never_blocking(child.terminate())
.await
.expect("the proxy answered Sent, once told");
release_at_the_warning.join().expect("the thread saw the warning");
assert_proxy_answered(child.pid(), CtrlEvent::CtrlBreak, ProxyAnswer::Sent);
let proxy = held.started().await;
let warned = crate::log_capture::records_since(mark, &marker);
assert_eq!(
warned.len(),
1,
"one warning for the proxy that had not answered: {warned:?}"
);
assert!(
warned[0].contains(&format!("(pid {proxy})")),
"the warning names the proxy: {warned:?}"
);
kill_release_reap_async(&mut child, sock, false).await;
}
#[cfg(windows)]
#[skuld::test]
async fn async_wait_saying_calls_late_once_for_a_running_root_only() {
use std::cell::Cell;
assert_current_thread();
let (member, writer, _) = crate::test_child::over_fake::live_member();
let mut child = crate::tokio::Child { inner: member };
let writer = Cell::new(Some(writer));
let late = Cell::new(0u32);
let late_at_release = Cell::new(None);
let (waited, ()) = ::tokio::join!(child.wait_saying(Duration::ZERO, |_| late.set(late.get() + 1)), async {
late_at_release.set(Some(late.get()));
drop(writer.take());
});
waited.expect("the root ended once its input did");
assert_eq!(
late_at_release.get(),
Some(1),
"late was called before the wait went on"
);
assert_eq!(late.get(), 1, "late was called once");
let (member, writer, _) = crate::test_child::over_fake::live_member();
let mut child = crate::tokio::Child { inner: member };
drop(writer);
assert!(
stop::wait_exit(&StopTarget::from(&child), Duration::MAX)
.await
.expect("the root's exit"),
"the root exited"
);
child
.wait_saying(Duration::ZERO, |_| panic!("late was called for a root that had exited"))
.await
.expect("the exited root is reaped");
}
#[cfg(windows)]
#[skuld::test]
async fn async_a_child_that_has_exited_is_answered_before_the_proxy_is_started() {
use crate::stop::proxy::protocol::ProxyAnswer;
use crate::stop::proxy::proxy_tests::Fixture;
use crate::test_child::ctrl_break::{assert_no_break_sent, spawn_member_async, Handler};
assert_current_thread();
for tree in [false, true] {
let fixture = Fixture::answering(ProxyAnswer::Sent.code());
let (mut child, sock, _) =
spawn_member_async(Handler::Ignore, None, Some(crate::ContainMode::Strongest), |cmd| {
cmd.no_window();
cmd.ctrl_proxy(fixture.setting());
})
.await;
child.kill().expect("kill the member");
child.wait().await.expect("see its exit");
drop(sock);
if tree {
let err = never_blocking(child.terminate_tree())
.await
.expect_err("nothing was sent to a tree whose root had exited");
assert!(
matches!(&err, Error::Unassessable { detail, .. } if detail.contains("nothing was sent") && !detail.contains("CTRL_BREAK")),
"{err:?}"
);
never_blocking(child.graceful_shutdown_tree(Duration::ZERO))
.await
.expect("the call goes on and ends the tree");
} else {
never_blocking(child.terminate()).await.expect("an exited child is Ok");
}
assert_no_break_sent();
assert!(fixture.ran().is_none(), "tree {tree}: the proxy was started");
}
}
#[cfg(windows)]
#[skuld::test]
async fn async_the_default_refuses_a_child_cosca_did_not_create() {
use crate::containment::windows::ConsoleFacts;
assert_current_thread();
for caller_had_console in [true, false] {
let mut child = test_child::over_fake::child_over(&crate::os_process::fake::FakeProcess::new([
crate::os_process::fake::Answer::Running,
]));
child.console = ConsoleFacts {
group: true,
caller_had_console,
..ConsoleFacts::uac_elevated()
};
let err = never_blocking(stop::default(&StopTarget::from(&child)))
.await
.expect_err("not created by cosca");
let Error::Unsupported { detail, .. } = &err else {
panic!("{err:?}");
};
assert!(
detail.contains("did not create this child"),
"caller_had_console {caller_had_console}: {detail}"
);
crate::test_child::ctrl_break::assert_no_break_sent();
}
}