~ubuntu-branches/ubuntu/maverick/evolution-data-server/maverick-proposed

« back to all changes in this revision

Viewing changes to libdb/test/lock003.tcl

  • Committer: Bazaar Package Importer
  • Author(s): Didier Roche
  • Date: 2010-05-17 17:02:06 UTC
  • mfrom: (1.1.79 upstream) (1.6.12 experimental)
  • Revision ID: james.westby@ubuntu.com-20100517170206-4ufr52vwrhh26yh0
Tags: 2.30.1-1ubuntu1
* Merge from debian experimental. Remaining change:
  (LP: #42199, #229669, #173703, #360344, #508494)
  + debian/control:
    - add Vcs-Bzr tag
    - don't use libgnome
    - Use Breaks instead of Conflicts against evolution 2.25 and earlier.
  + debian/evolution-data-server.install,
    debian/patches/45_libcamel_providers_version.patch:
    - use the upstream versioning, not a Debian-specific one 
  + debian/libedata-book1.2-dev.install, debian/libebackend-1.2-dev.install,
    debian/libcamel1.2-dev.install, debian/libedataserverui1.2-dev.install:
    - install html documentation
  + debian/rules:
    - don't build documentation it's shipped with the tarball

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-2002
4
 
#       Sleepycat Software.  All rights reserved.
5
 
#
6
 
# $Id$
7
 
#
8
 
# TEST  lock003
9
 
# TEST  Exercise multi-process aspects of lock.  Generate a bunch of parallel
10
 
# TEST  testers that try to randomly obtain locks;  make sure that the locks
11
 
# TEST  correctly protect corresponding objects.
12
 
proc lock003 { {iter 500} {max 1000} {procs 5} } {
13
 
        source ./include.tcl
14
 
        global lock_curid
15
 
        global lock_maxid
16
 
 
17
 
        set ldegree 5
18
 
        set objs 75
19
 
        set reads 65
20
 
        set wait 1
21
 
        set conflicts { 0 0 0 0 0 1 0 1 1}
22
 
        set seeds {}
23
 
 
24
 
        puts "Lock003: Multi-process random lock test"
25
 
 
26
 
        # Clean up after previous runs
27
 
        env_cleanup $testdir
28
 
 
29
 
        # Open/create the lock region
30
 
        puts "\tLock003.a: Create environment"
31
 
        set e [berkdb_env -create -lock -home $testdir]
32
 
        error_check_good env_open [is_substr $e env] 1
33
 
        $e lock_id_set $lock_curid $lock_maxid
34
 
 
35
 
        error_check_good env_close [$e close] 0
36
 
 
37
 
        # Now spawn off processes
38
 
        set pidlist {}
39
 
 
40
 
        for { set i 0 } {$i < $procs} {incr i} {
41
 
                if { [llength $seeds] == $procs } {
42
 
                        set s [lindex $seeds $i]
43
 
                }
44
 
#               puts "$tclsh_path\
45
 
#                   $test_path/wrap.tcl \
46
 
#                   lockscript.tcl $testdir/$i.lockout\
47
 
#                   $testdir $iter $objs $wait $ldegree $reads &"
48
 
                set p [exec $tclsh_path $test_path/wrap.tcl \
49
 
                    lockscript.tcl $testdir/lock003.$i.out \
50
 
                    $testdir $iter $objs $wait $ldegree $reads &]
51
 
                lappend pidlist $p
52
 
        }
53
 
 
54
 
        puts "\tLock003.b: $procs independent processes now running"
55
 
        watch_procs $pidlist 30 10800
56
 
 
57
 
        # Check for test failure
58
 
        set e [eval findfail [glob $testdir/lock003.*.out]]
59
 
        error_check_good "FAIL: error message(s) in log files" $e 0
60
 
 
61
 
        # Remove log files
62
 
        for { set i 0 } {$i < $procs} {incr i} {
63
 
                fileremove -f $testdir/lock003.$i.out
64
 
        }
65
 
}
66
 
 
67
 
# Create and destroy flag files to show we have an object locked, and
68
 
# verify that the correct files exist or don't exist given that we've
69
 
# just read or write locked a file.
70
 
proc lock003_create { rw obj } {
71
 
        source ./include.tcl
72
 
 
73
 
        set pref $testdir/L3FLAG
74
 
        set f [open $pref.$rw.[pid].$obj w]
75
 
        close $f
76
 
}
77
 
 
78
 
proc lock003_destroy { obj } {
79
 
        source ./include.tcl
80
 
 
81
 
        set pref $testdir/L3FLAG
82
 
        set f [glob -nocomplain $pref.*.[pid].$obj]
83
 
        error_check_good l3_destroy [llength $f] 1
84
 
        fileremove $f
85
 
}
86
 
 
87
 
proc lock003_vrfy { rw obj } {
88
 
        source ./include.tcl
89
 
 
90
 
        set pref $testdir/L3FLAG
91
 
        if { [string compare $rw "write"] == 0 } {
92
 
                set fs [glob -nocomplain $pref.*.*.$obj]
93
 
                error_check_good "number of other locks on $obj" [llength $fs] 0
94
 
        } else {
95
 
                set fs [glob -nocomplain $pref.write.*.$obj]
96
 
                error_check_good "number of write locks on $obj" [llength $fs] 0
97
 
        }
98
 
}
99