summaryrefslogtreecommitdiff
path: root/db-4.8.30/test/sdb008.tcl
blob: c4021b06aadf4fa0ea23265fa7254b1f96a2563e (plain)
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
# See the file LICENSE for redistribution information.
#
# Copyright (c) 1999-2009 Oracle.  All rights reserved.
#
# $Id$
#
# TEST	sdb008
# TEST	Tests explicit setting of lorders for subdatabases -- the
# TEST	lorder should be ignored.
proc sdb008 { method args } {
	source ./include.tcl

	set args [convert_args $method $args]
	set omethod [convert_method $method]

	if { [is_queue $method] == 1 } {
		puts "Subdb008: skipping for method $method"
		return
	}
	set eindex [lsearch -exact $args "-env"]

	# If we are using an env, then testfile should just be the db name.
	# Otherwise it is the test directory and the name.
	if { $eindex == -1 } {
		set testfile1 $testdir/subdb008a.db
		set testfile2 $testdir/subdb008b.db
		set env NULL
	} else {
		set testfile1 subdb008a.db
		set testfile2 subdb008b.db
		incr eindex
		set env [lindex $args $eindex]
		set txnenv [is_txnenv $env]
		if { $txnenv == 1 } {
			append args " -auto_commit "
		}
		set testdir [get_home $env]
	}
	cleanup $testdir $env

	puts "Subdb008: $method ($args) subdb tests with different lorders"

	puts "\tSubdb008.a.0: create subdb with system default lorder"
	set lorder "1234"
	if { [big_endian] } {
		set lorder "4321"
	}
	set db [eval {berkdb_open -create -mode 0644} \
	    $args {$omethod $testfile1 "sub1"}]
	error_check_good subdb [is_valid_db $db] TRUE
	error_check_good dbclose [$db close] 0

	# Explicitly try to create subdb's of each byte order.  In both
	# cases the subdb should be forced to the byte order of the
	# parent database.
	puts "\tSubdb008.a.1: Try to create subdb with -1234 lorder"
	set db [eval {berkdb_open -create -mode 0644} \
	    $args {-lorder 1234 $omethod $testfile1 "sub2"}]
	error_check_good lorder_1234 [eval $db get_lorder] $lorder
	error_check_good subdb [is_valid_db $db] TRUE
	error_check_good dbclose [$db close] 0

	puts "\tSubdb008.a.2: Try to create subdb with -4321 lorder"
	set db [eval {berkdb_open -create -mode 0644} \
	    $args {-lorder 4321 $omethod $testfile1 "sub3"}]
	error_check_good lorder_4321 [eval $db get_lorder] $lorder
	error_check_good subdb [is_valid_db $db] TRUE
	error_check_good dbclose [$db close] 0

	puts "\tSubdb008.b.0: create subdb with non-default lorder"
	set reverse_lorder "4321"
	if { [big_endian] } {
		set reverse_lorder "1234"
	}
	set db [eval {berkdb_open -create -mode 0644} \
	    {-lorder $reverse_lorder} $args {$omethod $testfile2 "sub1"}]
	error_check_good subdb [is_valid_db $db] TRUE
	error_check_good dbclose [$db close] 0

	puts "\tSubdb008.b.1: Try to create subdb with -1234 lorder"
	set db [eval {berkdb_open -create -mode 0644} \
	    $args {-lorder 1234 $omethod $testfile2 "sub2"}]
	error_check_good lorder_1234 [eval $db get_lorder] $reverse_lorder
	error_check_good subdb [is_valid_db $db] TRUE
	error_check_good dbclose [$db close] 0

	puts "\tSubdb008.b.2: Try to create subdb with -4321 lorder"
	set db [eval {berkdb_open -create -mode 0644} \
	    $args {-lorder 4321 $omethod $testfile2 "sub3"}]
	error_check_good lorder_4321 [eval $db get_lorder] $reverse_lorder
	error_check_good subdb [is_valid_db $db] TRUE
	error_check_good dbclose [$db close] 0
}