1# See the file LICENSE for redistribution information.
2#
3# Copyright (c) 1999,2008 Oracle.  All rights reserved.
4#
5# $Id: env010.tcl,v 12.6 2008/01/08 20:58:53 bostic Exp $
6#
7# TEST	env010
8# TEST	Run recovery in an empty directory, and then make sure we can still
9# TEST	create a database in that directory.
10proc env010 { } {
11	source ./include.tcl
12
13	puts "Env010: Test of recovery in an empty directory."
14
15	# Create a new directory used only for this test
16
17	if { [file exists $testdir/EMPTYDIR] != 1 } {
18		file mkdir $testdir/EMPTYDIR
19	} else {
20		puts "\nDirectory already exists."
21	}
22
23	# Do the test twice, for regular recovery and catastrophic
24	# Open environment and recover, but don't create a database
25
26	foreach rmethod {recover recover_fatal} {
27
28		puts "\tEnv010: Creating env for $rmethod test."
29		env_cleanup $testdir/EMPTYDIR
30		set e [berkdb_env \
31		    -create -home $testdir/EMPTYDIR -txn -$rmethod]
32		error_check_good dbenv [is_valid_env $e] TRUE
33
34		# Open and close a database
35		# The method doesn't matter, so picked btree arbitrarily
36
37		set db [eval {berkdb_open -env $e \
38			-btree -create -mode 0644} ]
39		error_check_good dbopen [is_valid_db $db] TRUE
40		error_check_good db_close [$db close] 0
41
42		# Close environment
43
44		error_check_good envclose [$e close] 0
45		error_check_good berkdb:envremove \
46			[berkdb envremove -home $testdir/EMPTYDIR] 0
47	}
48	puts "\tEnv010 complete."
49}
50