File: env008.tcl

package info (click to toggle)
evolution-data-server 1.0.4-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 39,504 kB
  • ctags: 26,423
  • sloc: ansic: 175,347; tcl: 30,499; sh: 20,699; perl: 11,320; xml: 9,039; java: 7,653; cpp: 6,029; makefile: 4,866; awk: 1,338; yacc: 1,103; sed: 772; cs: 505; lex: 134; asm: 14
file content (73 lines) | stat: -rw-r--r-- 2,039 bytes parent folder | download | duplicates (3)
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 1.1.1.1 2003/11/20 22:13:56 toshok 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
}