mirror of
https://github.com/isar/rusqlite.git
synced 2025-08-19 12:29:34 +08:00
Add test and check for SQLite being in single-threaded mode
This commit is contained in:
20
tests/deny_single_threaded_sqlite_config.rs
Normal file
20
tests/deny_single_threaded_sqlite_config.rs
Normal file
@@ -0,0 +1,20 @@
|
||||
//! Ensure we reject connections when SQLite is in single-threaded mode, as it
|
||||
//! would violate safety if multiple Rust threads tried to use connections.
|
||||
|
||||
extern crate rusqlite;
|
||||
extern crate libsqlite3_sys as ffi;
|
||||
|
||||
use rusqlite::Connection;
|
||||
|
||||
#[test]
|
||||
fn test_error_when_singlethread_mode() {
|
||||
// put SQLite into single-threaded mode
|
||||
unsafe {
|
||||
// 1 == SQLITE_CONFIG_SINGLETHREAD
|
||||
assert_eq!(ffi::sqlite3_config(1), ffi::SQLITE_OK);
|
||||
println!("{}", ffi::sqlite3_mutex_alloc(0) as u64);
|
||||
}
|
||||
|
||||
let result = Connection::open_in_memory();
|
||||
assert!(result.is_err());
|
||||
}
|
Reference in New Issue
Block a user