1# 2011 March 29 2# 3# The author disclaims copyright to this source code. In place of 4# a legal notice, here is a blessing: 5# 6# May you do good and not evil. 7# May you find forgiveness for yourself and forgive others. 8# May you share freely, never taking more than you give. 9# 10#*********************************************************************** 11# 12 13set testdir [file dirname $argv0] 14source $testdir/tester.tcl 15source $testdir/lock_common.tcl 16source $testdir/malloc_common.tcl 17 18if {[llength [info commands test_syscall]]==0} { 19 finish_test 20 return 21} 22set testprefix syscall 23 24 25#------------------------------------------------------------------------- 26# Tests for the xSetSystemCall method. 27# 28do_test 1.1.1 { 29 list [catch { test_syscall reset open } msg] $msg 30} {0 {}} 31do_test 1.1.2 { 32 list [catch { test_syscall reset nosuchcall } msg] $msg 33} {1 SQLITE_NOTFOUND} 34do_test 1.1.3 { 35 list [catch { test_syscall reset open } msg] $msg 36} {0 {}} 37do_test 1.1.4 { 38 list [catch { test_syscall reset ""} msg] $msg 39} {1 SQLITE_NOTFOUND} 40 41do_test 1.2 { test_syscall reset } {} 42 43do_test 1.3.1 { test_syscall install {open getcwd access} } {} 44do_test 1.3.2 { test_syscall reset } {} 45 46#------------------------------------------------------------------------- 47# Tests for the xGetSystemCall method. 48# 49do_test 2.1.1 { test_syscall exists open } 1 50do_test 2.1.2 { test_syscall exists nosuchcall } 0 51 52#------------------------------------------------------------------------- 53# Tests for the xNextSystemCall method. 54# 55set syscall_list [list \ 56 open close access getcwd stat fstat ftruncate \ 57 fcntl read pread write pwrite fchmod \ 58] 59if {[test_syscall exists fallocate]} {lappend syscall_list fallocate} 60do_test 3.1 { test_syscall list } $syscall_list 61 62#------------------------------------------------------------------------- 63# This test verifies that if a call to open() fails and errno is set to 64# EINTR, the call is retried. If it succeeds, execution continues as if 65# nothing happened. 66# 67test_syscall reset 68forcedelete test.db2 69do_execsql_test 4.1 { 70 CREATE TABLE t1(x, y); 71 INSERT INTO t1 VALUES(1, 2); 72 ATTACH 'test.db2' AS aux; 73 CREATE TABLE aux.t2(x, y); 74 INSERT INTO t2 VALUES(3, 4); 75} 76 77db_save_and_close 78test_syscall install open 79foreach jrnl [list wal delete] { 80 for {set i 1} {$i < 20} {incr i} { 81 db_restore_and_reopen 82 test_syscall fault $i 0 83 test_syscall errno open EINTR 84 85 do_test 4.2.$jrnl.$i { 86 sqlite3 db test.db 87 execsql { ATTACH 'test.db2' AS aux } 88 execsql "PRAGMA main.journal_mode = $jrnl" 89 execsql "PRAGMA aux.journal_mode = $jrnl" 90 execsql { 91 BEGIN; 92 INSERT INTO t1 VALUES(5, 6); 93 INSERT INTO t2 VALUES(7, 8); 94 COMMIT; 95 } 96 97 db close 98 sqlite3 db test.db 99 execsql { ATTACH 'test.db2' AS aux } 100 execsql { 101 SELECT * FROM t1; 102 SELECT * FROM t2; 103 } 104 } {1 2 5 6 3 4 7 8} 105 } 106 107} 108 109 110 111finish_test 112