Signed-off-by: Rémi Rativel <remi.rativel@etudiant.univ-rennes1.fr>
This commit is contained in:
Rémi Rativel 2023-04-20 14:43:15 +02:00
parent bb1d2383bb
commit c33df28307

View File

@ -448,12 +448,14 @@ mod test {
let lock = Lock::new();
let lock_id = thread_manager.get_obj_addrs().add_lock(lock);
let thread = Rc::new(RefCell::new(Thread::new("test_lock")));
let thread_test = thread.clone();
thread_manager.ready_to_run(Rc::clone(&thread));
thread_manager.set_g_current_thread(Some(thread));
thread_manager.lock_acquire(lock_id, &mut machine).expect("lock acquire return an error: ");
{
let lock = thread_manager.get_obj_addrs().search_lock(lock_id).unwrap();
assert_eq!(lock.owner,Some(thread_test));
assert!(!lock.free);
assert!(lock.waiting_queue.is_empty());
}
@ -461,6 +463,7 @@ mod test {
thread_manager.lock_release(lock_id, &mut machine).expect("lock release return an error: ");
{
let lock = thread_manager.get_obj_addrs().search_lock(lock_id).unwrap();
assert_eq!(lock.owner, None);
assert!(!lock.free);
assert!(lock.waiting_queue.is_empty());
}