aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/atomic.test41
-rw-r--r--test/fallocate.test4
-rw-r--r--test/misc1.test42
-rw-r--r--test/permutations.test24
-rw-r--r--test/rollback.test1
-rw-r--r--test/syscall.test2
-rw-r--r--test/tester.tcl48
-rw-r--r--test/writecrash.test68
8 files changed, 208 insertions, 22 deletions
diff --git a/test/atomic.test b/test/atomic.test
new file mode 100644
index 000000000..6ce6debb7
--- /dev/null
+++ b/test/atomic.test
@@ -0,0 +1,41 @@
+# 2015-11-07
+#
+# 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 WITH clause.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set ::testprefix atomic
+
+db close
+if {[atomic_batch_write test.db]==0} {
+ puts "No f2fs atomic-batch-write support. Skipping tests..."
+ finish_test
+ return
+}
+
+reset_db
+
+do_execsql_test 1.0 {
+ CREATE TABLE t1(x, y);
+ BEGIN;
+ INSERT INTO t1 VALUES(1, 2);
+}
+
+do_test 1.1 { file exists test.db-journal } {0}
+
+do_execsql_test 1.2 {
+ COMMIT;
+}
+
+
+finish_test
diff --git a/test/fallocate.test b/test/fallocate.test
index f523c2cc4..63d88ea88 100644
--- a/test/fallocate.test
+++ b/test/fallocate.test
@@ -59,7 +59,9 @@ do_test fallocate-1.6 {
#
do_test fallocate-1.7 {
execsql { BEGIN; INSERT INTO t1 VALUES(1, 2); }
- if {[permutation] != "inmemory_journal"} {
+ if {[permutation] != "inmemory_journal"
+ && [permutation] != "atomic-batch-write"
+ } {
hexio_get_int [hexio_read test.db-journal 16 4]
} else {
set {} 1024
diff --git a/test/misc1.test b/test/misc1.test
index e646bfd09..be64a8f7a 100644
--- a/test/misc1.test
+++ b/test/misc1.test
@@ -479,26 +479,28 @@ ifcapable curdir {
# Make sure a database connection still works after changing the
# working directory.
#
-do_test misc1-14.1 {
- file mkdir tempdir
- cd tempdir
- execsql {BEGIN}
- file exists ./test.db-journal
-} {0}
-do_test misc1-14.2a {
- execsql {UPDATE t1 SET a=a||'x' WHERE 0}
- file exists ../test.db-journal
-} {0}
-do_test misc1-14.2b {
- execsql {UPDATE t1 SET a=a||'y' WHERE 1}
- file exists ../test.db-journal
-} {1}
-do_test misc1-14.3 {
- cd ..
- forcedelete tempdir
- execsql {COMMIT}
- file exists ./test.db-journal
-} {0}
+if {[atomic_batch_write test.db]==0} {
+ do_test misc1-14.1 {
+ file mkdir tempdir
+ cd tempdir
+ execsql {BEGIN}
+ file exists ./test.db-journal
+ } {0}
+ do_test misc1-14.2a {
+ execsql {UPDATE t1 SET a=a||'x' WHERE 0}
+ file exists ../test.db-journal
+ } {0}
+ do_test misc1-14.2b {
+ execsql {UPDATE t1 SET a=a||'y' WHERE 1}
+ file exists ../test.db-journal
+ } {1}
+ do_test misc1-14.3 {
+ cd ..
+ forcedelete tempdir
+ execsql {COMMIT}
+ file exists ./test.db-journal
+ } {0}
+}
}
# A failed create table should not leave the table in the internal
diff --git a/test/permutations.test b/test/permutations.test
index 59e30b519..bcd06c14b 100644
--- a/test/permutations.test
+++ b/test/permutations.test
@@ -389,6 +389,30 @@ test_suite "vfslog" -prefix "" -description {
wal* mmap*
]
+test_suite "atomic-batch-write" -prefix "" -description {
+ Like veryquick.test, but must be run on a file-system that supports
+ atomic-batch-writes. Tests that depend on the journal file being present
+ are omitted.
+} -files [
+ test_set $allquicktests -exclude *malloc* *ioerr* *fault* *bigfile* *_err* \
+ *fts5corrupt* *fts5big* *fts5aj* \
+ crash8.test delete_db.test \
+ exclusive.test journal3.test \
+ journal1.test \
+ jrnlmode.test jrnlmode2.test \
+ lock4.test pager1.test \
+ pager3.test sharedA.test \
+ symlink.test stmt.test \
+ sync.test sync2.test \
+ tempdb.test tkt3457.test \
+ vacuum5.test wal2.test \
+ walmode.test zerodamage.test
+] -initialize {
+ if {[atomic_batch_write test.db]==0} {
+ error "File system does NOT support atomic-batch-write"
+ }
+}
+
lappend ::testsuitelist xxx
#-------------------------------------------------------------------------
# Define the coverage related test suites:
diff --git a/test/rollback.test b/test/rollback.test
index 7abafece6..60a619031 100644
--- a/test/rollback.test
+++ b/test/rollback.test
@@ -82,6 +82,7 @@ do_test rollback-1.9 {
if {$tcl_platform(platform) == "unix"
&& [permutation] ne "onefile"
&& [permutation] ne "inmemory_journal"
+ && [permutation] ne "atomic-batch-write"
} {
do_test rollback-2.1 {
execsql {
diff --git a/test/syscall.test b/test/syscall.test
index 2532187b4..19313a5e6 100644
--- a/test/syscall.test
+++ b/test/syscall.test
@@ -61,7 +61,7 @@ foreach s {
fcntl read pread write pwrite fchmod fallocate
pread64 pwrite64 unlink openDirectory mkdir rmdir
statvfs fchown geteuid umask mmap munmap mremap
- getpagesize readlink lstat
+ getpagesize readlink lstat ioctl
} {
if {[test_syscall exists $s]} {lappend syscall_list $s}
}
diff --git a/test/tester.tcl b/test/tester.tcl
index dc6547d03..38c19701c 100644
--- a/test/tester.tcl
+++ b/test/tester.tcl
@@ -1608,6 +1608,54 @@ proc crashsql {args} {
lappend r $msg
}
+# crash_on_write ?-devchar DEVCHAR? CRASHDELAY SQL
+#
+proc crash_on_write {args} {
+
+ set nArg [llength $args]
+ if {$nArg<2 || $nArg%2} {
+ error "bad args: $args"
+ }
+ set zSql [lindex $args end]
+ set nDelay [lindex $args end-1]
+
+ set devchar {}
+ for {set ii 0} {$ii < $nArg-2} {incr ii 2} {
+ set opt [lindex $args $ii]
+ switch -- [lindex $args $ii] {
+ -devchar {
+ set devchar [lindex $args [expr $ii+1]]
+ }
+
+ default { error "unrecognized option: $opt" }
+ }
+ }
+
+ set f [open crash.tcl w]
+ puts $f "sqlite3_crash_on_write $nDelay"
+ puts $f "sqlite3_test_control_pending_byte $::sqlite_pending_byte"
+ puts $f "sqlite3 db test.db -vfs writecrash"
+ puts $f "db eval {$zSql}"
+ puts $f "set {} {}"
+
+ close $f
+ set r [catch {
+ exec [info nameofexec] crash.tcl >@stdout
+ } msg]
+
+ # Windows/ActiveState TCL returns a slightly different
+ # error message. We map that to the expected message
+ # so that we don't have to change all of the test
+ # cases.
+ if {$::tcl_platform(platform)=="windows"} {
+ if {$msg=="child killed: unknown signal"} {
+ set msg "child process exited abnormally"
+ }
+ }
+
+ lappend r $msg
+}
+
proc run_ioerr_prep {} {
set ::sqlite_io_error_pending 0
catch {db close}
diff --git a/test/writecrash.test b/test/writecrash.test
new file mode 100644
index 000000000..01bc4dbb5
--- /dev/null
+++ b/test/writecrash.test
@@ -0,0 +1,68 @@
+# 2009 January 8
+#
+# 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.
+#
+#***********************************************************************
+#
+# Test the outcome of a writer crashing within a call to the VFS
+# xWrite function.
+#
+
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix writecrash
+
+do_not_use_codec
+
+
+if {$tcl_platform(platform)=="windows"} {
+ finish_test
+ return
+}
+
+do_execsql_test 1.0 {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b BLOB UNIQUE);
+ WITH s(i) AS (
+ VALUES(1) UNION ALL SELECT i+1 FROM s WHERE i<100
+ )
+ INSERT INTO t1 SELECT NULL, randomblob(900) FROM s;
+} {}
+
+set bGo 1
+for {set tn 1} {$bGo} {incr tn} {
+
+db close
+sqlite3 db test.db
+
+ do_test 1.$tn.1 {
+ set res [crash_on_write $tn {
+ UPDATE t1 SET b = randomblob(899) WHERE (a%3)==0
+ }]
+ set bGo 0
+ if {[string match {1 {child killed:*}} $res]} {
+ set res {0 {}}
+ set bGo 1
+ }
+ set res
+ } {0 {}}
+
+#db close
+#sqlite3 db test.db
+
+ do_execsql_test 1.$tn.2 { PRAGMA integrity_check } {ok}
+
+db close
+sqlite3 db test.db
+
+ do_execsql_test 1.$tn.3 { PRAGMA integrity_check } {ok}
+}
+
+
+
+finish_test