journal3.test 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. # 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. set testdir [file dirname $argv0]
  14. source $testdir/tester.tcl
  15. source $testdir/lock_common.tcl
  16. source $testdir/malloc_common.tcl
  17. #-------------------------------------------------------------------------
  18. # If a connection is required to create a journal file, it creates it with
  19. # the same file-system permissions as the database file itself. Test this.
  20. #
  21. if {$::tcl_platform(platform) == "unix"} {
  22. # Changed on 2012-02-13: umask is deliberately ignored for -wal, -journal,
  23. # and -shm files.
  24. #set umask [exec /bin/sh -c umask]
  25. faultsim_delete_and_reopen
  26. do_test journal3-1.1 { execsql { CREATE TABLE tx(y, z) } } {}
  27. foreach {tn permissions} {
  28. 1 00644
  29. 2 00666
  30. 3 00600
  31. 4 00755
  32. } {
  33. db close
  34. #set effective [format %.5o [expr $permissions & ~$umask]]
  35. set effective $permissions
  36. do_test journal3-1.2.$tn.1 {
  37. catch { forcedelete test.db-journal }
  38. file attributes test.db -permissions $permissions
  39. file attributes test.db -permissions
  40. } $permissions
  41. do_test journal3-1.2.$tn.2 { file exists test.db-journal } {0}
  42. do_test journal3-1.2.$tn.3 {
  43. sqlite3 db test.db
  44. execsql {
  45. BEGIN;
  46. INSERT INTO tx DEFAULT VALUES;
  47. }
  48. file exists test.db-journal
  49. } {1}
  50. do_test journal3-1.2.$tn.4 {
  51. file attr test.db-journal -perm
  52. } $effective
  53. do_execsql_test journal3-1.2.$tn.5 { ROLLBACK } {}
  54. }
  55. }
  56. finish_test