aboutsummaryrefslogtreecommitdiff
path: root/test/sysfault.test
diff options
context:
space:
mode:
authordan <dan@noemail.net>2011-03-30 19:08:03 +0000
committerdan <dan@noemail.net>2011-03-30 19:08:03 +0000
commit661d71af8c1a47ebef22904e44cb9bce3b81bc3e (patch)
tree0212c8d23c1cf55fde94a290f8901bb98fa154dd /test/sysfault.test
parentf6cf1ffb390cf840cbfdc8de8308755a5bc72d3f (diff)
downloadsqlite-661d71af8c1a47ebef22904e44cb9bce3b81bc3e.tar.gz
sqlite-661d71af8c1a47ebef22904e44cb9bce3b81bc3e.zip
Further tests for os_unix.c.
FossilOrigin-Name: a84f7711949ea3885b0e36e48118d2c76a8a5b82
Diffstat (limited to 'test/sysfault.test')
-rw-r--r--test/sysfault.test87
1 files changed, 84 insertions, 3 deletions
diff --git a/test/sysfault.test b/test/sysfault.test
index f6d1eabbc..c8c6f512f 100644
--- a/test/sysfault.test
+++ b/test/sysfault.test
@@ -66,7 +66,11 @@ do_faultsim_test 1 -faults vfsfault-* -prep {
{1 {attempt to write a readonly database}}
}
-# Errors in the fstat() function when opening and writing a file.
+#-------------------------------------------------------------------------
+# Errors in the fstat() function when opening and writing a file. Cases
+# where fstat() fails and sets errno to ENOMEM and EOVERFLOW are both
+# tested. EOVERFLOW is interpreted as meaning that a file on disk is
+# too large to be opened by the OS.
#
foreach {tn errno errlist} {
1 ENOMEM {{disk I/O error}}
@@ -86,11 +90,56 @@ foreach {tn errno errlist} {
}
#-------------------------------------------------------------------------
+# Various errors in locking functions.
+#
+foreach vfs {unix unix-excl} {
+ foreach {tn errno errlist} {
+ 1 EAGAIN {{database is locked}}
+ 2 ETIMEDOUT {{database is locked}}
+ 3 EBUSY {{database is locked}}
+ 4 EINTR {{database is locked}}
+ 5 ENOLCK {{database is locked}}
+ 6 EACCES {{database is locked}}
+ 7 EPERM {{access permission denied}}
+ 8 EDEADLK {{disk I/O error}}
+ 9 ENOMEM {{disk I/O error}}
+ } {
+ proc vfsfault_install {} { test_syscall install fcntl }
+ set errs [list]
+ foreach e $errlist { lappend errs [list 1 $e] }
+
+ set body [string map [list %VFS% $vfs] {
+ sqlite3 db test.db
+ db eval {
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, 2);
+ }
+ set fd [open test.db-journal w]
+ puts $fd "hello world"
+ close $fd
+ sqlite3 db test.db -vfs %VFS%
+ db eval {
+ SELECT * FROM t1;
+ }
+ }]
+
+ do_faultsim_test 1.3.$vfs.$tn -faults vfsfault-* -prep {
+ faultsim_restore
+ } -body "
+ test_syscall errno fcntl $errno
+ $body
+ " -test "
+ faultsim_test_result {0 {1 2}} $errs
+ "
+ }
+}
+
+#-------------------------------------------------------------------------
# Check that a single EINTR error does not affect processing.
#
proc vfsfault_install {} {
test_syscall reset
- test_syscall install {open ftruncate close}
+ test_syscall install {open ftruncate close read pread pread64 write fallocate}
}
forcedelete test.db test.db2
@@ -113,16 +162,25 @@ do_faultsim_test 2.1 -faults vfsfault-transient -prep {
test_syscall errno open EINTR
test_syscall errno ftruncate EINTR
test_syscall errno close EINTR
+ test_syscall errno read EINTR
+ test_syscall errno pread EINTR
+ test_syscall errno pread64 EINTR
+ test_syscall errno write EINTR
+ test_syscall errno fallocate EINTR
sqlite3 db test.db
+ file_control_chunksize_test db main 8192
+
set res [db eval {
ATTACH 'test.db2' AS 'aux';
SELECT * FROM t1;
PRAGMA journal_mode = truncate;
BEGIN;
INSERT INTO t1 VALUES('jkl', 'mno', 'pqr');
+ INSERT INTO t1 VALUES(randomblob(10000), 0, 0);
UPDATE t2 SET x = 2;
COMMIT;
+ DELETE FROM t1 WHERE length(a)>3;
SELECT * FROM t1;
SELECT * FROM t2;
}]
@@ -159,8 +217,31 @@ do_faultsim_test 2.2 -faults vfsfault-* -prep {
}
#-------------------------------------------------------------------------
-#
+proc vfsfault_install {} {
+ test_syscall reset
+ test_syscall install {fstat fallocate}
+}
+do_faultsim_test 3 -faults vfsfault-* -prep {
+ faultsim_delete_and_reopen
+ file_control_chunksize_test db main 8192
+ execsql {
+ CREATE TABLE t1(a, b);
+ BEGIN;
+ SELECT * FROM t1;
+ }
+} -body {
+ test_syscall errno fstat EIO
+ test_syscall errno fallocate EIO
+
+ execsql {
+ INSERT INTO t1 VALUES(randomblob(10000), randomblob(10000));
+ SELECT length(a) + length(b) FROM t1;
+ COMMIT;
+ }
+} -test {
+ faultsim_test_result {0 20000}
+}
finish_test