xref: /sqlite-3.40.0/test/crashM.test (revision 63c088e7)
1*63c088e7Sdan# 2015 Mar 13
2*63c088e7Sdan#
3*63c088e7Sdan# The author disclaims copyright to this source code.  In place of
4*63c088e7Sdan# a legal notice, here is a blessing:
5*63c088e7Sdan#
6*63c088e7Sdan#    May you do good and not evil.
7*63c088e7Sdan#    May you find forgiveness for yourself and forgive others.
8*63c088e7Sdan#    May you share freely, never taking more than you give.
9*63c088e7Sdan#
10*63c088e7Sdan#***********************************************************************
11*63c088e7Sdan#
12*63c088e7Sdan# Crash tests for the multiplex module with 8.3 filenames enabled.
13*63c088e7Sdan#
14*63c088e7Sdan
15*63c088e7Sdanset testdir [file dirname $argv0]
16*63c088e7Sdansource $testdir/tester.tcl
17*63c088e7Sdanset testprefix crashM
18*63c088e7Sdan
19*63c088e7Sdanifcapable !crashtest||!8_3_names {
20*63c088e7Sdan  finish_test
21*63c088e7Sdan  return
22*63c088e7Sdan}
23*63c088e7Sdan
24*63c088e7Sdandb close
25*63c088e7Sdansqlite3_shutdown
26*63c088e7Sdansqlite3_config_uri 1
27*63c088e7Sdan
28*63c088e7Sdanforeach f [glob -nocomplain test1.* test2.*] { forcedelete $f }
29*63c088e7Sdansqlite3_multiplex_initialize "" 1
30*63c088e7Sdansqlite3 db file:test1.db?8_3_names=1
31*63c088e7Sdansqlite3_multiplex_control db main chunk_size [expr 64*1024]
32*63c088e7Sdan
33*63c088e7Sdando_execsql_test 1.0 {
34*63c088e7Sdan  ATTACH 'file:test2.db?8_3_names=1' AS aux;
35*63c088e7Sdan
36*63c088e7Sdan  CREATE TABLE t1(x, y);
37*63c088e7Sdan  CREATE INDEX t1x ON t1(x);
38*63c088e7Sdan  CREATE INDEX t1y ON t1(y);
39*63c088e7Sdan
40*63c088e7Sdan  CREATE TABLE aux.t2(x, y);
41*63c088e7Sdan  CREATE INDEX aux.t2x ON t2(x);
42*63c088e7Sdan  CREATE INDEX aux.t2y ON t2(y);
43*63c088e7Sdan
44*63c088e7Sdan  WITH s(a) AS (
45*63c088e7Sdan    SELECT 1 UNION ALL SELECT a+1 FROM s WHERE a<1000
46*63c088e7Sdan  )
47*63c088e7Sdan  INSERT INTO t1 SELECT a, randomblob(500) FROM s;
48*63c088e7Sdan
49*63c088e7Sdan  WITH s(a) AS (
50*63c088e7Sdan    SELECT 1 UNION ALL SELECT a+1 FROM s WHERE a<1000
51*63c088e7Sdan  )
52*63c088e7Sdan  INSERT INTO t2 SELECT a, randomblob(500) FROM s;
53*63c088e7Sdan} {}
54*63c088e7Sdan
55*63c088e7Sdanfor {set i 0} {$i < 20} {incr i} {
56*63c088e7Sdan  do_test 2.$i.1 {
57*63c088e7Sdan    crashsql -delay 1 -file test1.db -opendb {
58*63c088e7Sdan      sqlite3_shutdown
59*63c088e7Sdan      sqlite3_config_uri 1
60*63c088e7Sdan      sqlite3_multiplex_initialize crash 1
61*63c088e7Sdan      sqlite3 db file:test1.db?8_3_names=1
62*63c088e7Sdan      sqlite3_multiplex_control db main chunk_size [expr 64*1024]
63*63c088e7Sdan    } {
64*63c088e7Sdan      ATTACH 'file:test2.db?8_3_names=1' AS aux;
65*63c088e7Sdan      BEGIN;
66*63c088e7Sdan        UPDATE t1 SET y = randomblob(500) WHERE (x%10)==0;
67*63c088e7Sdan        UPDATE t2 SET y = randomblob(500) WHERE (x%10)==0;
68*63c088e7Sdan      COMMIT;
69*63c088e7Sdan    }
70*63c088e7Sdan  } {1 {child process exited abnormally}}
71*63c088e7Sdan
72*63c088e7Sdan  do_execsql_test 2.$i.2 {
73*63c088e7Sdan    PRAGMA main.integrity_check;
74*63c088e7Sdan    PRAGMA aux.integrity_check;
75*63c088e7Sdan  } {ok ok}
76*63c088e7Sdan}
77*63c088e7Sdan
78*63c088e7Sdancatch { db close }
79*63c088e7Sdansqlite3_multiplex_shutdown
80*63c088e7Sdanfinish_test
81