File: test.tcl

package info (click to toggle)
db 2%3A2.4.14-2.7.7.1.c
  • links: PTS
  • area: main
  • in suites: potato
  • size: 12,716 kB
  • ctags: 9,382
  • sloc: ansic: 35,556; tcl: 8,564; cpp: 4,890; sh: 2,075; makefile: 1,723; java: 1,632; sed: 419; awk: 153; asm: 41
file content (360 lines) | stat: -rw-r--r-- 8,521 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
# See the file LICENSE for redistribution information.
#
# Copyright (c) 1996, 1997, 1998
#	Sleepycat Software.  All rights reserved.
#
#	@(#)test.tcl	10.42 (Sleepycat) 1/2/99

source ./include.tcl
source ../test/testutils.tcl
source ../test/byteorder.tcl

set testdir ./TESTDIR
if { [file exists $testdir] != 1 } {
	exec $MKDIR $testdir
}

set is_windows_test 0

set parms(test001) 10000
set parms(test002) 10000
set parms(test003) ""
set parms(test004) {10000 4 0}
set parms(test005) 10000
set parms(test006) {10000 6}
set parms(test007) 10000
set parms(test008) {10000 8 0}
set parms(test009) 10000
set parms(test010) {10000 5 10}
set parms(test011) {10000 5 11}
set parms(test012)  ""
set parms(test013) 10000
set parms(test014) 10000
set parms(test015) {7500 0}
set parms(test016) 10000
set parms(test017) 10000
set parms(test018) 10000
set parms(test019) 10000
set parms(test020) 10000
set parms(test021) 10000
set parms(test022) ""
set parms(test023) ""
set parms(test024) 10000
set parms(test025) 10000
set parms(test026) {2000 5 26}
set parms(test027) {100}
set parms(test028) ""
set parms(test029) 10000
set parms(test030) 10000
set parms(test031) {10000 5 31}
set parms(test032) {10000 5 32}
set parms(test033) {10000 5 33}
set parms(test034) 10000
set parms(test035) 10000
set parms(test036) 10000
set parms(test037) 100
set parms(test038) 10000
set parms(test039) 10000
set parms(test040) 10000
set parms(test041) 100
set parms(test042) 1000
set parms(test043) 10000

set dict ../test/wordlist
set alphabet "abcdefghijklmnopqrstuvwxyz"

set recd_debug	0
set recd_prefix	"db_recover: Finding last valid log LSN"

set loadtests 46
set runtests 43
set recdtests 6
set deadtests 2
set bugtests 7
set rsrctests 1
for { set i 1 } { $i <= $loadtests } {incr i} {
	set name [format "test%03d.tcl" $i]
	source ../test/$name
}
for { set i 1 } { $i <= $recdtests } {incr i} {
	set name [format "recd%03d.tcl" $i]
	source ../test/$name
}
for { set i 1 } { $i <= $deadtests } {incr i} {
	set name [format "dead%03d.tcl" $i]
	source ../test/$name
}
for { set i 1 } { $i <= $bugtests } {incr i} {
	set name [format "bug%03d.tcl" $i]
	source ../test/$name
}
for { set i 1 } { $i <= $rsrctests } {incr i} {
	set name [format "rsrc%03d.tcl" $i]
	source ../test/$name
}

source ../test/archive.tcl
source ../test/dbm.tcl
source ../test/hsearch.tcl
source ../test/join.tcl
source ../test/lock.tcl
source ../test/mpool.tcl
source ../test/mlock.tcl
source ../test/mutex.tcl
source ../test/ndbm.tcl
source ../test/randomlock.tcl
source ../test/log.tcl
source ../test/txn.tcl

# Test driver programs

# Use args for options
proc run_method { method {start 1} {stop 0} args } {
	global parms
	global debug_print
	global debug_on
	global runtests
	if { $stop == 0 } {
		set stop $runtests
	}
	puts "run_method: $method $start $stop $args"

	for { set i $start } { $i <= $stop } {incr i} {
		puts "[timestamp]"
		set name [format "test%03d" $i]
		eval $name $method $parms($name) $args
		if { $debug_print != 0 } {
			puts ""
		}
		if { $debug_on != 0 } {
			debug
		}
		flush stdout
		flush stderr
	}
}

proc r { args } {
source ./include.tcl
	global recdtests

	set l [ lindex $args 0 ]
	switch $l {
		ampool { eval mpool -shmem anon [lrange $args 1 end] }
		archive { eval archive [lrange $args 1 end] }
		byte {
			foreach method "DB_HASH DB_BTREE DB_RECNO DB_RRECNO" {
				byteorder $method
			}
		}
		dbm { eval dbm }
		dead {
			eval dead001 [lrange $args 1 end]
			eval dead002 [lrange $args 1 end]
		}
		join1 { eval jointest }
		join2 { eval jointest 512 }
		join3 {	eval jointest 8192 $DB_JOIN_ITEM }
		hsearch { eval htest }
		lock { eval locktest [lrange $args 1 end] }
		log { eval logtest [lrange $args 1 end] }
		mpool { eval mpool [lrange $args 1 end] }
		nmpool { eval mpool -shmem named [lrange $args 1 end] }
		mutex { eval mutex [lrange $args 1 end] }
		ndbm { eval ndbm }
		recd {
			foreach method "DB_HASH DB_BTREE DB_RECNO DB_RRECNO" {
				for { set i 1 } {$i <= $recdtests} {incr i} {
					set name [format "recd%03d" $i]
					eval $name $method
					flush stdout
					flush stderr
				}
			}
		}
		rsrc {
			eval rsrc001
		}
		txn { eval txntest [lrange $args 1 end] }
		default { eval run_method $args }
	}
	flush stdout
	flush stderr
}

proc run_all { } {
source include.tcl
global runtests
global recdtests
	exec $RM -rf ALL.OUT
	foreach i "archive byte lock log mpool ampool nmpool mutex txn" {
		puts "Running $i tests"
		if [catch {exec ./dbtest << "r $i" >>& ALL.OUT } res] {
			set o [open ALL.OUT a]
			puts $o "FAIL: $i test"
			close $o
		}
	}

	# Add deadlock detector tests
	puts "Running deadlock detection tests."
	if [catch {exec ./dbtest << "r dead"  >>& ALL.OUT} res] {
		set o [open ALL.OUT a]
		puts $o "FAIL: deadlock detector test"
		close $o
	}


	foreach i "DB_BTREE DB_RBTREE DB_HASH DB_RECNO DB_RRECNO" {
		puts "Running $i tests"
		for { set j 1 } { $j <= $runtests } {incr j} {
			if [catch {exec ./dbtest << "run_method $i $j $j" \
			    >>& ALL.OUT } res] {
				set o [open ALL.OUT a]
				puts $o "FAIL: [format "test%03d" $j] $i"
				close $o
			}
		}
	}

	puts "Running RECNO source tests"
	if [catch {exec ./dbtest << "r rsrc" >>& ALL.OUT } res] {
		set o [open ALL.OUT a]
		puts $o "FAIL: $i test"
		close $o
	}

	# Run join test
	foreach i "join1 join2 join3" {
		if [catch {exec ./dbtest << "r $i" >>& ALL.OUT } res] {
			set o [open ALL.OUT a]
			puts $o "FAIL: $i test"
			close $o
		}
	}

	# Run recovery tests
	foreach method "DB_HASH DB_BTREE DB_RECNO DB_RRECNO" {
		puts "Running recovery tests for $method"
		for { set i 1 } {$i <= $recdtests} {incr i} {
			set name [format "recd%03d" $i]
			if [catch {exec ./dbtest << "$name $method" \
			    >>& ALL.OUT } res] {
				set o [open ALL.OUT a]
				puts $o "FAIL: $name $method"
				close $o
			}
		}
	}


	# Check historic interfaces
	foreach t "dbm ndbm hsearch"  {
		if [catch {exec ./dbtest << "r $t"  >>& ALL.OUT} res] {
			set o [open ALL.OUT a]
			puts $o "FAIL: $t test"
			close $o
		}
	}

	catch { exec $SED -e /^FAIL/p -e d ALL.OUT } res
	set o [open ALL.OUT a]
	if { [string length $res] == 0 } {
		puts "Regression Tests Succeeded"
		puts $o "Regression Tests Succeeded"
	} else {
		puts "Regression Tests Failed; see ALL.OUT for log"
		puts $o "Regression Tests Failed"
	}
	close $o
}

proc convert_method { method } {
	switch $method {
		rrecno { return DB_RECNO }
		RRECNO { return DB_RECNO }
		db_rrecno { return DB_RECNO }
		DB_RRECNO { return DB_RECNO }
		rrec { return DB_RECNO }
		recno { return DB_RECNO }
		RECNO { return DB_RECNO }
		db_recno { return DB_RECNO }
		DB_RECNO { return DB_RECNO }
		rec { return DB_RECNO }
		btree { return DB_BTREE }
		BTREE { return DB_BTREE }
		db_btree { return DB_BTREE }
		DB_BTREE { return DB_BTREE }
		bt { return DB_BTREE }
		rbtree { return DB_BTREE }
		RBTREE { return DB_BTREE }
		db_rbtree { return DB_BTREE }
		DB_RBTREE { return DB_BTREE }
		rbt { return DB_BTREE }
		hash { return DB_HASH }
		HASH { return DB_HASH }
		db_hash { return DB_HASH }
		DB_HASH { return DB_HASH }
		h { return DB_HASH }
	}
}

proc is_rrecno { method } {
	set names { rrecno RRECNO db_rrecno DB_RRECNO rrec }
	if { [lsearch $names $method] >= 0 } {
		return 1
	} else {
		return 0
	}
}

proc is_rbtree { method } {
	set names { rbtree RBTREE db_rbtree DB_RBTREE rbt }
	if { [lsearch $names $method] >= 0 } {
		return 1
	} else {
		return 0
	}
}


# If recno-with-renumbering or btree-with-renumbering is specified, then
# fix the arguments to specify the DB_RENUMBER/DB_RECNUM option for the
# -flags argument.
proc convert_args { method {largs ""} } {
source ./include.tcl
	set do_flags 0
	if { [is_rrecno $method] == 1 } {
		return [add_to_args $DB_RENUMBER $largs]
	} elseif { [is_rbtree $method] == 1 } {
		return [add_to_args $DB_RECNUM $largs]
	}
	return $largs
}

# Make sure the DB_RECNUM flag is set if we are doing btree.
proc number_btree { method {largs ""} } {
source ./include.tcl
	if { [string compare $method "DB_BTREE"] == 0 } {
		return [add_to_args $DB_RECNUM $largs]
	}
	return $largs
}

# We want to set a flag value.  Since there already might be one in
# args, we need to add to it.
proc add_to_args { flag_val {largs ""} } {
source ./include.tcl
	set ndx [lsearch $largs -flags]
	if { $ndx >= 0 } {
		# There is already a flags argument
		incr ndx
		set f [lindex $largs $ndx]
		set f [expr $f | $flag_val]
		set largs [lreplace $largs $ndx $ndx $f]
	} else {
		# There is no flags argument
		lappend largs -flags $flag_val
	}
	return $largs
}