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
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
|
# See the file LICENSE for redistribution information.
#
# Copyright (c) 1999-2009 Oracle. All rights reserved.
#
# $Id$
#
# TEST env007
# TEST Test DB_CONFIG config file options for berkdb env.
# TEST 1) Make sure command line option is respected
# TEST 2) Make sure that config file option is respected
# TEST 3) Make sure that if -both- DB_CONFIG and the set_<whatever>
# TEST method is used, only the file is respected.
# TEST Then test all known config options.
# TEST Also test config options on berkdb open. This isn't
# TEST really env testing, but there's no better place to put it.
proc env007 { } {
global errorInfo
global errorCode
global passwd
global has_crypto
source ./include.tcl
puts "Env007: DB_CONFIG and getters test."
puts "Env007.a: Test berkdb env options using getters and stat."
# Set up options we can check via stat or getters. Structure
# of the list is:
# 0. Arg used in berkdb env command
# 1. Arg used in DB_CONFIG file
# 2. Value assigned in berkdb env command
# 3. Value assigned in DB_CONFIG file
# 4. Message output during test
# 5. Stat command to run (empty if we can't get the info
# from stat).
# 6. String to search for in stat output
# 7. Which arg to check in stat (needed for cases where
# we set more than one args at a time, but stat can
# only check one args, like cachesize)
# 8. Arg used in getter
#
set rlist {
{ " -txn_max " "set_tx_max" "19" "31"
"Env007.a1: Txn Max" "txn_stat"
"Maximum txns" "0" "get_tx_max" }
{ " -lock_max_locks " "set_lk_max_locks" "1070" "1290"
"Env007.a2: Lock Max" "lock_stat"
"Maximum locks" "0" "get_lk_max_locks" }
{ " -lock_max_lockers " "set_lk_max_lockers" "1500" "2000"
"Env007.a3: Max Lockers" "lock_stat"
"Maximum lockers" "0" "get_lk_max_lockers" }
{ " -lock_max_objects " "set_lk_max_objects" "1500" "2000"
"Env007.a4: Max Objects" "lock_stat"
"Maximum objects" "0" "get_lk_max_objects" }
{ " -log_buffer " "set_lg_bsize" "65536" "131072"
"Env007.a5: Log Bsize" "log_stat"
"Log record cache size" "0" "get_lg_bsize" }
{ " -log_max " "set_lg_max" "8388608" "9437184"
"Env007.a6: Log Max" "log_stat"
"Current log file size" "0" "get_lg_max" }
{ " -cachesize " "set_cachesize" "0 536870912 1" "1 0 1"
"Env007.a7.0: Cachesize" "mpool_stat"
"Cache size (gbytes)" "0" "get_cachesize" }
{ " -cachesize " "set_cachesize" "0 536870912 1" "1 0 1"
"Env007.a7.1: Cachesize" "mpool_stat"
"Cache size (bytes)" "1" "get_cachesize" }
{ " -cachesize " "set_cachesize" "0 536870912 1" "1 0 1"
"Env007.a7.2: Cachesize" "mpool_stat"
"Number of caches" "2" "get_cachesize" }
{ " -lock_timeout " "set_lock_timeout" "100" "120"
"Env007.a8: Lock Timeout" "lock_stat"
"Lock timeout value" "0" "get_timeout lock" }
{ " -log_regionmax " "set_lg_regionmax" "8388608" "4194304"
"Env007.a9: Log Regionmax" "log_stat"
"Region size" "0" "get_lg_regionmax" }
{ " -mpool_max_openfd " "set_mp_max_openfd" "17" "27"
"Env007.a10: Mmap max openfd" "mpool_stat"
"Maximum open file descriptors" "0" "get_mp_max_openfd" }
{ " -mpool_max_write " "set_mp_max_write" "37 47" "57 67"
"Env007.a11.0: Mmap max write" "mpool_stat"
"Maximum sequential buffer writes" "0" "get_mp_max_write" }
{ " -mpool_max_write " "set_mp_max_write" "37 47" "57 67"
"Env007.a11.1: Mmap max write" "mpool_stat"
"Sleep after writing maximum buffers" "1" "get_mp_max_write" }
{ " -mpool_mmap_size " "set_mp_mmapsize" "12582912" "8388608"
"Env007.a12: Mmapsize" "mpool_stat"
"Maximum memory-mapped file size" "0" "get_mp_mmapsize" }
{ " -shm_key " "set_shm_key" "15" "35"
"Env007.a13: Shm Key" ""
"" "" "get_shm_key" }
{ " -tmp_dir " "set_tmp_dir" "." "./TEMPDIR"
"Env007.a14: Temp dir" ""
"" "" "get_tmp_dir" }
{ " -txn_timeout " "set_txn_timeout" "100" "120"
"Env007.a15: Txn timeout" "lock_stat"
"Transaction timeout value" "0" "get_timeout txn" }
{ " -log_filemode " "set_lg_filemode" "417" "637"
"Env007.a16: Log FileMode" "log_stat"
"Log file mode" "0" "get_lg_filemode" }
}
set e "berkdb_env_noerr -create -mode 0644 -home $testdir -txn "
set qnxexclude {set_cachesize}
foreach item $rlist {
set envarg [lindex $item 0]
set configarg [lindex $item 1]
set envval [lindex $item 2]
set configval [lindex $item 3]
set msg [lindex $item 4]
set statcmd [lindex $item 5]
set statstr [lindex $item 6]
set index [lindex $item 7]
set getter [lindex $item 8]
if { $is_qnx_test &&
[lsearch $qnxexclude $configarg] != -1 } {
puts "\tEnv007.a: Skipping $configarg for QNX"
continue
}
env_cleanup $testdir
# First verify using just env args
puts "\t$msg Environment argument only"
set env [eval $e $envarg {$envval}]
error_check_good envopen:0 [is_valid_env $env] TRUE
error_check_good get_envval [eval $env $getter] $envval
if { $statcmd != "" } {
set statenvval [lindex $envval $index]
# log_stat reports the sum of the specified
# region size and the log buffer size.
if { $statstr == "Region size" } {
set lbufsize 32768
set statenvval [expr $statenvval + $lbufsize]
}
env007_check $env $statcmd $statstr $statenvval
}
error_check_good envclose:0 [$env close] 0
env_cleanup $testdir
env007_make_config $configarg $configval
# Verify using just config file
puts "\t$msg Config file only"
set env [eval $e]
error_check_good envopen:1 [is_valid_env $env] TRUE
error_check_good get_configval1 [eval $env $getter] $configval
if { $statcmd != "" } {
set statconfigval [lindex $configval $index]
if { $statstr == "Region size" } {
set statconfigval \
[expr $statconfigval + $lbufsize]
}
env007_check $env $statcmd $statstr $statconfigval
}
error_check_good envclose:1 [$env close] 0
# Now verify using env args and config args
puts "\t$msg Environment arg and config file"
set env [eval $e $envarg {$envval}]
error_check_good envopen:2 [is_valid_env $env] TRUE
# Getter should retrieve config val, not envval.
error_check_good get_configval2 [eval $env $getter] $configval
if { $statcmd != "" } {
env007_check $env $statcmd $statstr $statconfigval
}
error_check_good envclose:2 [$env close] 0
}
#
# Test all options that can be set in DB_CONFIG. Write it out
# to the file and make sure we can open the env. This execs
# the config file code. Also check with a getter that the
# expected value is returned.
#
puts "\tEnv007.b: Test berkdb env config options using getters\
and env open."
# The cfglist variable contains options that can be set in DB_CONFIG.
set cfglist {
{ "set_data_dir" "." "get_data_dirs" "." }
{ "set_flags" "db_auto_commit" "get_flags" "-auto_commit" }
{ "set_flags" "db_cdb_alldb" "get_flags" "-cdb_alldb" }
{ "set_flags" "db_direct_db" "get_flags" "-direct_db" }
{ "set_flags" "db_nolocking" "get_flags" "-nolock" }
{ "set_flags" "db_nommap" "get_flags" "-nommap" }
{ "set_flags" "db_nopanic" "get_flags" "-nopanic" }
{ "set_flags" "db_overwrite" "get_flags" "-overwrite" }
{ "set_flags" "db_region_init" "get_flags" "-region_init" }
{ "set_flags" "db_txn_nosync" "get_flags" "-nosync" }
{ "set_flags" "db_txn_write_nosync" "get_flags" "-wrnosync" }
{ "set_flags" "db_yieldcpu" "get_flags" "-yield" }
{ "set_lg_bsize" "65536" "get_lg_bsize" "65536" }
{ "set_lg_dir" "." "get_lg_dir" "." }
{ "set_lg_max" "8388608" "get_lg_max" "8388608" }
{ "set_lg_regionmax" "262144" "get_lg_regionmax" "262144" }
{ "set_lk_detect" "db_lock_default" "get_lk_detect" "default" }
{ "set_lk_detect" "db_lock_expire" "get_lk_detect" "expire" }
{ "set_lk_detect" "db_lock_maxlocks" "get_lk_detect" "maxlocks" }
{ "set_lk_detect" "db_lock_minlocks" "get_lk_detect" "minlocks" }
{ "set_lk_detect" "db_lock_minwrite" "get_lk_detect" "minwrite" }
{ "set_lk_detect" "db_lock_oldest" "get_lk_detect" "oldest" }
{ "set_lk_detect" "db_lock_random" "get_lk_detect" "random" }
{ "set_lk_detect" "db_lock_youngest" "get_lk_detect" "youngest" }
{ "set_lk_max_lockers" "1500" "get_lk_max_lockers" "1500" }
{ "set_lk_max_locks" "1290" "get_lk_max_locks" "1290" }
{ "set_lk_max_objects" "1500" "get_lk_max_objects" "1500" }
{ "set_lock_timeout" "100" "get_timeout lock" "100" }
{ "set_mp_mmapsize" "12582912" "get_mp_mmapsize" "12582912" }
{ "set_mp_max_write" "10 20" "get_mp_max_write" "10 20" }
{ "set_mp_max_openfd" "10" "get_mp_max_openfd" "10" }
{ "set_region_init" "1" "get_flags" "-region_init" }
{ "set_shm_key" "15" "get_shm_key" "15" }
{ "set_tas_spins" "15" "get_tas_spins" "15" }
{ "set_tmp_dir" "." "get_tmp_dir" "." }
{ "set_tx_max" "31" "get_tx_max" "31" }
{ "set_txn_timeout" "50" "get_timeout txn" "50" }
{ "set_verbose" "db_verb_deadlock" "get_verbose deadlock" "on" }
{ "set_verbose" "db_verb_fileops" "get_verbose fileops" "on" }
{ "set_verbose" "db_verb_fileops_all" "get_verbose fileops_all" "on" }
{ "set_verbose" "db_verb_recovery" "get_verbose recovery" "on" }
{ "set_verbose" "db_verb_register" "get_verbose register" "on" }
{ "set_verbose" "db_verb_replication" "get_verbose rep" "on" }
{ "set_verbose" "db_verb_waitsfor" "get_verbose wait" "on" }
}
env_cleanup $testdir
set e "berkdb_env_noerr -create -mode 0644 -home $testdir -txn"
set directlist {db_direct_db}
foreach item $cfglist {
env_cleanup $testdir
set configarg [lindex $item 0]
set configval [lindex $item 1]
set getter [lindex $item 2]
set getval [lindex $item 3]
env007_make_config $configarg $configval
# Verify using config file
puts "\t\tEnv007.b: $configarg $configval"
# Unconfigured/unsupported direct I/O is not reported
# as a failure.
set directmsg \
"direct I/O either not configured or not supported"
if {[catch { eval $e } env ]} {
if { [lsearch $directlist $configval] != -1 && \
[is_substr $env $directmsg] == 1 } {
continue
} else {
puts "FAIL: $env"
continue
}
}
error_check_good envvalid:1 [is_valid_env $env] TRUE
error_check_good getter:1 [eval $env $getter] $getval
error_check_good envclose:1 [$env close] 0
}
puts "\tEnv007.c: Test berkdb env options using getters and env open."
# The envopenlist variable contains options that can be set using
# berkdb env. We always set -mpool.
# { "-system_mem" "-shm_key 1" "-system_mem" "get_open_flags" }
set envopenlist {
{ "-cdb" "" "-cdb" "get_open_flags" }
{ "-errpfx" "FOO" "FOO" "get_errpfx" }
{ "-lock" "" "-lock" "get_open_flags" }
{ "-log" "" "-log" "get_open_flags" }
{ "" "" "-mpool" "get_open_flags" }
{ "-txn" "" "-txn" "get_open_flags" }
{ "-recover" "-txn" "-recover" "get_open_flags" }
{ "-recover_fatal" "-txn" "-recover_fatal" "get_open_flags" }
{ "-register" "-txn -recover" "-register" "get_open_flags" }
{ "-use_environ" "" "-use_environ" "get_open_flags" }
{ "-use_environ_root" "" "-use_environ_root" "get_open_flags" }
{ "" "" "-create" "get_open_flags" }
{ "-private" "" "-private" "get_open_flags" }
{ "-thread" "" "-thread" "get_open_flags" }
{ "-txn_timestamp" "100000000" "100000000" "get_tx_timestamp" }
}
if { $has_crypto == 1 } {
lappend envopenlist {
"-encryptaes" "$passwd" "-encryptaes" "get_encrypt_flags" }
}
set e "berkdb_env_noerr -create -mode 0644 -home $testdir"
set qnxexclude {-system_mem}
foreach item $envopenlist {
env_cleanup $testdir
set envarg [lindex $item 0]
set envval [lindex $item 1]
set retval [lindex $item 2]
set getter [lindex $item 3]
if { $is_qnx_test &&
[lsearch $qnxexclude $envarg] != -1} {
puts "\t\tEnv007: Skipping $envarg for QNX"
continue
}
puts "\t\tEnv007.c: $envarg $retval"
# Set up env
set ret [catch {eval $e $envarg $envval} env]
if { $ret != 0 } {
# If the env open failed, it may be because we're on a
# platform such as HP-UX 10 that won't support mutexes
# in shmget memory. Verify that the return value was
# EINVAL or EOPNOTSUPP and bail gracefully.
error_check_good \
is_shm_test [is_substr $envarg -system_mem] 1
error_check_good returned_error [expr \
[is_substr $errorCode EINVAL] || \
[is_substr $errorCode EOPNOTSUPP]] 1
puts "Warning: platform\
does not support mutexes in shmget memory."
puts "Skipping shared memory mpool test."
} else {
error_check_good env_open [is_valid_env $env] TRUE
# Check that getter retrieves expected retval.
set get_retval [eval $env $getter]
if { [is_substr $get_retval $retval] != 1 } {
puts "FAIL: $retval\
should be a substring of $get_retval"
continue
}
error_check_good envclose [$env close] 0
# The -encryptany flag can only be tested on an existing
# environment that supports encryption, so do it here.
if { $has_crypto == 1 } {
if { $envarg == "-encryptaes" } {
set env [eval berkdb_env -home $testdir\
-encryptany $passwd]
error_check_good get_encryptany \
[eval $env get_encrypt_flags] \
"-encryptaes"
error_check_good envclose [$env close] 0
}
}
}
}
puts "\tEnv007.d: Test berkdb env options using set_flags and getters."
# The flaglist variable contains options that can be set using
# $env set_flags.
set flaglist {
{ "-direct_db" }
{ "-nolock" }
{ "-nommap" }
{ "-nopanic" }
{ "-nosync" }
{ "-overwrite" }
{ "-panic" }
{ "-wrnosync" }
}
set e "berkdb_env_noerr -create -mode 0644 -home $testdir"
set directlist {-direct_db}
foreach item $flaglist {
set flag [lindex $item 0]
env_cleanup $testdir
# Set up env
set env [eval $e]
error_check_good envopen [is_valid_env $env] TRUE
# Use set_flags to turn on new env characteristics.
#
# Unconfigured/unsupported direct I/O is not reported
# as a failure.
if {[catch { $env set_flags $flag on } res ]} {
if { [lsearch $directlist $flag] != -1 && \
[is_substr $res $directmsg] == 1 } {
error_check_good env_close [$env close] 0
continue
} else {
puts "FAIL: $res"
error_check_good env_close [$env close] 0
continue
}
} else {
error_check_good "flag $flag on" $res 0
}
# Check that getter retrieves expected retval.
set get_retval [eval $env get_flags]
if { [is_substr $get_retval $flag] != 1 } {
puts "FAIL: $flag should be a substring of $get_retval"
error_check_good env_close [$env close] 0
continue
}
# Use set_flags to turn off env characteristics, make sure
# they are gone.
error_check_good "flag $flag off" [$env set_flags $flag off] 0
set get_retval [eval $env get_flags]
if { [is_substr $get_retval $flag] == 1 } {
puts "FAIL: $flag should not be in $get_retval"
error_check_good env_close [$env close] 0
continue
}
error_check_good envclose [$env close] 0
}
puts "\tEnv007.d1: Test berkdb env options using set_log_config and getters."
# The flaglist variable contains options that can be set using
# $env log_config.
set flaglist {
{ "autoremove" }
{ "direct" }
{ "dsync" }
{ "zero" }
}
set e "berkdb_env_noerr -create -txn -mode 0644 -home $testdir"
set directlist {direct}
foreach item $flaglist {
set flag [lindex $item 0]
env_cleanup $testdir
# Set up env
set env [eval $e]
error_check_good envopen [is_valid_env $env] TRUE
# Use set_flags to turn on new env characteristics.
#
# Unconfigured/unsupported direct I/O is not reported
# as a failure.
if {[catch { $env log_config "$flag on" } res ]} {
if { [lsearch $directlist $flag] != -1 && \
[is_substr $res $directmsg] == 1 } {
error_check_good env_close [$env close] 0
continue
} else {
puts "FAIL: $res"
error_check_good env_close [$env close] 0
continue
}
} else {
error_check_good "flag $flag on" $res 0
}
# Check that getter retrieves expected retval.
set get_retval [eval $env log_get_config $flag]
if { $get_retval != 1 } {
puts "FAIL: $flag is not on"
error_check_good env_close [$env close] 0
continue
}
# Use set_flags to turn off env characteristics, make sure
# they are gone.
error_check_good "flag $flag off" [$env log_config "$flag off"] 0
set get_retval [eval $env log_get_config $flag]
if { $get_retval == 1 } {
puts "FAIL: $flag should off"
error_check_good env_close [$env close] 0
continue
}
error_check_good envclose [$env close] 0
}
puts "\tEnv007.e: Test env get_home."
env_cleanup $testdir
# Set up env
set env [eval $e]
error_check_good env_open [is_valid_env $env] TRUE
# Test for correct value.
set get_retval [eval $env get_home]
error_check_good get_home $get_retval $testdir
error_check_good envclose [$env close] 0
puts "\tEnv007.f: Test that bad config values are rejected."
set cfglist {
{ "set_cachesize" "1048576" }
{ "set_flags" "db_xxx" }
{ "set_flags" "1" }
{ "set_flags" "db_txn_nosync x" }
{ "set_lg_bsize" "db_xxx" }
{ "set_lg_max" "db_xxx" }
{ "set_lg_regionmax" "db_xxx" }
{ "set_lk_detect" "db_xxx" }
{ "set_lk_detect" "1" }
{ "set_lk_detect" "db_lock_youngest x" }
{ "set_lk_max_locks" "db_xxx" }
{ "set_lk_max_lockers" "db_xxx" }
{ "set_lk_max_objects" "db_xxx" }
{ "set_mp_max_openfd" "1 2" }
{ "set_mp_max_write" "1 2 3" }
{ "set_mp_mmapsize" "db_xxx" }
{ "set_region_init" "db_xxx" }
{ "set_shm_key" "db_xxx" }
{ "set_tas_spins" "db_xxx" }
{ "set_tx_max" "db_xxx" }
{ "set_verbose" "db_xxx" }
{ "set_verbose" "1" }
{ "set_verbose" "db_verb_recovery x" }
}
set e "berkdb_env_noerr -create -mode 0644 \
-home $testdir -log -lock -txn "
foreach item $cfglist {
set configarg [lindex $item 0]
set configval [lindex $item 1]
env007_make_config $configarg $configval
# verify using just config file
set stat [catch {eval $e} ret]
error_check_good envopen $stat 1
error_check_good error [is_substr $errorCode EINVAL] 1
}
puts "\tEnv007.g: Config name error set_xxx"
set e "berkdb_env_noerr -create -mode 0644 \
-home $testdir -log -lock -txn "
env007_make_config "set_xxx" 1
set stat [catch {eval $e} ret]
error_check_good envopen $stat 1
error_check_good error [is_substr $errorInfo \
"unrecognized name-value pair"] 1
puts "\tEnv007.h: Test berkdb open flags and getters."
# Check options that we configure with berkdb open and
# query via getters. Structure of the list is:
# 0. Flag used in berkdb open command
# 1. Value specified to flag
# 2. Specific method, if needed
# 3. Arg used in getter
set olist {
{ "-minkey" "4" " -btree " "get_bt_minkey" }
{ "-cachesize" "0 1048576 1" "" "get_cachesize" }
{ "" "FILENAME DBNAME" "" "get_dbname" }
{ "" "" "" "get_env" }
{ "-errpfx" "ERROR:" "" "get_errpfx" }
{ "" "-chksum" "" "get_flags" }
{ "-delim" "58" "-recno" "get_re_delim" }
{ "" "-dup" "" "get_flags" }
{ "" "-dup -dupsort" "" "get_flags" }
{ "" "-recnum" "" "get_flags" }
{ "" "-revsplitoff" "" "get_flags" }
{ "" "-renumber" "-recno" "get_flags" }
{ "" "-snapshot" "-recno" "get_flags" }
{ "" "-create" "" "get_open_flags" }
{ "" "-create -read_uncommitted" "" "get_open_flags" }
{ "" "-create -excl" "" "get_open_flags" }
{ "" "-create -nommap" "" "get_open_flags" }
{ "" "-create -thread" "" "get_open_flags" }
{ "" "-create -truncate" "" "get_open_flags" }
{ "-ffactor" "40" " -hash " "get_h_ffactor" }
{ "-lorder" "4321" "" "get_lorder" }
{ "-nelem" "10000" " -hash " "get_h_nelem" }
{ "-pagesize" "4096" "" "get_pagesize" }
{ "-extent" "4" "-queue" "get_q_extentsize" }
{ "-len" "20" "-recno" "get_re_len" }
{ "-pad" "0" "-recno" "get_re_pad" }
{ "-source" "include.tcl" "-recno" "get_re_source" }
}
set o "berkdb_open_noerr -create -mode 0644"
foreach item $olist {
cleanup $testdir NULL
set flag [lindex $item 0]
set flagval [lindex $item 1]
set method [lindex $item 2]
if { $method == "" } {
set method " -btree "
}
set getter [lindex $item 3]
puts "\t\tEnv007.h: $flag $flagval"
# Check that open is successful with the flag.
# The option -cachesize requires grouping for $flagval.
if { $flag == "-cachesize" } {
set ret [catch {eval $o $method $flag {$flagval}\
$testdir/a.db} db]
} else {
set ret [catch {eval $o $method $flag $flagval\
$testdir/a.db} db]
}
if { $ret != 0 } {
# If the open failed, it may be because we're on a
# platform such as HP-UX 10 that won't support
# locks in process-local memory.
# Verify that the return value was EOPNOTSUPP
# and bail gracefully.
error_check_good \
is_thread_test [is_substr $flagval -thread] 1
error_check_good returned_error [expr \
[is_substr $errorCode EINVAL] || \
[is_substr $errorCode EOPNOTSUPP]] 1
puts "Warning: platform does not support\
locks inside process-local memory."
puts "Skipping test of -thread flag."
} else {
error_check_good dbopen:0 [is_valid_db $db] TRUE
# Check that getter retrieves the correct value.
# Cachesizes under 500MB are adjusted upward to
# about 25% so just make sure we're in the right
# ballpark, between 1.2 and 1.3 of the original value.
if { $flag == "-cachesize" } {
set retval [eval $db $getter]
set retbytes [lindex $retval 1]
set setbytes [lindex $flagval 1]
error_check_good cachesize_low [expr\
$retbytes > [expr $setbytes * 6 / 5]] 1
error_check_good cachesize_high [expr\
$retbytes < [expr $setbytes * 13 / 10]] 1
} else {
error_check_good get_flagval \
[eval $db $getter] $flagval
}
error_check_good dbclose:0 [$db close] 0
}
}
puts "\tEnv007.i: Test berkdb_open -rdonly."
# This test is done separately because -rdonly can only be specified
# on an already existing database.
set flag "-rdonly"
set db [eval berkdb_open $flag $testdir/a.db]
error_check_good open_rdonly [is_valid_db $db] TRUE
error_check_good get_rdonly [eval $db get_open_flags] $flag
error_check_good dbclose:0 [$db close] 0
puts "\tEnv007.j: Test berkdb open flags and getters\
requiring environments."
# Check options that we configure with berkdb open and
# query via getters. Structure of the list is:
# 0. Flag used in berkdb open command
# 1. Value specified to flag
# 2. Specific method, if needed
# 3. Arg used in getter
# 4. Additional flags needed in setting up env
set elist {
{ "" "-auto_commit" "" "get_open_flags" "" }
}
if { $has_crypto == 1 } {
lappend elist \
{ "" "-encrypt" "" "get_flags" "-encryptaes $passwd" }
}
set e "berkdb_env -create -home $testdir -txn "
set o "berkdb_open -create -btree -mode 0644 "
foreach item $elist {
env_cleanup $testdir
set flag [lindex $item 0]
set flagval [lindex $item 1]
set method [lindex $item 2]
if { $method == "" } {
set method " -btree "
}
set getter [lindex $item 3]
set envflag [lindex $item 4]
# Check that open is successful with the flag.
set env [eval $e $envflag]
set db [eval $o -env $env $flag $flagval a.db]
error_check_good dbopen:0 [is_valid_db $db] TRUE
# Check that getter retrieves the correct value
set get_flagval [eval $db $getter]
error_check_good get_flagval [is_substr $get_flagval $flagval] 1
error_check_good dbclose [$db close] 0
error_check_good envclose [$env close] 0
}
}
proc env007_check { env statcmd statstr testval } {
set stat [$env $statcmd]
set checked 0
foreach statpair $stat {
if {$checked == 1} {
break
}
set statmsg [lindex $statpair 0]
set statval [lindex $statpair 1]
if {[is_substr $statmsg $statstr] != 0} {
set checked 1
error_check_good $statstr:ck $statval $testval
}
}
error_check_good $statstr:test $checked 1
}
proc env007_make_config { carg cval } {
global testdir
set cid [open $testdir/DB_CONFIG w]
puts $cid "$carg $cval"
close $cid
}
|