use std::sync::{Arc, Mutex};
use std::time::Duration;
use crate::error::Error;
use crate::stop::{self, StopTarget};
use crate::test_child::{self, Console};
#[cfg(target_os = "linux")]
use crate::test_groups::{stray_signal, Group};
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 Fn(&StopTarget<'_>) -> Result<(), Error> + Send + Sync + 'static {
let seen = Arc::clone(seen);
move |target| {
seen.lock().unwrap().push((target.pid(), target.covers_tree()));
Ok(())
}
}
fn blocker_stopping_by(
action: impl Fn(&StopTarget<'_>) -> Result<(), Error> + Send + Sync + 'static,
contain: bool,
) -> (crate::Child, crate::PipeWriter) {
let mut cmd = test_child::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(&mut cmd);
#[cfg(windows)]
cmd.contain();
}
cmd.graceful_stop(action);
let mut child = cmd.spawn().expect("spawn");
let stdin = child.stdin().expect("piped stdin");
(child, stdin)
}
fn prepared_send(target: &StopTarget<'_>) -> Result<(), Error> {
#[cfg(unix)]
return stop::send_signal(target, crate::Signal::Usr1);
#[cfg(windows)]
return stop::send_ctrl_break_to_group(target);
}
#[cfg(unix)]
const PREPARED_SENT: &str = "the SIGUSR1";
#[cfg(windows)]
const PREPARED_SENT: &str = "the CTRL_BREAK";
fn assert_nothing_was_sent(child: &crate::Child, stdin: crate::PipeWriter) {
#[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().expect("reap"));
}
#[cfg(unix)]
#[skuld::test]
fn the_default_action_is_what_terminate_sent_before() {
let (child, stdin, stdout) = test_child::ready_tree(test_child::signal_reporting_tree_argv(), |_| {});
child.terminate().expect("the default stop");
drop(stdin);
assert_eq!(
test_child::signal_reports_to_end(stdout),
["leaf eof", "root SIGTERM"],
"only the root was sent the signal"
);
child.wait().expect("the root reported the signal and exited");
}
#[cfg(windows)]
#[skuld::test]
fn the_default_action_is_what_terminate_sent_before() {
use crate::test_child::ctrl_break::{self, assert_acked, kill_release_reap, Handler};
let (child, mut sock, _) = ctrl_break::spawn_member(Handler::Ack, None, crate::ContainMode::Strongest, |_| {});
stop::default(&StopTarget::from(&child)).expect("the default stop");
ctrl_break::assert_break_sent_to(child.pid());
assert_acked(&mut sock, "the root");
kill_release_reap(&child, sock, false);
}
#[skuld::test]
fn terminate_runs_the_callers_action_on_a_root_target() {
let seen = Seen::default();
let (child, stdin) = blocker_stopping_by(recording(&seen), false);
child.terminate().expect("the action's Ok is the answer");
assert_eq!(*seen.lock().unwrap(), [(child.pid(), false)]);
assert_nothing_was_sent(&child, stdin);
}
#[skuld::test]
fn terminate_tree_runs_the_action_on_a_tree_target() {
let seen = Seen::default();
let (child, stdin) = blocker_stopping_by(recording(&seen), true);
child.terminate_tree().expect("the action's Ok is the answer");
assert_eq!(*seen.lock().unwrap(), [(child.pid(), true)]);
assert_nothing_was_sent(&child, stdin);
}
#[skuld::test]
fn an_actions_error_is_terminates_error() {
let (child, stdin) = blocker_stopping_by(|_| Err(refused()), false);
let err = child.terminate().expect_err("the action refused");
assert!(
matches!(&err, Error::Unsupported { detail, .. } if detail == "refused by the test action"),
"{err:?}"
);
let err = child
.graceful_shutdown(Duration::ZERO)
.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(&child, stdin);
}
#[cfg(unix)]
struct Reports {
stdout: std::io::BufReader<crate::PipeReader>,
lines: Vec<String>,
}
#[cfg(unix)]
impl Reports {
fn new(stdout: crate::PipeReader) -> Reports {
Reports {
stdout: std::io::BufReader::new(stdout),
lines: Vec::new(),
}
}
fn until(&mut self, wanted: &[&str]) {
use std::io::BufRead 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).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);
}
}
fn read_rest(&mut self) {
use std::io::BufRead as _;
for line in (&mut self.stdout).lines() {
self.lines.push(line.expect("a report 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]
fn a_chosen_signal_reaches_the_root() {
let (child, stdin, stdout) = test_child::ready_tree(test_child::signal_reporting_tree_argv(), |cmd| {
cmd.graceful_stop(|target| stop::send_signal(target, crate::Signal::Usr1));
});
child.terminate().expect("the chosen signal was sent");
drop(stdin);
assert_eq!(
test_child::signal_reports_to_end(stdout),
["leaf eof", "root SIGUSR1"],
"only the root was sent the signal"
);
child.wait().expect("the root reported the signal and exited");
}
#[cfg(unix)]
#[skuld::test]
fn a_chosen_signal_reaches_every_member_of_the_tree() {
for shutdown in [false, true] {
let held = test_child::HeldStdin::default();
let ending = held.clone();
let (child, stdin, stdout) = test_child::ready_tree(test_child::signal_reporting_tree_argv(), |cmd| {
test_child::contain_without_cgroup(cmd);
cmd.graceful_stop(move |target| {
stop::send_signal(target, crate::Signal::Usr1)?;
ending.end();
Ok(())
});
});
held.hold(stdin);
let status = if shutdown {
Some(
child
.graceful_shutdown_tree(Duration::from_secs(3600))
.expect("the chosen signal ended the tree"),
)
} else {
child.terminate_tree().expect("the chosen signal was sent to the tree");
None
};
let reports = test_child::signal_reports_to_end(stdout);
if let Some(status) = status {
assert!(status.success(), "the root reported the signal and exited: {status:?}");
assert!(reports.iter().any(|line| line == "root SIGUSR1"), "{reports:?}");
assert!(
reports.iter().all(|line| line.ends_with("SIGUSR1")),
"only the chosen signal was sent: {reports:?}"
);
} else {
assert_eq!(
reports,
["leaf SIGUSR1", "root SIGUSR1"],
"both members got the chosen signal"
);
child.wait().expect("the root reported the signal and exited");
}
}
}
#[cfg(unix)]
#[skuld::test]
fn a_prepared_send_called_directly_keeps_the_gates() {
use crate::child::front_kill_tests::{cat, spawn_as};
use crate::elevation::{Backend, ElevatedVia};
use std::os::unix::process::ExitStatusExt as _;
let (child, stdin) = spawn_as(cat(), ElevatedVia::Wrapped(Backend::Sudo));
let target = StopTarget::from(&child);
let err = stop::send_signal(&target, crate::Signal::Alrm).expect_err("sudo does not relay SIGALRM");
let Error::Unsupported { detail, .. } = &err else {
panic!("{err:?}");
};
assert!(detail.contains("SIGALRM") && detail.contains("sudo"), "{detail}");
assert_eq!(
child.is_alive(),
crate::identity::Liveness::Alive,
"the refused signal was not sent"
);
stop::send_signal(&target, crate::Signal::Usr1).expect("sudo relays SIGUSR1");
drop(stdin);
let status = child.wait().expect("reap");
assert_eq!(
status.signal(),
Some(libc::SIGUSR1),
"the relayed signal was sent: {status:?}"
);
}
#[cfg(unix)]
#[skuld::test]
fn a_prepared_tree_send_keeps_the_front_gate() {
use crate::child::front_kill_tests::{cat, spawn_as};
use crate::elevation::{Backend, ElevatedVia};
for shutdown in [false, true] {
let mut cmd = cat();
test_child::contain_without_cgroup(&mut cmd);
cmd.graceful_stop(|target| stop::send_signal(target, crate::Signal::Alrm));
let (child, stdin) = spawn_as(cmd, ElevatedVia::Wrapped(Backend::Sudo));
let err = if shutdown {
child.graceful_shutdown_tree(Duration::ZERO).expect_err("refused")
} else {
child.terminate_tree().expect_err("refused")
};
let Error::Unsupported { detail, .. } = &err else {
panic!("shutdown: {shutdown}: {err:?}");
};
assert!(
detail.contains("SIGALRM") && detail.contains("sudo"),
"shutdown: {shutdown}: {detail}"
);
assert_eq!(
child.is_alive(),
crate::identity::Liveness::Alive,
"shutdown: {shutdown}: nothing was sent, and no sweep ran"
);
drop(stdin);
let status = child.wait().expect("reap");
assert!(
status.success(),
"shutdown: {shutdown}: it ended on its stdin: {status:?}"
);
}
}
#[cfg(unix)]
#[skuld::test]
fn an_action_may_compose_sends_with_a_wait() {
for tree in [false, true] {
let waited = Arc::new(Mutex::new(Vec::new()));
let record = Arc::clone(&waited);
let reports = Arc::new(Mutex::new(None::<Reports>));
let held = test_child::HeldStdin::default();
let first: &[&str] = if tree {
&["root SIGUSR1", "leaf SIGUSR1"]
} else {
&["root SIGUSR1"]
};
let (child, stdin, stdout) = test_child::ready_tree(test_child::signal_then_term_tree_argv(), |cmd| {
if tree {
test_child::contain_without_cgroup(cmd);
}
let (reports, held) = (Arc::clone(&reports), held.clone());
cmd.graceful_stop(move |target| {
let sent = crate::send_log::Capture::start();
stop::send_signal(target, crate::Signal::Usr1)?;
sent.require_a_send(libc::SIGUSR1)?;
record.lock().unwrap().push(target.wait_exit(Duration::ZERO)?);
reports.lock().unwrap().as_mut().expect("the reports").until(first);
stop::send_signal(target, crate::Signal::Term)?;
held.end();
record
.lock()
.unwrap()
.push(target.wait_exit(Duration::from_secs(3600))?);
Ok(())
});
});
held.hold(stdin);
*reports.lock().unwrap() = Some(Reports::new(stdout));
if tree {
child.terminate_tree().expect("the composed stop");
} else {
child.terminate().expect("the composed stop");
}
assert_eq!(*waited.lock().unwrap(), [false, true], "tree: {tree}");
let mut reports = reports.lock().unwrap().take().expect("the reports");
reports.read_rest();
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().expect("the root had exited, and is reaped once");
}
}
#[skuld::test]
fn graceful_shutdown_tree_goes_on_after_a_callers_own_action() {
let (child, stdin) = blocker_stopping_by(|_| Ok(()), true);
let status = child
.graceful_shutdown_tree(Duration::ZERO)
.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]
fn graceful_shutdown_tree_keeps_an_error_after_a_send_that_went_out() {
crate::log_capture::install();
let mark = crate::log_capture::mark();
let held = test_child::HeldStdin::default();
let ending = held.clone();
let (child, stdin, stdout) = test_child::ready_tree(test_child::signal_reporting_tree_argv(), |cmd| {
test_child::contain_without_cgroup(cmd);
cmd.graceful_stop(move |target| {
prepared_send(target)?;
ending.end();
Err(refused())
});
});
held.hold(stdin);
let _armed = crate::child::graceful::fault::ArmedKillTreeError::arm();
let err = child
.graceful_shutdown_tree(Duration::from_secs(3600))
.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:?}"
);
assert_eq!(
test_child::signal_reports_to_end(stdout),
["leaf SIGUSR1", "root SIGUSR1"],
"the send that went out reached the tree"
);
}
#[cfg(windows)]
#[skuld::test]
fn graceful_shutdown_tree_keeps_an_error_after_a_send_that_went_out() {
use crate::test_child::ctrl_break::{self, Handler, STATUS_CONTROL_C_EXIT};
crate::log_capture::install();
let mark = crate::log_capture::mark();
let (child, sock, _) = ctrl_break::spawn_member(Handler::Default, None, crate::ContainMode::Strongest, |cmd| {
cmd.graceful_stop(|target| {
prepared_send(target)?;
Err(refused())
});
});
ctrl_break::assert_in_our_console(child.pid(), "the root");
let status = child
.graceful_shutdown_tree(Duration::from_secs(3600))
.expect("the tree drained, which supersedes the action's error");
ctrl_break::assert_break_sent_to(child.pid());
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]
fn graceful_shutdown_tree_ends_on_an_error_with_nothing_sent() {
let (child, stdin) = blocker_stopping_by(|_| Err(refused()), true);
let err = child
.graceful_shutdown_tree(Duration::ZERO)
.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(&child, stdin);
}
#[skuld::test]
fn a_call_words_what_the_action_sent_before_its_kill() {
type Action = Box<dyn Fn(&StopTarget<'_>) -> Result<(), Error> + Send + Sync>;
let rows: [(&str, Action, &str, bool); 3] = [
(
"an action that sends nothing",
Box::new(|_| Ok(())),
"the stop action",
false,
),
("a prepared send", Box::new(prepared_send), PREPARED_SENT, false),
(
"a prepared send, then one that was refused",
Box::new(|target| {
prepared_send(target)?;
target.note_refused(&refused());
Ok(())
}),
"the stop action",
true,
),
];
crate::log_capture::install();
let refusal_logged = |mark: usize, marker: &str| {
crate::log_capture::records_since_on_current_thread(mark, marker)
.iter()
.any(|(level, text)| {
*level == log::Level::Debug
&& text.contains("the action went on after a refused send")
&& text.contains("refused by the test action")
})
};
for (what, action, says, logs_a_refusal) in rows {
let (child, stdin) = blocker_stopping_by(action, true);
let mark = crate::log_capture::mark();
let (answer, earlier) = crate::child::graceful::shutdown::run_ready(
crate::child::graceful::shutdown::stop_root(&crate::child::graceful::shutdown::BlockingDriver(&child)),
);
answer.unwrap_or_else(|e| panic!("{what}: {e:?}"));
assert_eq!(earlier, says, "the lone shutdown's kill, after {what}");
assert_eq!(
refusal_logged(mark, &format!("graceful_shutdown({})", child.pid())),
logs_a_refusal,
"{what}"
);
child.kill().expect("kill");
drop(stdin);
child.wait().expect("reap");
}
}
#[skuld::test]
fn a_tree_call_words_what_the_action_sent_before_its_sweep() {
use crate::child::graceful::SignalTreeCooperativelyOutcome;
type Action = Box<dyn Fn(&StopTarget<'_>) -> Result<(), Error> + Send + Sync>;
let rows: [(&str, Action, &str, bool); 3] = [
(
"an action that sends nothing",
Box::new(|_| Ok(())),
"the stop action",
false,
),
("a prepared send", Box::new(prepared_send), PREPARED_SENT, false),
(
"a prepared send, then one that was refused",
Box::new(|target| {
prepared_send(target)?;
target.note_refused(&refused());
Ok(())
}),
"the stop action",
true,
),
];
crate::log_capture::install();
for (what, action, says, logs_a_refusal) in rows {
let (child, stdin) = blocker_stopping_by(action, true);
let mark = crate::log_capture::mark();
match crate::child::graceful::shutdown::run_ready(crate::child::graceful::shutdown::signal_tree_cooperatively(
&crate::child::graceful::shutdown::BlockingDriver(&child),
)) {
SignalTreeCooperativelyOutcome::Sent {
result: Ok(()),
earlier: Some(earlier),
..
} => assert_eq!(earlier, says, "the sweep's error, after {what}"),
other => panic!("{what}: the cooperative signal did not go on to the sweep: {other:?}"),
}
let logged = crate::log_capture::records_since_on_current_thread(
mark,
&format!("graceful_shutdown_tree({})", child.pid()),
);
assert_eq!(
logged.iter().any(|(level, text)| {
*level == log::Level::Debug
&& text.contains("the action went on after a refused send")
&& text.contains("refused by the test action")
}),
logs_a_refusal,
"{what}: {logged:?}"
);
child.kill_tree().expect("kill_tree");
drop(stdin);
child.wait().expect("reap");
}
}
#[cfg(target_os = "linux")]
#[skuld::test]
fn a_composed_action_stops_at_a_send_that_found_nothing_to_name(#[fixture(stray_signal)] _stray: &Group) {
use crate::containment::unix::fault::{record_kill_group, record_term_group};
use crate::test_child::reaped_elsewhere::{kill_own_child, reap_behind, session_cat};
let _old_kernel = crate::containment::unix::fault::refuse_pidfd_group_flag();
crate::log_capture::install();
let killed = record_kill_group();
let termed = record_term_group();
let steps = Arc::new(Mutex::new(Vec::new()));
let mut cmd = session_cat();
cmd.graceful_stop({
let steps = Arc::clone(&steps);
move |target| {
steps.lock().unwrap().push("first send");
stop::send_signal(target, crate::Signal::Int)?;
steps.lock().unwrap().push("wait");
target.wait_exit(Duration::ZERO)?;
steps.lock().unwrap().push("second send");
stop::send_signal(target, crate::Signal::Term)?;
Ok(())
}
});
let child = cmd.spawn().expect("spawn");
let pid = child.pid();
kill_own_child(pid);
reap_behind(pid);
let err = child
.graceful_shutdown_tree(Duration::ZERO)
.expect_err("a group whose root was reaped elsewhere is not assessable");
assert!(matches!(err, Error::Unassessable { .. }), "{err:?}");
assert_eq!(
*steps.lock().unwrap(),
["first send"],
"the action stopped at its first `?`"
);
assert_eq!(
killed.killed(),
Vec::<i32>::new(),
"no killpg by a reaped root's number"
);
assert_eq!(
termed.termed(),
Vec::<i32>::new(),
"no signal by a reaped root's number"
);
}
#[cfg(target_os = "linux")]
#[skuld::test]
fn 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 crate::test_child::reaped_elsewhere::session_cat;
use std::os::unix::process::ExitStatusExt as _;
let _old_kernel = crate::containment::unix::fault::refuse_pidfd_group_flag();
crate::log_capture::install();
let mut cmd = session_cat();
cmd.graceful_stop(|target| stop::send_signal(target, crate::Signal::Usr1));
let mut child = cmd.spawn().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
.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 = child
.graceful_shutdown_tree(Duration::ZERO)
.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().expect("reap the root");
assert_eq!(
status.signal(),
Some(libc::SIGUSR1),
"the action's signal ended the root"
);
}
#[cfg(windows)]
#[skuld::test]
fn a_prepared_send_on_a_child_without_the_group_flag_is_unsupported() {
let (child, stdin) = blocker_stopping_by(|_| Ok(()), false);
for target in [
StopTarget::from(&child),
StopTarget::tree(&child, stop::TreeCall::SignalOnly),
] {
let err = stop::send_ctrl_break_to_group(&target).expect_err("no group to address");
let Error::Unsupported { detail, .. } = &err else {
panic!("{err:?}");
};
assert!(detail.contains("contain"), "the refusal names the remedy: {detail}");
assert!(
detail.contains("kill()"),
"the refusal names the other remedy: {detail}"
);
assert!(!detail.contains(" "), "a run of spaces: {detail:?}");
}
assert_nothing_was_sent(&child, stdin);
}
#[cfg(windows)]
#[skuld::test]
fn a_prepared_send_refuses_a_child_cosca_did_not_create() {
use crate::containment::windows::ConsoleFacts;
let mut child = test_child::over_fake::child_over(&crate::os_process::fake::FakeProcess::new([]));
child.console = ConsoleFacts {
group: true,
..ConsoleFacts::uac_elevated()
};
let err = stop::send_ctrl_break_to_group(&StopTarget::from(&child)).expect_err("not created by cosca");
let Error::Unsupported { detail, .. } = &err else {
panic!("{err:?}");
};
assert!(detail.contains("did not create this child"), "{detail}");
assert!(detail.contains("kill()"), "the refusal names the remedy: {detail}");
assert!(!detail.contains(" "), "a run of spaces: {detail:?}");
crate::test_child::ctrl_break::assert_no_break_sent();
}
#[cfg(windows)]
#[skuld::test]
fn the_default_refuses_a_child_cosca_did_not_create() {
use crate::containment::windows::ConsoleFacts;
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 = stop::default(&StopTarget::from(&child)).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();
}
}