Debian Codegraph @

test/cksumvfs.test

raw
1 # 2024 March 19
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 #
12
13 set testdir [file dirname $argv0]
14 source $testdir/tester.tcl
15 set testprefix cksumvfs
16
17
18 db close
19 sqlite3_shutdown
20 #test_sqlite3_log logfunc
21 sqlite3_initialize
22
23 proc logfunc {args} {
24 puts "LOG: $args"
25 }
26
27 sqlite3_register_cksumvfs
28 sqlite3 db test.db
29
30 file_control_reservebytes db 8
31 execsql {
32 PRAGMA page_size = 4096;
33 }
34
35 set text [db one "SELECT hex(randomblob(5000))"]
36
37 do_execsql_test 1.0 {
38 CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c);
39 INSERT INTO t1 VALUES(1, $text, NULL);
40 }
41
42 do_execsql_test 1.1 {
43 SELECT * FROM t1;
44 } [list 1 $text {}]
45
46 do_execsql_test 1.2 {
47 DELETE FROM t1;
48 }
49
50 do_test 1.3 {
51 execsql BEGIN
52 for {set ii 1500} {$ii < 10000} {incr ii} {
53 execsql { INSERT INTO t1 VALUES(NULL, randomblob(5000), randomblob($ii)) }
54 }
55 execsql COMMIT
56 } {}
57
58 do_execsql_test 1.4 {
59 SELECT count(b) FROM t1
60 } {8500}
61
62 do_execsql_test 1.5 {
63 PRAGMA journal_mode = wal;
64 DELETE FROM t1;
65 } {wal}
66
67 do_execsql_test 1.6 {
68 PRAGMA wal_checkpoint;
69 } {/0 # #/}
70
71 do_execsql_test 1.7 {
72 WITH s(i) AS (
73 VALUES(1) UNION ALL SELECT i+1 FROM s WHERE i<100
74 )
75 INSERT INTO t1 SELECT NULL, randomblob(5000), randomblob(i) FROM s;
76 SELECT count(*) FROM t1;
77 } {100}
78
79 db_save_and_close
80 db_restore_and_reopen
81
82 do_execsql_test 1.8 {
83 SELECT count(*) FROM t1;
84 } {100}
85
86 db close
87 sqlite3 db test.db
88
89 do_execsql_test 1.9 {
90 SELECT count(*) FROM t1;
91 } {100}
92
93 finish_test