summaryrefslogtreecommitdiff
path: root/test/env006.tcl
blob: 6f36d7504cc1199987020a52ed3df160892fcf0b (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
# See the file LICENSE for redistribution information.
#
# Copyright (c) 1999-2009 Oracle.  All rights reserved.
#
# $Id$
#
# TEST	env006
# TEST	Make sure that all the utilities exist and run.
# TEST	Test that db_load -r options don't blow up.
proc env006 { } {
	source ./include.tcl

	puts "Env006: Run underlying utilities."

	set rlist {
	{ "db_archive"			"Env006.a"}
	{ "db_checkpoint"		"Env006.b"}
	{ "db_deadlock"			"Env006.c"}
	{ "db_dump"			"Env006.d"}
	{ "db_load"			"Env006.e"}
	{ "db_printlog"			"Env006.f"}
	{ "db_recover"			"Env006.g"}
	{ "db_stat"			"Env006.h"}
	{ "db_upgrade"			"Env006.h"}
	{ "db_verify"			"Env006.h"}
	}
	foreach pair $rlist {
		set cmd [lindex $pair 0]
		set msg [lindex $pair 1]

		puts "\t$msg: $cmd"

		set stat [catch {exec $util_path/$cmd -?} ret]
		error_check_good $cmd $stat 1

		#
		# Check for "usage", but only check "sage" so that
		# we can handle either Usage or usage.
		#
		error_check_good $cmd.err [is_substr $ret sage] 1
	}

	env_cleanup $testdir
	set env [eval berkdb_env -create -home $testdir -txn]
	error_check_good env_open [is_valid_env $env] TRUE

	set sub SUBDB
	foreach case { noenv env } {
		if { $case == "env" } {
			set envargs " -env $env "
			set homeargs " -h $testdir "
			set testfile env006.db
		} else {
			set envargs ""
			set homeargs ""
			set testfile $testdir/env006.db
		}

		puts "\tEnv006.i: Testing db_load -r with $case."
		set db [eval berkdb_open -create $envargs -btree $testfile]
		error_check_good db_open [is_valid_db $db] TRUE
		error_check_good db_close [$db close] 0

		set ret [eval \
		    exec $util_path/db_load -r lsn $homeargs $testfile]
		error_check_good db_load_r_lsn $ret ""
		set ret [eval \
		    exec $util_path/db_load -r fileid $homeargs $testfile]
		error_check_good db_load_r_fileid $ret ""

		error_check_good db_remove \
		    [eval {berkdb dbremove} $envargs $testfile] 0

		puts "\tEnv006.j: Testing db_load -r with $case and subdbs."
		set db [eval berkdb_open -create $envargs -btree $testfile $sub]
		error_check_good db_open [is_valid_db $db] TRUE
		error_check_good db_close [$db close] 0

		set ret [eval \
		    exec {$util_path/db_load} -r lsn $homeargs $testfile]
		error_check_good db_load_r_lsn $ret ""
		set ret [eval \
		    exec {$util_path/db_load} -r fileid $homeargs $testfile]
		error_check_good db_load_r_fileid $ret ""

		error_check_good \
		    db_remove [eval {berkdb dbremove} $envargs $testfile] 0
	}
	error_check_good env_close [$env close] 0
}