reverie/tests/thread_start.rs
Jason White cc40e95c91 Remove unnecessary Serialize/Deserialize impls for tools
Summary: Now that `Tool` doesn't require `Serialize` and `Deserialize`, we can remove these unnecessary derives. Hopefully this will have a slight improvement to compile-times.

Reviewed By: wkhughes

Differential Revision: D40958697

fbshipit-source-id: 88aa1f4ee2b953ba287d749c88d200c2887ccd46
2022-11-03 12:53:11 -07:00

55 lines
1.3 KiB
Rust

/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/
#![cfg(not(sanitized))]
use reverie::syscalls;
use reverie::Error;
use reverie::Guest;
use reverie::Pid;
use reverie::Tool;
#[test]
fn thread_start_inject() {
#[derive(Debug, Default)]
struct TestTool;
#[reverie::tool]
impl Tool for TestTool {
type GlobalState = ();
type ThreadState = ();
async fn handle_thread_start<T: Guest<Self>>(&self, guest: &mut T) -> Result<(), Error> {
let ret = guest.inject(syscalls::Getpid::new()).await?;
assert_eq!(Pid::from_raw(ret as i32), guest.pid());
Ok(())
}
}
reverie_ptrace::testing::check_fn::<TestTool, _>(|| {});
}
#[test]
fn thread_start_tail_inject() {
#[derive(Debug, Default)]
struct TestTool;
#[reverie::tool]
impl Tool for TestTool {
type GlobalState = ();
type ThreadState = ();
async fn handle_thread_start<T: Guest<Self>>(&self, guest: &mut T) -> Result<(), Error> {
guest.tail_inject(syscalls::Getpid::new()).await;
unreachable!()
}
}
reverie_ptrace::testing::check_fn::<TestTool, _>(|| {});
}