CoolFace
Modelpublic

AryaWu/sqlite

sourceHugging Faceupdated 9mo agoView on Hugging Face
0likes
ioerr6.test92 linesDownload Raw Back to test
1# 2012 December 182#3# The author disclaims copyright to this source code.  In place of4# a legal notice, here is a blessing:5#6#    May you do good and not evil.7#    May you find forgiveness for yourself and forgive others.8#    May you share freely, never taking more than you give.9#10#***********************************************************************11#12 13set testdir [file dirname $argv0]14source $testdir/tester.tcl15source $testdir/malloc_common.tcl16set ::testprefix ioerr617 18ifcapable !atomicwrite {19  puts "skipping tests - not compiled with SQLITE_ENABLE_ATOMIC_WRITE..."20  finish_test21  return22}23 24if {[permutation]=="inmemory_journal"} {25  # These tests will not work with in-memory journals (as persistent VFS26  # errors commencing after a transaction has started to write to the db27  # cannot be recovered from).28  finish_test29  return30}31 32faultsim_save_and_close33 34do_test 1.1 {35  testvfs shmfault -default true36  shmfault devchar atomic37  sqlite3 db test.db38  execsql {39    CREATE TABLE t1(a, b);40    CREATE INDEX i1 ON t1(a, b);41    INSERT INTO t1 VALUES(1, 2);42    INSERT INTO t1 VALUES(2, 4);43    INSERT INTO t1 VALUES(3, 6);44    INSERT INTO t1 VALUES(4, 8);45  }46 47  # Cause the first call to xWrite() to fail with SQLITE_FULL.48  shmfault full 2 149  catchsql { INSERT INTO t1 VALUES(5, 10) }50} {1 {database or disk is full}}51 52do_test 1.2 {53  execsql { PRAGMA integrity_check }54} {ok}55 56db close57shmfault delete58 59do_faultsim_test 2 -faults full* -prep {60  shmfault devchar atomic61  faultsim_restore62  sqlite3 db test.db63} -body {64  db eval {65    CREATE TABLE t1(x PRIMARY KEY);66    INSERT INTO t1 VALUES('abc');67  }68} -test {69  set res [db one { PRAGMA integrity_check }]70  if {$res != "ok"} {71    error "integrity check: $res"72  }73}74 75do_faultsim_test 3 -faults full* -prep {76  shmfault devchar atomic77  faultsim_restore78  sqlite3 db test.db79} -body {80  db eval {81    CREATE TABLE t1(x);82    CREATE TABLE t2(x);83  }84} -test {85  db eval { CREATE TABLE t3(x) }86  if {[db one { PRAGMA integrity_check }] != "ok"} {87    error "integrity check failed"88  }89}90 91finish_test92