1c74e4ef4Sdan# 2010 July 15 2c74e4ef4Sdan# 3c74e4ef4Sdan# The author disclaims copyright to this source code. In place of 4c74e4ef4Sdan# a legal notice, here is a blessing: 5c74e4ef4Sdan# 6c74e4ef4Sdan# May you do good and not evil. 7c74e4ef4Sdan# May you find forgiveness for yourself and forgive others. 8c74e4ef4Sdan# May you share freely, never taking more than you give. 9c74e4ef4Sdan# 10c74e4ef4Sdan#*********************************************************************** 11c74e4ef4Sdan# This file implements regression tests for SQLite library. 12c74e4ef4Sdan# 13c74e4ef4Sdan 14c74e4ef4Sdanset testdir [file dirname $argv0] 15c74e4ef4Sdansource $testdir/tester.tcl 16c74e4ef4Sdansource $testdir/lock_common.tcl 17c74e4ef4Sdansource $testdir/malloc_common.tcl 18c74e4ef4Sdan 19c74e4ef4Sdan#------------------------------------------------------------------------- 20c74e4ef4Sdan# If a connection is required to create a journal file, it creates it with 21c74e4ef4Sdan# the same file-system permissions as the database file itself. Test this. 22c74e4ef4Sdan# 2369aedc8dSdanif {$::tcl_platform(platform) == "unix" 2469aedc8dSdan && [atomic_batch_write test.db]==0 2569aedc8dSdan} { 26c74e4ef4Sdan 278c815d14Sdrh # Changed on 2012-02-13: umask is deliberately ignored for -wal, -journal, 288c815d14Sdrh # and -shm files. 298c815d14Sdrh #set umask [exec /bin/sh -c umask] 30c74e4ef4Sdan faultsim_delete_and_reopen 31c74e4ef4Sdan do_test journal3-1.1 { execsql { CREATE TABLE tx(y, z) } } {} 32c74e4ef4Sdan 33c74e4ef4Sdan foreach {tn permissions} { 34c74e4ef4Sdan 1 00644 35c74e4ef4Sdan 2 00666 36c74e4ef4Sdan 3 00600 37c74e4ef4Sdan 4 00755 38c74e4ef4Sdan } { 39c74e4ef4Sdan db close 408c815d14Sdrh #set effective [format %.5o [expr $permissions & ~$umask]] 41*baa34589Sdan set res "/[regsub {^00} $permissions {0.}]/" 42158931abSdrh if {$tcl_version>=8.7} { 43158931abSdrh regsub {^00} $permissions {0o} permissions 44158931abSdrh } 458c815d14Sdrh set effective $permissions 46c74e4ef4Sdan do_test journal3-1.2.$tn.1 { 47fda06befSmistachkin catch { forcedelete test.db-journal } 48c74e4ef4Sdan file attributes test.db -permissions $permissions 49c74e4ef4Sdan file attributes test.db -permissions 50*baa34589Sdan } $res 51c74e4ef4Sdan do_test journal3-1.2.$tn.2 { file exists test.db-journal } {0} 52c74e4ef4Sdan do_test journal3-1.2.$tn.3 { 53c74e4ef4Sdan sqlite3 db test.db 54c74e4ef4Sdan execsql { 55c74e4ef4Sdan BEGIN; 56c74e4ef4Sdan INSERT INTO tx DEFAULT VALUES; 57c74e4ef4Sdan } 58c74e4ef4Sdan file exists test.db-journal 59c74e4ef4Sdan } {1} 60c74e4ef4Sdan do_test journal3-1.2.$tn.4 { 61c74e4ef4Sdan file attr test.db-journal -perm 62*baa34589Sdan } $res 63c74e4ef4Sdan do_execsql_test journal3-1.2.$tn.5 { ROLLBACK } {} 64c74e4ef4Sdan } 65c74e4ef4Sdan 66c74e4ef4Sdan 67c74e4ef4Sdan} 68c74e4ef4Sdan 69c74e4ef4Sdanfinish_test 70