Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion litebox_shim_linux/src/syscalls/signal/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,10 @@ impl<Platform: ShimPlatform, FS: ShimFS> Task<Platform, FS> {
}

fn force_signal_with_info(&self, signal: Signal, force_exit: bool, siginfo: Siginfo) {
assert!(matches!(signal, Signal::SIGKILL | Signal::SIGSEGV));
assert!(matches!(
signal,
Signal::SIGKILL | Signal::SIGSEGV | Signal::SIGFPE | Signal::SIGTRAP | Signal::SIGILL
));

self.signals
.pending
Expand Down
25 changes: 25 additions & 0 deletions litebox_shim_linux/src/syscalls/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ use zerocopy::FromBytes as _;

use crate::UserPtrMut;

#[cfg(target_arch = "x86_64")]
use litebox::shim::{Exception, ExceptionInfo};
#[cfg(target_arch = "x86_64")]
use litebox_common_linux::signal::Signal;

extern crate std;

const TEST_TAR_FILE: &[u8] = include_bytes!("../../../litebox/src/fs/test.tar");
Expand Down Expand Up @@ -78,6 +83,26 @@ pub(crate) fn init_platform(
task
}

#[cfg(target_arch = "x86_64")]
#[test]
fn exceptions_queue_their_corresponding_signals() {
let task = init_platform(None);

for (exception, signal) in [
(Exception::DIVIDE_ERROR, Signal::SIGFPE),
(Exception::BREAKPOINT, Signal::SIGTRAP),
(Exception::INVALID_OPCODE, Signal::SIGILL),
] {
task.handle_exception_request(&ExceptionInfo {
exception,
error_code: 0,
cr2: 0,
kernel_mode: false,
});
assert!(task.pending_signal_set().contains(signal));
}
}

#[test]
fn test_fcntl() {
let task = init_platform(None);
Expand Down