File: env019.tcl

package info (click to toggle)
db5.3 5.3.28%2Bdfsg2-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 158,500 kB
  • sloc: ansic: 448,411; java: 111,824; tcl: 80,544; sh: 44,264; cs: 33,697; cpp: 21,604; perl: 14,557; xml: 10,799; makefile: 4,077; javascript: 1,998; yacc: 1,003; awk: 965; sql: 801; erlang: 342; python: 216; php: 24; asm: 14
file content (68 lines) | stat: -rw-r--r-- 2,245 bytes parent folder | download | duplicates (9)
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
# See the file LICENSE for redistribution information.
#
# Copyright (c) 2010, 2013 Oracle and/or its affiliates.  All rights reserved.
#
# $Id$
#
# TEST	env019
# TEST	Test that stats are correctly set and reported when 
# TEST  an env is accessed from a second process.

proc env019 { } {
	source ./include.tcl

	puts "Env019:  Test stats when env is joined from a second process."

	# Set up test cases.
	# The first two elements are the flag and value for the original
	# env.  The third and fourth elements are the flag and value for
	# the second process.
	#
	set testcases {
		{ "-cachesize" "{0 1048576 1}" "-cachesize" "{0 2097152 1}" }
		{ "-cachesize" "{0 2097152 1}" "-cachesize" "{0 1048576 1}" }
		{ "-cachesize" "{0 2097152 1}" "-cachesize" "{0 2097152 1}" }
		{ "-cachesize" "{0 1048576 1}" {} {} }
	}

	foreach case $testcases {

		env_cleanup $testdir

		# Extract the values 
		set flag1 [ lindex $case 0 ] 
		set value1 [ lindex $case 1 ]
		set flag2 [ lindex $case 2 ] 
		set value2 [ lindex $case 3 ]
		
		# Set up the original env.
		set e [eval {berkdb_env -create -home $testdir} $flag1 $value1 ]
		error_check_good dbenv [is_valid_env $e] TRUE

		# Start up a second process to join the env. 
		puts "$tclsh_path $test_path/wrap.tcl env019script.tcl\
		    $testdir/env019.log $flag2 $value2 &"
		set pid [exec $tclsh_path $test_path/wrap.tcl env019script.tcl\
		    $testdir/env019.log $flag2 $value2 &]

		watch_procs $pid 5

		# Read the value observed by the second process.
		set db [eval berkdb_open -env $e -btree values.db]
		set get_gbytes [lindex [lindex [$db get gbytes] 0] 1]
		set get_bytes [lindex [lindex [$db get bytes] 0] 1]
		set get_ncache [lindex [lindex [$db get ncache] 0] 1]

		# Now get the answer from memp_stat.
		set set_gbytes [stat_field $e mpool_stat "Cache size (gbytes)"]
		set set_bytes [stat_field $e mpool_stat "Cache size (bytes)"]
		set set_ncache [stat_field $e mpool_stat "Number of caches"]

		error_check_good gbytes [string equal $get_gbytes $set_gbytes] 1
		error_check_good bytes [string equal $get_bytes $set_bytes] 1
		error_check_good ncache [string equal $get_ncache $set_ncache] 1
		error_check_good db_close [$db close] 0
		error_check_good env_close [$e close] 0
	}

}