Skip to content

Commit dd3ecab

Browse files
authored
fix tests about comparing Arc<dyn KernelObject> (#173)
1 parent 999a5d4 commit dd3ecab

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

zircon-object/src/task/job.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -304,10 +304,14 @@ mod tests {
304304
#[test]
305305
fn create() {
306306
let root_job = Job::root();
307-
let job: Arc<dyn KernelObject> =
308-
Job::create_child(&root_job).expect("failed to create job");
307+
let job = Job::create_child(&root_job).expect("failed to create job");
309308

310-
assert!(Arc::ptr_eq(&root_job.get_child(job.id()).unwrap(), &job));
309+
let child = root_job
310+
.get_child(job.id())
311+
.unwrap()
312+
.downcast_arc()
313+
.unwrap();
314+
assert!(Arc::ptr_eq(&child, &job));
311315
assert_eq!(job.related_koid(), root_job.id());
312316
assert_eq!(root_job.related_koid(), 0);
313317

zircon-object/src/task/thread.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -740,9 +740,9 @@ mod tests {
740740
let thread = Thread::create(&proc, "thread").expect("failed to create thread");
741741
assert_eq!(thread.flags(), ThreadFlag::empty());
742742

743-
let thread: Arc<dyn KernelObject> = thread;
744743
assert_eq!(thread.related_koid(), proc.id());
745-
assert!(Arc::ptr_eq(&proc.get_child(thread.id()).unwrap(), &thread));
744+
let child = proc.get_child(thread.id()).unwrap().downcast_arc().unwrap();
745+
assert!(Arc::ptr_eq(&child, &thread));
746746
}
747747

748748
#[async_std::test]

0 commit comments

Comments
 (0)