Skip to content

Commit 8468990

Browse files
committed
Use fmt::Display impl of Signal in signals test
Removes the need for SIGNAL_NAMES.
1 parent fd27982 commit 8468990

File tree

1 file changed

+4
-39
lines changed

1 file changed

+4
-39
lines changed

tests/signals.rs

Lines changed: 4 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -47,41 +47,6 @@ const SIGNALS: &[Signal] = &[
4747
Signal::SYS,
4848
];
4949

50-
const SIGNAL_NAMES: [&str; SIGNALS.len()] = [
51-
"SIGHUP",
52-
"SIGINT",
53-
"SIGQUIT",
54-
"SIGILL",
55-
"SIGTRAP",
56-
"SIGABRT",
57-
"SIGIOT",
58-
"SIGBUS",
59-
"SIGFPE",
60-
"SIGUSR1",
61-
"SIGUSR2",
62-
"SIGSEGV",
63-
"SIGPIPE",
64-
"SIGALRM",
65-
"SIGTERM",
66-
"SIGCHLD",
67-
"SIGCONT",
68-
"SIGTSTP",
69-
"SIGTTIN",
70-
"SIGTTOU",
71-
"SIGURG",
72-
"SIGXCPU",
73-
"SIGXFSZ",
74-
"SIGVTALRM",
75-
"SIGPROF",
76-
"SIGWINCH",
77-
"SIGIO",
78-
#[cfg(any(target_os = "android", target_os = "linux"))]
79-
"SIGPOLL",
80-
#[cfg(any(target_os = "android", target_os = "linux"))]
81-
"SIGPWR",
82-
"SIGSYS",
83-
];
84-
8550
fn main() {
8651
init();
8752
let start = Instant::now();
@@ -154,10 +119,10 @@ impl TestHarness {
154119
F: FnMut(&mut Ring, &Signals, Signal),
155120
{
156121
let signals = self.signals.as_ref().unwrap();
157-
for (signal, name) in SIGNALS.iter().copied().zip(SIGNAL_NAMES) {
122+
for signal in SIGNALS.into_iter().copied() {
158123
print_test_start(
159124
self.quiet,
160-
format_args!("{test_name} ({:?}, {name})", self.fd_kind),
125+
format_args!("{test_name} ({:?}, {signal}, {signal:?})", self.fd_kind),
161126
);
162127
// thread sanitizer can't deal with `SIGSYS` signal being send.
163128
#[cfg(feature = "nightly")]
@@ -215,10 +180,10 @@ impl TestHarness {
215180
fn test_receive_signals(&mut self) {
216181
let pid = std::process::id();
217182
let mut receive_signal = self.signals.take().unwrap().receive_signals();
218-
for (signal, name) in SIGNALS.into_iter().zip(SIGNAL_NAMES) {
183+
for signal in SIGNALS.into_iter() {
219184
print_test_start(
220185
self.quiet,
221-
format_args!("receive_signals ({:?}, {name})", self.fd_kind),
186+
format_args!("receive_signals ({:?}, {signal}, {signal:?})", self.fd_kind),
222187
);
223188
// thread sanitizer can't deal with `SIGSYS` signal being send.
224189
#[cfg(feature = "nightly")]

0 commit comments

Comments
 (0)