blob: 30e5823d8cd20d26dfc12cbdd3e1148ef0bacc0b (
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
|
# See the file LICENSE for redistribution information.
#
# Copyright (c) 2004,2007 Oracle. All rights reserved.
#
# $Id: recd020.tcl,v 12.6 2007/05/17 15:15:55 bostic Exp $
#
# TEST recd020
# TEST Test creation of intermediate directories -- an
# TEST undocumented, UNIX-only feature.
#
proc recd020 { method args } {
source ./include.tcl
global tcl_platform
set args [convert_args $method $args]
set omethod [convert_method $method]
set tnum "020"
set nentries 10
if { $tcl_platform(platform) != "unix" } {
puts "Skipping recd$tnum for non-UNIX platform."
return
}
puts "Recd$tnum ($method):\
Test creation of intermediate directories in recovery."
# Create the original intermediate directory.
env_cleanup $testdir
set intdir INTDIR
file mkdir $testdir/$intdir
set testfile recd$tnum.db
set flags "-create -txn -home $testdir"
puts "\tRecd$tnum.a: Create environment and populate database."
set env_cmd "berkdb_env $flags"
set env [eval $env_cmd]
error_check_good env [is_valid_env $env] TRUE
set db [eval berkdb_open \
-create $omethod $args -env $env -auto_commit $intdir/$testfile]
error_check_good db_open [is_valid_db $db] TRUE
set txn [$env txn]
set data "data"
for { set i 1 } { $i <= $nentries } { incr i } {
error_check_good db_put [eval \
{$db put} -txn $txn $i [chop_data $method $data.$i]] 0
}
error_check_good txn_commit [$txn commit] 0
error_check_good db_close [$db close] 0
error_check_good log_flush [$env log_flush] 0
error_check_good env_close [$env close] 0
puts "\tRecd$tnum.b: Remove intermediate directory."
error_check_good directory_there [file exists $testdir/$intdir] 1
file delete -force $testdir/$intdir
error_check_good directory_gone [file exists $testdir/$intdir] 0
puts "\tRecd020.c: Run recovery, recreating intermediate directory."
set env [eval $env_cmd -set_intermediate_dir 0751 -recover]
error_check_good env [is_valid_env $env] TRUE
puts "\tRecd020.d: Reopen test file to verify success."
set db [berkdb_open -env $env $intdir/$testfile]
error_check_good db_open [is_valid_db $db] TRUE
for { set i 1 } { $i <= $nentries } { incr i } {
set ret [$db get $i]
set k [lindex [lindex $ret 0] 0]
set d [lindex [lindex $ret 0] 1]
error_check_good key $k $i
error_check_good data $d [pad_data $method $data.$i]
}
# Clean up.
error_check_good db_close [$db close] 0
error_check_good log_flush [$env log_flush] 0
error_check_good env_close [$env close] 0
}
|