0
0
mirror of https://github.com/sqlite/sqlite.git synced 2024-11-25 00:49:41 +01:00
sqlite/ext/ota/otafault2.test

59 lines
1.5 KiB
Plaintext
Raw Normal View History

# 2014 October 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.
#
#***********************************************************************
#
if {![info exists testdir]} {
set testdir [file join [file dirname [info script]] .. .. test]
}
source $testdir/tester.tcl
source $testdir/malloc_common.tcl
set ::testprefix otafault2
forcedelete ota.db
do_execsql_test 1.0 {
CREATE TABLE target(x UNIQUE, y, z, PRIMARY KEY(y));
INSERT INTO target VALUES(1, 2, 3);
INSERT INTO target VALUES(4, 5, 6);
ATTACH 'ota.db' AS ota;
CREATE TABLE ota.data_target(x, y, z, ota_control);
INSERT INTO data_target VALUES(7, 8, 9, 0);
INSERT INTO data_target VALUES(1, 11, 12, 0);
DETACH ota;
}
db close
forcecopy test.db test.db-bak
forcecopy ota.db ota.db-bak
do_faultsim_test 1 -faults oom* -prep {
forcecopy test.db-bak test.db
forcecopy ota.db-bak ota.db
forcedelete test.db-oal test.db-wal ota.db-journal
sqlite3ota ota test.db ota.db
} -body {
while {[ota step]=="SQLITE_OK"} { }
ota close
} -test {
faultsim_test_result \
{1 {SQLITE_CONSTRAINT - UNIQUE constraint failed: target.x}} \
{1 SQLITE_CONSTRAINT} \
{1 SQLITE_NOMEM} \
{1 {SQLITE_NOMEM - unable to open a temporary database file for storing temporary tables}} \
{1 {SQLITE_NOMEM - out of memory}}
}
finish_test