diff options
Diffstat (limited to 'rust/tests/main_thread.rs')
| -rw-r--r-- | rust/tests/main_thread.rs | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/rust/tests/main_thread.rs b/rust/tests/main_thread.rs new file mode 100644 index 00000000..f74414d5 --- /dev/null +++ b/rust/tests/main_thread.rs @@ -0,0 +1,29 @@ +use binaryninja::headless::Session; +use rstest::*; + +// TODO: Add a test for MainThreadHandler + +#[fixture] +#[once] +fn session() -> Session { + Session::new().expect("Failed to initialize session") +} + +#[rstest] +fn test_not_main_thread(_session: &Session) { + // We should never be the main thread. + assert!(!binaryninja::is_main_thread()) +} + +#[rstest] +fn test_main_thread_different(_session: &Session) { + let calling_thread = std::thread::current(); + binaryninja::main_thread::execute_on_main_thread_and_wait(move || { + let main_thread = std::thread::current(); + assert_ne!( + calling_thread.id(), + main_thread.id(), + "Expected calling thread to be the different from the main thread" + ) + }); +} |
