os/persistentdata/persistentstorage/sqlite3api/TEST/TclScript/crash7.test
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/persistentdata/persistentstorage/sqlite3api/TEST/TclScript/crash7.test	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,82 @@
     1.4 +# 2008 March 20
     1.5 +#
     1.6 +# The author disclaims copyright to this source code.  In place of
     1.7 +# a legal notice, here is a blessing:
     1.8 +#
     1.9 +#    May you do good and not evil.
    1.10 +#    May you find forgiveness for yourself and forgive others.
    1.11 +#    May you share freely, never taking more than you give.
    1.12 +#
    1.13 +#***********************************************************************
    1.14 +#
    1.15 +# $Id: crash7.test,v 1.1 2008/04/03 14:36:26 danielk1977 Exp $
    1.16 +
    1.17 +set testdir [file dirname $argv0]
    1.18 +source $testdir/tester.tcl
    1.19 +
    1.20 +ifcapable !crashtest {
    1.21 +  finish_test
    1.22 +  return
    1.23 +}
    1.24 +
    1.25 +proc signature {} {
    1.26 +  return [db eval {SELECT count(*), md5sum(a), md5sum(b), md5sum(c) FROM abc}]
    1.27 +}
    1.28 +
    1.29 +foreach f [list test.db test.db-journal] {
    1.30 +  for {set ii 1} {$ii < 64} {incr ii} {
    1.31 +    db close
    1.32 +    file delete test.db
    1.33 +    sqlite3 db test.db
    1.34 +  
    1.35 +    set from_size [expr 1024 << ($ii&3)]
    1.36 +    set to_size   [expr 1024 << (($ii>>2)&3)]
    1.37 +  
    1.38 +    execsql "
    1.39 +      PRAGMA page_size = $from_size;
    1.40 +      BEGIN;
    1.41 +      CREATE TABLE abc(a PRIMARY KEY, b, c);
    1.42 +      INSERT INTO abc VALUES(randomblob(100), randomblob(200), randomblob(1000));
    1.43 +      INSERT INTO abc 
    1.44 +          SELECT randomblob(1000), randomblob(200), randomblob(100)
    1.45 +          FROM abc;
    1.46 +      INSERT INTO abc 
    1.47 +          SELECT randomblob(100), randomblob(200), randomblob(1000)
    1.48 +          FROM abc;
    1.49 +      INSERT INTO abc 
    1.50 +          SELECT randomblob(100), randomblob(200), randomblob(1000)
    1.51 +          FROM abc;
    1.52 +      INSERT INTO abc 
    1.53 +          SELECT randomblob(100), randomblob(200), randomblob(1000)
    1.54 +          FROM abc;
    1.55 +      INSERT INTO abc 
    1.56 +          SELECT randomblob(100), randomblob(200), randomblob(1000)
    1.57 +          FROM abc WHERE [expr $ii&16];
    1.58 +      INSERT INTO abc 
    1.59 +          SELECT randomblob(25), randomblob(45), randomblob(9456)
    1.60 +          FROM abc WHERE [expr $ii&32];
    1.61 +      INSERT INTO abc 
    1.62 +          SELECT randomblob(100), randomblob(200), randomblob(1000)
    1.63 +          FROM abc WHERE [expr $ii&8];
    1.64 +      INSERT INTO abc 
    1.65 +          SELECT randomblob(25), randomblob(45), randomblob(9456)
    1.66 +          FROM abc WHERE [expr $ii&4];
    1.67 +      COMMIT;
    1.68 +    "
    1.69 +  
    1.70 +    set sig [signature]
    1.71 +    db close
    1.72 +  
    1.73 +    do_test crash7-1.$ii.crash {
    1.74 +       crashsql -file $f "
    1.75 +         PRAGMA page_size = $to_size;
    1.76 +         VACUUM;
    1.77 +       "
    1.78 +    } {1 {child process exited abnormally}}
    1.79 +  
    1.80 +    sqlite3 db test.db
    1.81 +    integrity_check crash7-1.$ii.integrity
    1.82 +  } 
    1.83 +}
    1.84 +
    1.85 +finish_test