mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-07 02:42:48 +03:00
Account for a malloc failure in the asynchronous writer thread in test_async.c (CVS 3096)
FossilOrigin-Name: 2f2a8a69cb380dc30b85a792c369020fec3c79a5
This commit is contained in:
121
test/async2.test
121
test/async2.test
@@ -5,7 +5,7 @@
|
||||
#
|
||||
#***********************************************************************
|
||||
#
|
||||
# $Id: async2.test,v 1.2 2006/02/14 13:48:34 danielk1977 Exp $
|
||||
# $Id: async2.test,v 1.3 2006/02/14 14:02:08 danielk1977 Exp $
|
||||
|
||||
|
||||
if {[info commands sqlite3async_enable]==""} {
|
||||
@@ -41,65 +41,74 @@ set sql_script {
|
||||
|
||||
db close
|
||||
|
||||
set ::go 1
|
||||
for {set n 3} {$::go} {incr n} {
|
||||
set ::sqlite_io_error_pending 0
|
||||
file delete -force test.db test.db-journal
|
||||
sqlite3 db test.db
|
||||
execsql $::setup_script
|
||||
db close
|
||||
|
||||
sqlite3async_enable 1
|
||||
sqlite3 db test.db
|
||||
execsql $::sql_script
|
||||
db close
|
||||
foreach err [list ioerr malloc] {
|
||||
set ::go 1
|
||||
for {set n 1} {$::go} {incr n} {
|
||||
set ::sqlite_io_error_pending 0
|
||||
sqlite_malloc_fail 0
|
||||
file delete -force test.db test.db-journal
|
||||
sqlite3 db test.db
|
||||
execsql $::setup_script
|
||||
db close
|
||||
|
||||
sqlite3async_enable 1
|
||||
sqlite3 db test.db
|
||||
execsql $::sql_script
|
||||
db close
|
||||
|
||||
switch -- $err {
|
||||
ioerr { set ::sqlite_io_error_pending $n }
|
||||
malloc { sqlite_malloc_fail $n }
|
||||
}
|
||||
sqlite3async_halt idle
|
||||
sqlite3async_start
|
||||
sqlite3async_wait
|
||||
|
||||
set ::sqlite_io_error_pending 0
|
||||
sqlite_malloc_fail 0
|
||||
|
||||
set ::sqlite_io_error_pending $n
|
||||
sqlite3async_halt idle
|
||||
sqlite3async_start
|
||||
sqlite3async_wait
|
||||
|
||||
set ::sqlite_io_error_pending 0
|
||||
sqlite3 db test.db
|
||||
set c [db eval {SELECT c FROM counter LIMIT 1}]
|
||||
switch -- $c {
|
||||
1 {
|
||||
do_test async-ioerr-1.1.$n {
|
||||
execsql {
|
||||
SELECT name FROM sqlite_master;
|
||||
}
|
||||
} {counter}
|
||||
}
|
||||
2 {
|
||||
do_test async-ioerr-1.2.$n.1 {
|
||||
execsql {
|
||||
SELECT * FROM t1;
|
||||
}
|
||||
} {}
|
||||
do_test async-ioerr-1.2.$n.2 {
|
||||
execsql {
|
||||
SELECT * FROM t2;
|
||||
}
|
||||
} {}
|
||||
}
|
||||
3 {
|
||||
do_test async-ioerr-1.3.$n.1 {
|
||||
execsql {
|
||||
SELECT * FROM t1;
|
||||
}
|
||||
} {abcdefghij four score}
|
||||
do_test async-ioerr-1.3.$n.2 {
|
||||
execsql {
|
||||
SELECT * FROM t2;
|
||||
}
|
||||
} {klmnopqrst and seven}
|
||||
}
|
||||
FIN {
|
||||
set ::go 0
|
||||
sqlite3 db test.db
|
||||
set c [db eval {SELECT c FROM counter LIMIT 1}]
|
||||
switch -- $c {
|
||||
1 {
|
||||
do_test async-$err-1.1.$n {
|
||||
execsql {
|
||||
SELECT name FROM sqlite_master;
|
||||
}
|
||||
} {counter}
|
||||
}
|
||||
2 {
|
||||
do_test async-$err-1.2.$n.1 {
|
||||
execsql {
|
||||
SELECT * FROM t1;
|
||||
}
|
||||
} {}
|
||||
do_test async-$err-1.2.$n.2 {
|
||||
execsql {
|
||||
SELECT * FROM t2;
|
||||
}
|
||||
} {}
|
||||
}
|
||||
3 {
|
||||
do_test async-$err-1.3.$n.1 {
|
||||
execsql {
|
||||
SELECT * FROM t1;
|
||||
}
|
||||
} {abcdefghij four score}
|
||||
do_test async-$err-1.3.$n.2 {
|
||||
execsql {
|
||||
SELECT * FROM t2;
|
||||
}
|
||||
} {klmnopqrst and seven}
|
||||
}
|
||||
FIN {
|
||||
set ::go 0
|
||||
}
|
||||
}
|
||||
|
||||
sqlite3async_enable 0
|
||||
}
|
||||
|
||||
sqlite3async_enable 0
|
||||
}
|
||||
|
||||
catch {db close}
|
||||
|
Reference in New Issue
Block a user