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 #***********************************************************************
12 # This file contains tests for the "truncate" option in the multiplexor.
15 set testdir [file dirname $argv0]
16 source $testdir/tester.tcl
17 set ::testprefix multiplex4
21 sqlite3_multiplex_initialize {} 0
23 # delete all filesl with the base name of $basename
25 proc multiplex_delete_db {basename} {
26 foreach file [glob -nocomplain $basename.*] {
31 # Return a sorted list of all files with the base name of $basename.
32 # Except, delete all text from the end of $basename through the NNN
33 # suffix on the end of the filename.
35 proc multiplex_file_list {basename} {
37 foreach file [glob -nocomplain $basename.*] {
38 regsub "^$basename\\..*(\\d\\d\\d)\$" $file $basename.\\1 file
44 do_test multiplex4-1.0 {
45 multiplex_delete_db mx4test
46 sqlite3 db {file:mx4test.db?chunksize=10&truncate=1} -uri 1 -vfs multiplex
49 INSERT INTO t1(x) VALUES(randomblob(250000));
51 multiplex_file_list mx4test
52 } {mx4test.001 mx4test.db}
54 do_test multiplex4-1.1 {
59 multiplex_file_list mx4test
62 do_test multiplex4-1.2 {
63 db eval {PRAGMA multiplex_truncate}
65 do_test multiplex4-1.3 {
66 db eval {PRAGMA multiplex_truncate=off}
68 do_test multiplex4-1.4 {
69 db eval {PRAGMA multiplex_truncate}
71 do_test multiplex4-1.5 {
72 db eval {PRAGMA multiplex_truncate=on}
74 do_test multiplex4-1.6 {
75 db eval {PRAGMA multiplex_truncate}
77 do_test multiplex4-1.7 {
78 db eval {PRAGMA multiplex_truncate=0}
80 do_test multiplex4-1.8 {
81 db eval {PRAGMA multiplex_truncate=1}
83 do_test multiplex4-1.9 {
84 db eval {PRAGMA multiplex_truncate=0}
87 do_test multiplex4-1.10 {
89 INSERT INTO t1(x) VALUES(randomblob(250000));
91 multiplex_file_list mx4test
92 } {mx4test.001 mx4test.db}
94 do_test multiplex4-1.11 {
99 multiplex_file_list mx4test
100 } {mx4test.001 mx4test.db}
102 do_test multiplex4-1.12 {
104 PRAGMA multiplex_truncate=ON;
108 multiplex_file_list mx4test
112 forcedelete mx4test.db
113 sqlite3_multiplex_shutdown