]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Add very simple test cases for backup and VACUUM of WAL databases. More to come.
authordan <dan@noemail.net>
Fri, 23 Apr 2010 11:44:40 +0000 (11:44 +0000)
committerdan <dan@noemail.net>
Fri, 23 Apr 2010 11:44:40 +0000 (11:44 +0000)
FossilOrigin-Name: 1077d8130b8ed5716ad73f78382270909d347963

manifest
manifest.uuid
test/walbak.test [new file with mode: 0644]

index b451c49511738744be40177cad1808237646f935..49b2e5bcc4a9aa9d063c1b5cbe2c8d9714e4dbac 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Create\sa\sversion\sof\sthe\slog\schecksummer\sthat\sworks\son\sbig-endian\splatforms.\sRemove\sthe\s512KB\ssize\slimit\son\sthe\slog-summary.
-D 2010-04-22T19:14:14
+C Add\svery\ssimple\stest\scases\sfor\sbackup\sand\sVACUUM\sof\sWAL\sdatabases.\sMore\sto\scome.
+D 2010-04-23T11:44:41
 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
 F Makefile.in 4f2f967b7e58a35bb74fb7ec8ae90e0f4ca7868b
 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -759,6 +759,7 @@ F test/vtab_alter.test 9e374885248f69e251bdaacf480b04a197f125e5
 F test/vtab_err.test 0d4d8eb4def1d053ac7c5050df3024fd47a3fbd8
 F test/vtab_shared.test 0eff9ce4f19facbe0a3e693f6c14b80711a4222d
 F test/wal.test fcb5ec1fbec08c1165b6974f126056f2b4cead49
+F test/walbak.test 3aecf824ee6433bd34673336623c4990aa1346ba
 F test/walcrash.test f022cee7eb7baa5fb898726120a6a4073dd831d1
 F test/walhook.test 76a559e262f0715c470bade4a8d8333035f8ee47
 F test/walmode.test c2f4e30ad64910b2d8faf6cf4e940b3f201b41df
@@ -807,7 +808,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
 F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
-P 1236318477787a612f02cc98caf2931bd2e99d94
-R 2eba2ad72744173c34347863efb93bd2
+P 5d6d4423d1def39bd2424703120aa985085c3f8e
+R 7813072bd3855cfe2a094b15eff01c69
 U dan
-Z b18c4f1fb26d4b385c95cfa4edf72422
+Z f898bd1b5727c5103088c594c0575550
index 815632c84ebfa0d14bb0ba097ca7690400ee8d96..b5381319c7bd32bf88649fd58d1592803227d842 100644 (file)
@@ -1 +1 @@
-5d6d4423d1def39bd2424703120aa985085c3f8e
\ No newline at end of file
+1077d8130b8ed5716ad73f78382270909d347963
\ No newline at end of file
diff --git a/test/walbak.test b/test/walbak.test
new file mode 100644 (file)
index 0000000..f4998ac
--- /dev/null
@@ -0,0 +1,86 @@
+# 2010 April 22
+#
+# The author disclaims copyright to this source code.  In place of
+# a legal notice, here is a blessing:
+#
+#    May you do good and not evil.
+#    May you find forgiveness for yourself and forgive others.
+#    May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.  The
+# focus of this file is testing the operation of the library in
+# "PRAGMA journal_mode=WAL" mode.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+proc log_file_size {nFrame pgsz} {
+  expr {12 + ($pgsz+16)*$nFrame}
+}
+
+# Make sure a simple backup from a WAL database works.
+#
+do_test walbak-1.0 {
+  execsql { 
+    PRAGMA synchronous = NORMAL;
+    PRAGMA page_size = 1024;
+    PRAGMA auto_vacuum = 0;
+    PRAGMA journal_mode = wal;
+    BEGIN;
+      CREATE TABLE t1(a PRIMARY KEY, b);
+      INSERT INTO t1 VALUES('I', 'one');
+    COMMIT;
+  }
+} {wal}
+do_test walbak-1.1 {
+  file delete -force bak.db bak.db-journal bak.db-wal
+  db backup bak.db
+  file size bak.db
+} [expr 3*1024]
+do_test walbak-1.2 {
+  sqlite3 db2 bak.db
+  execsql { 
+    SELECT * FROM t1;
+    PRAGMA main.journal_mode;
+  } db2
+} {I one wal}
+do_test walbak-1.3 {
+  execsql { PRAGMA integrity_check } db2
+} {ok}
+db2 close
+
+# Try a VACUUM on a WAL database.
+#
+do_test walbak-2.1 {
+  execsql { 
+    VACUUM;
+    PRAGMA main.journal_mode;
+  }
+} {wal}
+do_test walbak-2.2 {
+  list [file size test.db] [file size test.db-wal]
+} [list 1024 [log_file_size 6 1024]]
+do_test walbak-2.3 {
+  execsql { PRAGMA checkpoint }
+  list [file size test.db] [file size test.db-wal]
+} [list [expr 3*1024] [log_file_size 6 1024]]
+do_test walbak-2.4 {
+  execsql { 
+    CREATE TABLE t2(a, b);
+    INSERT INTO t2 SELECT * FROM t1;
+    DROP TABLE t1;
+  }
+  list [file size test.db] [file size test.db-wal]
+} [list [expr 3*1024] [log_file_size 6 1024]]
+do_test walbak-2.5 {
+  execsql { VACUUM }
+  list [file size test.db] [file size test.db-wal]
+} [list [expr 3*1024] [log_file_size 8 1024]]
+do_test walbak-2.6 {
+  execsql { PRAGMA checkpoint }
+  list [file size test.db] [file size test.db-wal]
+} [list [expr 2*1024] [log_file_size 8 1024]]
+
+finish_test