reverie/tests/thread_start.rs
Jason White 6813d9a7b2 rustfmt with imports_granularity=Item
Summary: This makes merge conflicts much easier to handle.

Reviewed By: johnhurt

Differential Revision: D37564000

fbshipit-source-id: a7f1a2711ffbdbb23c93e2f479f47d0368a2dad9
2022-06-30 14:56:20 -07:00

56 lines
1.4 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;
use serde::Deserialize;
use serde::Serialize;
#[test]
fn thread_start_inject() {
#[derive(Debug, Serialize, Deserialize, 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, Serialize, Deserialize, 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, _>(|| {});
}