ioerr.test 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. # 2001 October 12
  2. #
  3. # The author disclaims copyright to this source code. In place of
  4. # 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. # This file implements regression tests for SQLite library. The
  12. # focus of this file is testing for correct handling of I/O errors
  13. # such as writes failing because the disk is full.
  14. #
  15. # The tests in this file use special facilities that are only
  16. # available in the SQLite test fixture.
  17. #
  18. # $Id: ioerr.test,v 1.1 2001/10/12 17:30:05 drh Exp $
  19. set testdir [file dirname $argv0]
  20. source $testdir/tester.tcl
  21. set ::go 1
  22. for {set n 1} {$go} {incr n} {
  23. do_test ioerr-1.$n.1 {
  24. set ::sqlite_io_error_pending 0
  25. db close
  26. catch {file delete -force test.db}
  27. sqlite db test.db
  28. execsql {SELECT * FROM sqlite_master}
  29. } {}
  30. do_test ioerr-1.$n.2 [subst {
  31. set ::sqlite_io_error_pending $n
  32. }] $n
  33. do_test ioerr-1.$n.3 {
  34. set r [catch {db eval {
  35. CREATE TABLE t1(a,b,c);
  36. SELECT * FROM sqlite_master;
  37. BEGIN TRANSACTION;
  38. INSERT INTO t1 VALUES(1,2,3);
  39. INSERT INTO t1 VALUES(4,5,6);
  40. ROLLBACK;
  41. SELECT * FROM t1;
  42. BEGIN TRANSACTION;
  43. INSERT INTO t1 VALUES(1,2,3);
  44. INSERT INTO t1 VALUES(4,5,6);
  45. COMMIT;
  46. SELECT * FROM t1;
  47. DELETE FROM t1 WHERE a<100;
  48. }} msg]
  49. # if {$r} {puts $msg}
  50. set ::go [expr {$::sqlite_io_error_pending<=0}]
  51. expr {$::sqlite_io_error_pending>0 || $r!=0}
  52. } {1}
  53. }
  54. set ::sqlite_io_error_pending 0
  55. finish_test