1# See the file LICENSE for redistribution information.
2#
3# Copyright (c) 2005,2008 Oracle.  All rights reserved.
4#
5# $Id: txn012.tcl,v 12.7 2008/01/08 20:58:53 bostic Exp $
6#
7# TEST	txn012
8# TEST	Test txn->getname and txn->setname.
9
10proc txn012 { {ntxns 100} } {
11	source ./include.tcl
12	global util_path
13
14	puts "Txn012: Test txn->setname and txn->getname."
15	env_cleanup $testdir
16	set txnname "this is a short txn name"
17	set longtxnname "transaction names longer than 50 characters will be truncated"
18
19	puts "\tTxn012.a: Set up env and txn."
20	set env [berkdb_env -create -home $testdir -txn]
21	set db [berkdb_open -create -auto_commit -btree -env $env test.db]
22	set txn0 [$env txn]
23	set txn1 [$env txn]
24
25	# Name the transactions, check the name.
26	error_check_good name_txn0 [$txn0 setname $txnname] 0
27	set getname [$txn0 getname]
28	error_check_good txnname $getname $txnname
29
30	error_check_good longname_txn [$txn1 setname $longtxnname] 0
31	set getlongname [$txn1 getname]
32	error_check_good longtxnname $getlongname $longtxnname
33
34	# Run db_stat.  The long txn name will be truncated.
35	set stat [exec $util_path/db_stat -h $testdir -t]
36	error_check_good stat_name [is_substr $stat $txnname] 1
37	error_check_good stat_longname [is_substr $stat $longtxnname] 0
38	set truncname [string range $longtxnname 0 49]
39	error_check_good stat_truncname [is_substr $stat $truncname] 1
40
41	# Start another process and make sure it can see the names too.
42	puts "\tTxn012.b: Fork child process."
43	set pid [exec $tclsh_path $test_path/wrap.tcl txn012script.tcl \
44	    $testdir/txn012script.log $testdir $txnname $longtxnname &]
45
46	watch_procs $pid 1
47
48	error_check_good txn0_commit [$txn0 commit] 0
49	error_check_good txn1_commit [$txn1 commit] 0
50
51	# Check for errors in child log file.
52	set errstrings [eval findfail $testdir/txn012script.log]
53	foreach str $errstrings {
54		puts "FAIL: error message in log file: $str"
55	}
56
57	# Clean up.
58	error_check_good db_close [$db close] 0
59	error_check_good env_close [$env close] 0
60}
61
62