summaryrefslogtreecommitdiff
path: root/rust/tests/main_thread.rs
blob: a42157a9fd128aabe15419d31352bffd7cf94c9f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
use binaryninja::headless::Session;

// TODO: Add a test for MainThreadHandler

#[test]
fn test_not_main_thread() {
    // We should never be the main thread.
    assert!(!binaryninja::is_main_thread())
}

#[test]
fn test_main_thread_different() {
    let _session = Session::new().expect("Failed to initialize 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"
        )
    });
}