aboutsummaryrefslogtreecommitdiff
path: root/tests/deny_single_threaded_sqlite_config.rs
blob: f6afdd51c40cd539129dc98780f365709c3759d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
//! Ensure we reject connections when SQLite is in single-threaded mode, as it
//! would violate safety if multiple Rust threads tried to use connections.

use rusqlite::ffi;
use rusqlite::Connection;

#[test]
#[should_panic]
fn test_error_when_singlethread_mode() {
    // put SQLite into single-threaded mode
    unsafe {
        if ffi::sqlite3_config(ffi::SQLITE_CONFIG_SINGLETHREAD) != ffi::SQLITE_OK {
            return;
        }
        if ffi::sqlite3_initialize() != ffi::SQLITE_OK {
            return;
        }
    }

    let _ = Connection::open_in_memory().unwrap();
}