CoolFace
Modelpublic

AryaWu/sqlite

sourceHugging Faceupdated 9mo agoView on Hugging Face
0likes
journal3.test70 linesDownload Raw Back to test
1# 2010 July 152#3# The author disclaims copyright to this source code.  In place of4# 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.tcl16source $testdir/lock_common.tcl17source $testdir/malloc_common.tcl18 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(os) ne "Windows NT"24 && [atomic_batch_write test.db]==025} {26 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_reopen31  do_test journal3-1.1 { execsql { CREATE TABLE tx(y, z) } } {}32 33  foreach {tn permissions} {34   1 0064435   2 0066636   3 0060037   4 0075538  } {39    db close40    #set effective [format %.5o [expr $permissions & ~$umask]]41    set res "/[regsub {^00} $permissions {0.}]/"42    if {$tcl_version>=8.7} {43       regsub {^00} $permissions {0o} permissions44    }45    set effective $permissions46    do_test journal3-1.2.$tn.1 {47      catch { forcedelete test.db-journal }48      file attributes test.db -permissions $permissions49      file attributes test.db -permissions50    } $res51    do_test journal3-1.2.$tn.2 { file exists test.db-journal } {0}52    do_test journal3-1.2.$tn.3 {53      sqlite3 db test.db54      execsql { 55        BEGIN;56          INSERT INTO tx DEFAULT VALUES;57      }58      file exists test.db-journal59    } {1}60    do_test journal3-1.2.$tn.4 {61      file attr test.db-journal -perm62    } $res63    do_execsql_test journal3-1.2.$tn.5 { ROLLBACK } {}64  }65 66 67}68 69finish_test70