13c48e655Sdan# 20 September 18 23c48e655Sdan# 33c48e655Sdan# The author disclaims copyright to this source code. In place of 43c48e655Sdan# a legal notice, here is a blessing: 53c48e655Sdan# 63c48e655Sdan# May you do good and not evil. 73c48e655Sdan# May you find forgiveness for yourself and forgive others. 83c48e655Sdan# May you share freely, never taking more than you give. 93c48e655Sdan# 103c48e655Sdan#*********************************************************************** 113c48e655Sdan# 123c48e655Sdan 133c48e655Sdanset testdir [file dirname $argv0] 143c48e655Sdansource $testdir/tester.tcl 153c48e655Sdan 163c48e655Sdan 173c48e655Sdanif 0 { 183c48e655Sdan db close 193c48e655Sdan sqlite3_shutdown 203c48e655Sdan proc msg {args} { puts $args } 213c48e655Sdan test_sqlite3_log msg 223c48e655Sdan sqlite3 db test.db 233c48e655Sdan} 243c48e655Sdan 253c48e655Sdanset testprefix mmapwarm 263c48e655Sdan 273c48e655Sdan 283c48e655Sdando_execsql_test 1.0 { 29*e1b972bdSdan PRAGMA auto_vacuum = 0; 303c48e655Sdan CREATE TABLE t1(x, y); 313c48e655Sdan WITH s(i) AS ( 323c48e655Sdan SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<500 333c48e655Sdan ) 343c48e655Sdan INSERT INTO t1 SELECT randomblob(400), randomblob(500) FROM s; 353c48e655Sdan PRAGMA page_count; 363c48e655Sdan} {507} 373c48e655Sdandb close 383c48e655Sdan 393c48e655Sdando_test 1.1 { 403c48e655Sdan sqlite3 db test.db 413c48e655Sdan db eval {PRAGMA mmap_size = 1000000} 423c48e655Sdan sqlite3_mmap_warm db 433c48e655Sdan} {SQLITE_OK} 443c48e655Sdan 453c48e655Sdando_test 1.2 { 463c48e655Sdan db close 473c48e655Sdan sqlite3 db test.db 483c48e655Sdan db eval {PRAGMA mmap_size = 1000000} 493c48e655Sdan sqlite3_mmap_warm db "main" 503c48e655Sdan} {SQLITE_OK} 513c48e655Sdan 523c48e655Sdando_test 1.3 { 533c48e655Sdan sqlite3 db test.db 543c48e655Sdan sqlite3_mmap_warm db 553c48e655Sdan} {SQLITE_OK} 563c48e655Sdan 573c48e655Sdando_test 1.4 { 583c48e655Sdan db close 593c48e655Sdan sqlite3 db test.db 603c48e655Sdan sqlite3_mmap_warm db "main" 613c48e655Sdan} {SQLITE_OK} 623c48e655Sdan 633c48e655Sdando_test 2.0 { 643c48e655Sdan db close 653c48e655Sdan sqlite3 db test.db 663c48e655Sdan db eval BEGIN 673c48e655Sdan sqlite3_mmap_warm db "main" 683c48e655Sdan} {SQLITE_MISUSE} 693c48e655Sdan 703c48e655Sdando_faultsim_test 3 -faults oom* -prep { 713c48e655Sdan sqlite3 db test.db 723c48e655Sdan sqlite3_db_config_lookaside db 0 0 0 733c48e655Sdan db eval { PRAGMA mmap_size = 1000000 } 743c48e655Sdan db eval { SELECT * FROM sqlite_master } 753c48e655Sdan} -body { 763c48e655Sdan sqlite3_mmap_warm db "main" 773c48e655Sdan} -test { 783c48e655Sdan faultsim_test_result {0 SQLITE_OK} {0 SQLITE_NOMEM} 793c48e655Sdan} 803c48e655Sdan 813c48e655Sdanfinish_test 82