Skip to content

Commit 010f119

Browse files
Manciukicroypat
authored andcommitted
test(signal): remove flaky unit test
The signal handler unit test registers the signal handlers, spins up a new thread, and sends signals to itself (using kill) to check that the metrics get updated. This is a very complicated test for a unit test, and it's already covered in the integration test test_signals.py. As this test is seldomly failing in our CI, it's best to get rid of its complexity and rely on the integration tests, which are better suited for this kind of test. Signed-off-by: Riccardo Mancini <mancio@amazon.com>
1 parent 321b26a commit 010f119

File tree

1 file changed

+0
-72
lines changed

1 file changed

+0
-72
lines changed

src/vmm/src/signal_handler.rs

Lines changed: 0 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ macro_rules! generate_handler {
5050

5151
$body(si_code, info);
5252

53-
#[cfg(not(test))]
5453
match si_signo {
5554
$signal_name => exit_with_code(crate::FcExitCode::$exit_code),
5655
_ => exit_with_code(FcExitCode::UnexpectedError),
@@ -170,74 +169,3 @@ pub fn register_signal_handlers() -> vmm_sys_util::errno::Result<()> {
170169
register_signal_handler(SIGILL, sigill_handler)?;
171170
Ok(())
172171
}
173-
174-
#[cfg(test)]
175-
mod tests {
176-
#![allow(clippy::undocumented_unsafe_blocks)]
177-
use std::{process, thread};
178-
179-
use libc::syscall;
180-
181-
use super::*;
182-
183-
#[test]
184-
fn test_signal_handler() {
185-
let child = thread::spawn(move || {
186-
register_signal_handlers().unwrap();
187-
188-
// Call the forbidden `SYS_mkdirat`.
189-
unsafe { libc::syscall(libc::SYS_mkdirat, "/foo/bar\0") };
190-
191-
// Call SIGBUS signal handler.
192-
assert_eq!(METRICS.signals.sigbus.fetch(), 0);
193-
unsafe {
194-
syscall(libc::SYS_kill, process::id(), SIGBUS);
195-
}
196-
197-
// Call SIGSEGV signal handler.
198-
assert_eq!(METRICS.signals.sigsegv.fetch(), 0);
199-
unsafe {
200-
syscall(libc::SYS_kill, process::id(), SIGSEGV);
201-
}
202-
203-
// Call SIGXFSZ signal handler.
204-
assert_eq!(METRICS.signals.sigxfsz.fetch(), 0);
205-
unsafe {
206-
syscall(libc::SYS_kill, process::id(), SIGXFSZ);
207-
}
208-
209-
// Call SIGXCPU signal handler.
210-
assert_eq!(METRICS.signals.sigxcpu.fetch(), 0);
211-
unsafe {
212-
syscall(libc::SYS_kill, process::id(), SIGXCPU);
213-
}
214-
215-
// Call SIGPIPE signal handler.
216-
assert_eq!(METRICS.signals.sigpipe.count(), 0);
217-
unsafe {
218-
syscall(libc::SYS_kill, process::id(), SIGPIPE);
219-
}
220-
221-
// Call SIGHUP signal handler.
222-
assert_eq!(METRICS.signals.sighup.fetch(), 0);
223-
unsafe {
224-
syscall(libc::SYS_kill, process::id(), SIGHUP);
225-
}
226-
227-
// Call SIGILL signal handler.
228-
assert_eq!(METRICS.signals.sigill.fetch(), 0);
229-
unsafe {
230-
syscall(libc::SYS_kill, process::id(), SIGILL);
231-
}
232-
});
233-
child.join().unwrap();
234-
235-
assert!(METRICS.signals.sigbus.fetch() >= 1);
236-
assert!(METRICS.signals.sigsegv.fetch() >= 1);
237-
assert!(METRICS.signals.sigxfsz.fetch() >= 1);
238-
assert!(METRICS.signals.sigxcpu.fetch() >= 1);
239-
assert!(METRICS.signals.sigpipe.count() >= 1);
240-
assert!(METRICS.signals.sighup.fetch() >= 1);
241-
assert!(METRICS.signals.sigill.fetch() >= 1);
242-
}
243-
}

0 commit comments

Comments
 (0)