Skip to content

Commit

Permalink
fix tests about comparing Arc<dyn KernelObject> (#173)
Browse files Browse the repository at this point in the history
  • Loading branch information
xxchan authored Sep 6, 2020
1 parent 999a5d4 commit dd3ecab
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 7 additions & 3 deletions zircon-object/src/task/job.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,10 +304,14 @@ mod tests {
#[test]
fn create() {
let root_job = Job::root();
let job: Arc<dyn KernelObject> =
Job::create_child(&root_job).expect("failed to create job");
let job = Job::create_child(&root_job).expect("failed to create job");

assert!(Arc::ptr_eq(&root_job.get_child(job.id()).unwrap(), &job));
let child = root_job
.get_child(job.id())
.unwrap()
.downcast_arc()
.unwrap();
assert!(Arc::ptr_eq(&child, &job));
assert_eq!(job.related_koid(), root_job.id());
assert_eq!(root_job.related_koid(), 0);

Expand Down
4 changes: 2 additions & 2 deletions zircon-object/src/task/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -740,9 +740,9 @@ mod tests {
let thread = Thread::create(&proc, "thread").expect("failed to create thread");
assert_eq!(thread.flags(), ThreadFlag::empty());

let thread: Arc<dyn KernelObject> = thread;
assert_eq!(thread.related_koid(), proc.id());
assert!(Arc::ptr_eq(&proc.get_child(thread.id()).unwrap(), &thread));
let child = proc.get_child(thread.id()).unwrap().downcast_arc().unwrap();
assert!(Arc::ptr_eq(&child, &thread));
}

#[async_std::test]
Expand Down

0 comments on commit dd3ecab

Please sign in to comment.