1
# See the file LICENSE for redistribution information.
3
# Copyright (c) 1999-2001
4
# Sleepycat Software. All rights reserved.
6
# $Id: rsrc002.tcl,v 11.12 2001/01/25 18:23:06 bostic Exp $
8
# Recno backing file test #2: test of set_re_delim.
9
# Specify a backing file with colon-delimited records,
10
# and make sure they are correctly interpreted.
14
puts "Rsrc002: Alternate variable-length record delimiters."
16
# We run this test essentially twice, once with a db file
17
# and once without (an in-memory database).
18
foreach testfile { "$testdir/rsrc002.db" "" } {
22
# Create the starting files
23
set oid1 [open $testdir/rsrc.txt w]
24
set oid2 [open $testdir/check.txt w]
25
puts -nonewline $oid1 "ostrich:emu:kiwi:moa:cassowary:rhea:"
26
puts -nonewline $oid2 "ostrich:emu:kiwi:penguin:cassowary:rhea:"
30
if { $testfile == "" } {
31
puts "Rsrc002: Testing with in-memory database."
33
puts "Rsrc002: Testing with disk-backed database."
36
puts "\tRsrc002.a: Read file, verify correctness."
37
set db [eval {berkdb_open -create -mode 0644 -delim 58 \
38
-recno -source $testdir/rsrc.txt} $testfile]
39
error_check_good dbopen [is_valid_db $db] TRUE
41
# Read the last record; replace it (but we won't change it).
42
# Then close the file and diff the two files.
44
set dbc [eval {$db cursor} $txn]
45
error_check_good db_cursor [is_valid_cursor $dbc $db] TRUE
47
set rec [$dbc get -first]
48
error_check_good get_first $rec [list [list 1 "ostrich"]]
49
set rec [$dbc get -next]
50
error_check_good get_next $rec [list [list 2 "emu"]]
52
puts "\tRsrc002.b: Write record, verify correctness."
54
eval {$dbc get -set 4}
55
set ret [$dbc put -current "penguin"]
56
error_check_good dbc_put $ret 0
58
error_check_good dbc_close [$dbc close] 0
59
error_check_good db_close [$db close] 0
62
Rsrc002:diff($testdir/rsrc.txt,$testdir/check.txt) \
63
[filecmp $testdir/rsrc.txt $testdir/check.txt] 0