SQLite

Check-in [5aef5b0dd8]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix test instrumentation problems on shared_err.test. (CVS 4728)
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 5aef5b0dd8e44a56f84fbc6f843016bca5101987
User & Date: drh 2008-01-18 17:03:33.000
Context
2008-01-19
03:35
Cleanup and simplification of constraint processing. Simplifications to the VM for better test coverage. (CVS 4729) (check-in: d9ebe9d78c user: drh tags: trunk)
2008-01-18
17:03
Fix test instrumentation problems on shared_err.test. (CVS 4728) (check-in: 5aef5b0dd8 user: drh tags: trunk)
14:17
Remove an absolute path from crash5.test. (CVS 4727) (check-in: 42d8a37755 user: danielk1977 tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to test/malloc_common.tcl.
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#    May you share freely, never taking more than you give.
#
#***********************************************************************
#
# This file contains common code used by many different malloc tests
# within the test suite.
#
# $Id: malloc_common.tcl,v 1.10 2008/01/16 17:46:38 drh Exp $

# If we did not compile with malloc testing enabled, then do nothing.
#
ifcapable !memdebug {
  return 0
}








|







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#    May you share freely, never taking more than you give.
#
#***********************************************************************
#
# This file contains common code used by many different malloc tests
# within the test suite.
#
# $Id: malloc_common.tcl,v 1.11 2008/01/18 17:03:33 drh Exp $

# If we did not compile with malloc testing enabled, then do nothing.
#
ifcapable !memdebug {
  return 0
}

52
53
54
55
56
57
58





59
60
61
62
63
64
65
66
67
68
69
70
    set tn malloc-$tn
  }
  if {[info exists ::mallocopts(-start)]} {
    set start $::mallocopts(-start)
  } else {
    set start 0
  }





  save_prng_state

  foreach ::iRepeat {0 1} {
    set ::go 1
    for {set ::n $start} {$::go && $::n < 50000} {incr ::n} {

      # If $::iRepeat is 0, then the malloc() failure is transient - it
      # fails and then subsequent calls succeed. If $::iRepeat is 1, 
      # then the failure is persistent - once malloc() fails it keeps
      # failing.
      #
      set zRepeat "transient"







>
>
>
>
>




|







52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
    set tn malloc-$tn
  }
  if {[info exists ::mallocopts(-start)]} {
    set start $::mallocopts(-start)
  } else {
    set start 0
  }
  if {[info exists ::mallocopts(-end)]} {
    set end $::mallocopts(-end)
  } else {
    set end 50000
  }
  save_prng_state

  foreach ::iRepeat {0 1} {
    set ::go 1
    for {set ::n $start} {$::go && $::n <= $end} {incr ::n} {

      # If $::iRepeat is 0, then the malloc() failure is transient - it
      # fails and then subsequent calls succeed. If $::iRepeat is 1, 
      # then the failure is persistent - once malloc() fails it keeps
      # failing.
      #
      set zRepeat "transient"
Changes to test/shared_err.test.
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#
#***********************************************************************
#
# The focus of the tests in this file are IO errors that occur in a shared
# cache context. What happens to connection B if one connection A encounters
# an IO-error whilst reading or writing the file-system?
#
# $Id: shared_err.test,v 1.17 2007/09/03 16:12:10 drh Exp $

proc skip {args} {}


set testdir [file dirname $argv0]
source $testdir/tester.tcl
source $testdir/malloc_common.tcl







|







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#
#***********************************************************************
#
# The focus of the tests in this file are IO errors that occur in a shared
# cache context. What happens to connection B if one connection A encounters
# an IO-error whilst reading or writing the file-system?
#
# $Id: shared_err.test,v 1.18 2008/01/18 17:03:33 drh Exp $

proc skip {args} {}


set testdir [file dirname $argv0]
source $testdir/tester.tcl
source $testdir/malloc_common.tcl
108
109
110
111
112
113
114

115
116
117
118
119
120
121
  execsql {BEGIN;}
  execsql {INSERT INTO t1 SELECT a+1, b FROM t1;}
  execsql {INSERT INTO t1 SELECT 'string' || a, b FROM t1 WHERE 0 = (a%7);}
  execsql {COMMIT;}

  incr ::residx
} -cleanup {

  do_test shared_ioerr-2.$n.cleanup.1 {
    set res [catchsql {
      SELECT max(a), min(a), count(*) FROM (SELECT a FROM t1 order by a);
    } db2]
    set possible_results [list \
      {0 {1024 1 1024}}        \
      {0 {1023 1 512}}         \







>







108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
  execsql {BEGIN;}
  execsql {INSERT INTO t1 SELECT a+1, b FROM t1;}
  execsql {INSERT INTO t1 SELECT 'string' || a, b FROM t1 WHERE 0 = (a%7);}
  execsql {COMMIT;}

  incr ::residx
} -cleanup {
  catchsql ROLLBACK
  do_test shared_ioerr-2.$n.cleanup.1 {
    set res [catchsql {
      SELECT max(a), min(a), count(*) FROM (SELECT a FROM t1 order by a);
    } db2]
    set possible_results [list \
      {0 {1024 1 1024}}        \
      {0 {1023 1 512}}         \
339
340
341
342
343
344
345
346

347
348
349
350
351
352
353
  if {$::rc=="SQLITE_ROW"} {
    do_test shared_malloc-4.$::n.cleanup.2 {
      sqlite3_column_text $::STMT 0
    } {2222222222}
  }
  do_test shared_malloc-4.$::n.cleanup.3 {
   set rc [sqlite3_finalize $::STMT]
   expr {$rc=="SQLITE_OK" || $rc=="SQLITE_ABORT" || $rc=="SQLITE_NOMEM"}

  } {1}
# db2 eval {select * from sqlite_master}
  db2 close
}

do_malloc_test shared_err-5 -tclbody {
  db close







|
>







340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
  if {$::rc=="SQLITE_ROW"} {
    do_test shared_malloc-4.$::n.cleanup.2 {
      sqlite3_column_text $::STMT 0
    } {2222222222}
  }
  do_test shared_malloc-4.$::n.cleanup.3 {
   set rc [sqlite3_finalize $::STMT]
   expr {$rc=="SQLITE_OK" || $rc=="SQLITE_ABORT" ||
         $rc=="SQLITE_NOMEM" || $rc=="SQLITE_IOERR"}
  } {1}
# db2 eval {select * from sqlite_master}
  db2 close
}

do_malloc_test shared_err-5 -tclbody {
  db close
407
408
409
410
411
412
413
414
415



416


417
418
419
420
421
422
423
424
425
426
427

428
429
430
431
432
433
434
  execsql {
    BEGIN;
    INSERT INTO t1 VALUES(6, NULL);
    ROLLBACK;
  }
} -cleanup {
  do_test shared_malloc-8.$::n.cleanup.1 {
    lrange [execsql {
      SELECT a FROM t1;



    } db2] 0 1


  } {0000000000 1111111111}
  do_test shared_malloc-8.$::n.cleanup.2 {
    set rc1 [sqlite3_step $::STMT]
    set rc2 [sqlite3_finalize $::STMT]
    if {$rc2=="SQLITE_ABORT"} {
      incr ::aborted
    }
    expr {
      ($rc1=="SQLITE_DONE" && $rc2=="SQLITE_OK") || 
      ($rc1=="SQLITE_ERROR" && $rc2=="SQLITE_ABORT") ||
      ($rc1=="SQLITE_ERROR" && $rc2=="SQLITE_NOMEM")

    }
  } {1}
  db2 close
}
do_test shared_malloc-8.X {
  # Test that one or more queries were aborted due to the malloc() failure.
  expr $::aborted>=1







<
|
>
>
>
|
>
>
|









|
>







409
410
411
412
413
414
415

416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
  execsql {
    BEGIN;
    INSERT INTO t1 VALUES(6, NULL);
    ROLLBACK;
  }
} -cleanup {
  do_test shared_malloc-8.$::n.cleanup.1 {

    set res [catchsql {SELECT a FROM t1} db2]
    set ans [lindex $res 1]
    if {[lindex $res 0]} {
       set r [expr {$ans=="disk I/O error"}]
    } else {
       set r [expr {[lrange $ans 0 1]=="0000000000 1111111111"}]
    }
  } {1}
  do_test shared_malloc-8.$::n.cleanup.2 {
    set rc1 [sqlite3_step $::STMT]
    set rc2 [sqlite3_finalize $::STMT]
    if {$rc2=="SQLITE_ABORT"} {
      incr ::aborted
    }
    expr {
      ($rc1=="SQLITE_DONE" && $rc2=="SQLITE_OK") || 
      ($rc1=="SQLITE_ERROR" && $rc2=="SQLITE_ABORT") ||
      ($rc1=="SQLITE_ERROR" && $rc2=="SQLITE_NOMEM") ||
      ($rc1=="SQLITE_ERROR" && $rc2=="SQLITE_IOERR")
    }
  } {1}
  db2 close
}
do_test shared_malloc-8.X {
  # Test that one or more queries were aborted due to the malloc() failure.
  expr $::aborted>=1