summaryrefslogtreecommitdiff
path: root/storage/bdb/test/env008.tcl
blob: dccdb41f61227c3a9dfb75f4c7ac8cf6e6d7ead6 (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
# See the file LICENSE for redistribution information.
#
# Copyright (c) 1999-2002
#	Sleepycat Software.  All rights reserved.
#
# $Id: env008.tcl,v 11.6 2002/02/22 14:29:34 sandstro Exp $
#
# TEST	env008
# TEST	Test environments and subdirectories.
proc env008 { } {
	global errorInfo
	global errorCode

	source ./include.tcl

	env_cleanup $testdir

	set subdir  1/1
	set subdir1 1/2
	file mkdir $testdir/$subdir $testdir/$subdir1
	set testfile $subdir/env.db

	puts "Env008: Test of environments and subdirectories."

	puts "\tEnv008.a: Create env and db."
	set env [berkdb_env -create -mode 0644 -home $testdir -txn]
	error_check_good env [is_valid_env $env] TRUE

	puts "\tEnv008.b: Remove db in subdir."
	env008_db $env $testfile
	error_check_good dbremove:$testfile \
	    [berkdb dbremove -env $env $testfile] 0

	#
	# Rather than remaking the db every time for the renames
	# just move around the new file name to another new file
	# name.
	#
	puts "\tEnv008.c: Rename db in subdir."
	env008_db $env $testfile
	set newfile $subdir/new.db
	error_check_good dbrename:$testfile/.. \
	    [berkdb dbrename -env $env $testfile $newfile] 0
	set testfile $newfile

	puts "\tEnv008.d: Rename db to parent dir."
	set newfile $subdir/../new.db
	error_check_good dbrename:$testfile/.. \
	    [berkdb dbrename -env $env $testfile $newfile] 0
	set testfile $newfile

	puts "\tEnv008.e: Rename db to child dir."
	set newfile $subdir/env.db
	error_check_good dbrename:$testfile/.. \
	    [berkdb dbrename -env $env $testfile $newfile] 0
	set testfile $newfile

	puts "\tEnv008.f: Rename db to another dir."
	set newfile $subdir1/env.db
	error_check_good dbrename:$testfile/.. \
	    [berkdb dbrename -env $env $testfile $newfile] 0

	error_check_good envclose [$env close] 0
	puts "\tEnv008 complete."
}

proc env008_db { env testfile } {
	set db [berkdb_open -env $env -create -btree $testfile]
	error_check_good dbopen [is_valid_db $db] TRUE
	set ret [$db put key data]
	error_check_good dbput $ret 0
	error_check_good dbclose [$db close] 0
}