feat(kernel): add Exit and ExitThread syscalls with process cleanup
This commit is contained in:
25
crates/kernel/src/tests/exit.rs
Normal file
25
crates/kernel/src/tests/exit.rs
Normal file
@@ -0,0 +1,25 @@
|
||||
use super::*;
|
||||
use crate::{SyscallOutcome, SyscallResult};
|
||||
use domain::syscall::Syscall;
|
||||
|
||||
#[test]
|
||||
fn exit_thread_terminates_caller() {
|
||||
let (mut k, _) = kernel_with_process();
|
||||
let outcome = k.handle_syscall(Syscall::ExitThread);
|
||||
assert!(matches!(outcome, SyscallOutcome::TerminateCaller));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn exit_terminates_process_and_all_threads() {
|
||||
let (mut k, _) = kernel_with_process();
|
||||
let outcome = k.handle_syscall(Syscall::Exit);
|
||||
assert!(matches!(outcome, SyscallOutcome::TerminateCaller));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn exit_thread_last_thread_destroys_process() {
|
||||
let (mut k, pid) = kernel_with_process();
|
||||
k.handle_syscall(Syscall::ExitThread);
|
||||
// Process should be gone since it had only one thread
|
||||
assert!(k.process_exists(pid) == false);
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
mod exit;
|
||||
mod simple;
|
||||
|
||||
use domain::memory::page_pool::PagePool;
|
||||
|
||||
Reference in New Issue
Block a user