Merge sqlite-release(3.30.1) into prerelease-integration
[sqlcipher.git] / test / journal3.test
blob9dc7aa25f87782b18410eab954131a949a94c7a4
1 # 2010 July 15
3 # The author disclaims copyright to this source code.  In place of
4 # a legal notice, here is a blessing:
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.
10 #***********************************************************************
11 # This file implements regression tests for SQLite library.
14 set testdir [file dirname $argv0]
15 source $testdir/tester.tcl
16 source $testdir/lock_common.tcl
17 source $testdir/malloc_common.tcl
19 #-------------------------------------------------------------------------
20 # If a connection is required to create a journal file, it creates it with 
21 # the same file-system permissions as the database file itself. Test this.
23 if {$::tcl_platform(platform) == "unix"
24  && [atomic_batch_write test.db]==0
25 } {
27   # Changed on 2012-02-13:  umask is deliberately ignored for -wal, -journal,
28   # and -shm files.
29   #set umask [exec /bin/sh -c umask]
30   faultsim_delete_and_reopen
31   do_test journal3-1.1 { execsql { CREATE TABLE tx(y, z) } } {}
33   foreach {tn permissions} {
34    1 00644
35    2 00666
36    3 00600
37    4 00755
38   } {
39     db close
40     #set effective [format %.5o [expr $permissions & ~$umask]]
41     if {$tcl_version>=8.7} {
42        regsub {^00} $permissions {0o} permissions
43     }
44     set effective $permissions
45     do_test journal3-1.2.$tn.1 {
46       catch { forcedelete test.db-journal }
47       file attributes test.db -permissions $permissions
48       file attributes test.db -permissions
49     } $permissions
50     do_test journal3-1.2.$tn.2 { file exists test.db-journal } {0}
51     do_test journal3-1.2.$tn.3 {
52       sqlite3 db test.db
53       execsql { 
54         BEGIN;
55           INSERT INTO tx DEFAULT VALUES;
56       }
57       file exists test.db-journal
58     } {1}
59     do_test journal3-1.2.$tn.4 {
60       file attr test.db-journal -perm
61     } $effective
62     do_execsql_test journal3-1.2.$tn.5 { ROLLBACK } {}
63   }
68 finish_test