blob: 939cc27c7084b029a8173d69e9881b5b5bcd2609 [file] [log] [blame]
danc74e4ef2010-07-15 14:59:37 +00001# 2010 July 15
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# This file implements regression tests for SQLite library.
12#
13
14set testdir [file dirname $argv0]
15source $testdir/tester.tcl
16source $testdir/lock_common.tcl
17source $testdir/malloc_common.tcl
18
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.
22#
23if {$::tcl_platform(platform) == "unix"} {
24
drh8c815d12012-02-13 20:16:37 +000025 # Changed on 2012-02-13: umask is deliberately ignored for -wal, -journal,
26 # and -shm files.
27 #set umask [exec /bin/sh -c umask]
danc74e4ef2010-07-15 14:59:37 +000028 faultsim_delete_and_reopen
29 do_test journal3-1.1 { execsql { CREATE TABLE tx(y, z) } } {}
30
31 foreach {tn permissions} {
32 1 00644
33 2 00666
34 3 00600
35 4 00755
36 } {
37 db close
drh8c815d12012-02-13 20:16:37 +000038 #set effective [format %.5o [expr $permissions & ~$umask]]
39 set effective $permissions
danc74e4ef2010-07-15 14:59:37 +000040 do_test journal3-1.2.$tn.1 {
mistachkinfda06be2011-08-02 00:57:34 +000041 catch { forcedelete test.db-journal }
danc74e4ef2010-07-15 14:59:37 +000042 file attributes test.db -permissions $permissions
43 file attributes test.db -permissions
44 } $permissions
45 do_test journal3-1.2.$tn.2 { file exists test.db-journal } {0}
46 do_test journal3-1.2.$tn.3 {
47 sqlite3 db test.db
48 execsql {
49 BEGIN;
50 INSERT INTO tx DEFAULT VALUES;
51 }
52 file exists test.db-journal
53 } {1}
54 do_test journal3-1.2.$tn.4 {
55 file attr test.db-journal -perm
56 } $effective
57 do_execsql_test journal3-1.2.$tn.5 { ROLLBACK } {}
58 }
59
60
61}
62
63finish_test