~ubuntu-branches/ubuntu/edgy/rpm/edgy

« back to all changes in this revision

Viewing changes to db/test/dead001.tcl

  • Committer: Bazaar Package Importer
  • Author(s): Joey Hess
  • Date: 2002-01-22 20:56:57 UTC
  • Revision ID: james.westby@ubuntu.com-20020122205657-l74j50mr9z8ofcl5
Tags: upstream-4.0.3
ImportĀ upstreamĀ versionĀ 4.0.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# See the file LICENSE for redistribution information.
 
2
#
 
3
# Copyright (c) 1996-2001
 
4
#       Sleepycat Software.  All rights reserved.
 
5
#
 
6
# $Id: dead001.tcl,v 11.19 2001/05/17 20:37:04 bostic Exp $
 
7
#
 
8
# Deadlock Test 1.
 
9
# We create various deadlock scenarios for different numbers of lockers
 
10
# and see if we can get the world cleaned up suitably.
 
11
proc dead001 { { procs "2 4 10" } {tests "ring clump" } } {
 
12
        source ./include.tcl
 
13
 
 
14
        puts "Dead001: Deadlock detector tests"
 
15
 
 
16
        env_cleanup $testdir
 
17
 
 
18
        # Create the environment.
 
19
        puts "\tDead001.a: creating environment"
 
20
        set env [berkdb env -create -mode 0644 -lock -home $testdir]
 
21
        error_check_good lock_env:open [is_valid_env $env] TRUE
 
22
 
 
23
        error_check_good lock_env:close [$env close] 0
 
24
 
 
25
        set dpid [exec $util_path/db_deadlock -vw -h $testdir \
 
26
            >& $testdir/dd.out &]
 
27
 
 
28
        foreach t $tests {
 
29
                set pidlist ""
 
30
                foreach n $procs {
 
31
 
 
32
                        sentinel_init
 
33
 
 
34
                        # Fire off the tests
 
35
                        puts "\tDead001: $n procs of test $t"
 
36
                        for { set i 0 } { $i < $n } { incr i } {
 
37
                                puts "$tclsh_path $test_path/wrap.tcl \
 
38
                                    $testdir/dead001.log.$i \
 
39
                                    ddscript.tcl $testdir $t $i $i $n"
 
40
                                set p [exec $tclsh_path \
 
41
                                        $test_path/wrap.tcl \
 
42
                                        ddscript.tcl $testdir/dead001.log.$i \
 
43
                                        $testdir $t $i $i $n &]
 
44
                                lappend pidlist $p
 
45
                        }
 
46
                        watch_procs 5
 
47
 
 
48
                        # Now check output
 
49
                        set dead 0
 
50
                        set clean 0
 
51
                        set other 0
 
52
                        for { set i 0 } { $i < $n } { incr i } {
 
53
                                set did [open $testdir/dead001.log.$i]
 
54
                                while { [gets $did val] != -1 } {
 
55
                                        switch $val {
 
56
                                                DEADLOCK { incr dead }
 
57
                                                1 { incr clean }
 
58
                                                default { incr other }
 
59
                                        }
 
60
                                }
 
61
                                close $did
 
62
                        }
 
63
                        puts "dead check..."
 
64
                        dead_check $t $n $dead $clean $other
 
65
                }
 
66
        }
 
67
 
 
68
        exec $KILL $dpid
 
69
        # Windows needs files closed before deleting files, so pause a little
 
70
        tclsleep 2
 
71
        fileremove -f $testdir/dd.out
 
72
        # Remove log files
 
73
        for { set i 0 } { $i < $n } { incr i } {
 
74
                fileremove -f $testdir/dead001.log.$i
 
75
        }
 
76
}