3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing:
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.
10 #***********************************************************************
11 # This file implements regression tests for SQLite library. The
12 # focus of this script is multithreading behavior
14 # $Id: thread2.test,v 1.3 2008/10/07 15:25:49 drh Exp $
17 set testdir [file dirname $argv0]
18 source $testdir/tester.tcl
20 if {[run_thread_tests]==0} { finish_test ; return }
22 # Skip this whole file if the thread testing code is not enabled
24 if {[llength [info command thread_step]]==0 || [sqlite3 -has-codec]} {
29 # Create some data to work with
34 INSERT INTO t1 VALUES(1,'abcdefgh');
35 INSERT INTO t1 SELECT a+1, b||b FROM t1;
36 INSERT INTO t1 SELECT a+2, b||b FROM t1;
37 INSERT INTO t1 SELECT a+4, b||b FROM t1;
38 SELECT count(*), max(length(b)) FROM t1;
42 # Use the thread_swap command to move the database connections between
43 # threads, then verify that they still work.
47 thread_create A test.db
48 thread_create B test.db
50 thread_compile A {SELECT a FROM t1 LIMIT 1}
65 thread_compile B {SELECT a FROM t1 LIMIT 1}
84 thread_compile A {SELECT a FROM t1 LIMIT 1}
99 thread_compile B {SELECT a FROM t1 LIMIT 1}
102 do_test thread2-2.7 {
106 do_test thread2-2.8 {
109 do_test thread2-2.9 {
116 # Also important to halt the worker threads, which are using spin
117 # locks and eating away CPU cycles.