1# See the file LICENSE for redistribution information 2# 3# Copyright (c) 2000,2008 Oracle. All rights reserved. 4# 5# $Id: logtrack.tcl,v 12.7 2008/01/08 20:58:53 bostic Exp $ 6# 7# logtrack.tcl: A collection of routines, formerly implemented in Perl 8# as log.pl, to track which log record types the test suite hits. 9 10set ltsname "logtrack_seen.db" 11set ltlist $test_path/logtrack.list 12set tmpname "logtrack_tmp" 13 14proc logtrack_clean { } { 15 global ltsname 16 17 file delete -force $ltsname 18 19 return 20} 21 22proc logtrack_init { } { 23 global ltsname 24 25 logtrack_clean 26 27 # Create an empty tracking database. 28 [berkdb_open -create -truncate -btree $ltsname] close 29 30 return 31} 32 33# Dump the logs for directory dirname and record which log 34# records were seen. 35proc logtrack_read { dirname } { 36 global ltsname tmpname util_path 37 global encrypt passwd 38 39 set seendb [berkdb_open $ltsname] 40 error_check_good seendb_open [is_valid_db $seendb] TRUE 41 42 file delete -force $tmpname 43 set pargs " -N -h $dirname " 44 if { $encrypt > 0 } { 45 append pargs " -P $passwd " 46 } 47 set ret [catch {eval exec $util_path/db_printlog $pargs > $tmpname} res] 48 error_check_good printlog $ret 0 49 error_check_good tmpfile_exists [file exists $tmpname] 1 50 51 set f [open $tmpname r] 52 while { [gets $f record] >= 0 } { 53 set r [regexp {\[[^\]]*\]\[[^\]]*\]([^\:]*)\:} $record whl name] 54 if { $r == 1 } { 55 error_check_good seendb_put [$seendb put $name ""] 0 56 } 57 } 58 close $f 59 file delete -force $tmpname 60 61 error_check_good seendb_close [$seendb close] 0 62} 63 64# Print the log record types that were seen but should not have been 65# seen and the log record types that were not seen but should have been seen. 66proc logtrack_summary { } { 67 global ltsname ltlist testdir 68 global one_test 69 70 set seendb [berkdb_open $ltsname] 71 error_check_good seendb_open [is_valid_db $seendb] TRUE 72 set existdb [berkdb_open -create -btree] 73 error_check_good existdb_open [is_valid_db $existdb] TRUE 74 set deprecdb [berkdb_open -create -btree] 75 error_check_good deprecdb_open [is_valid_db $deprecdb] TRUE 76 77 error_check_good ltlist_exists [file exists $ltlist] 1 78 set f [open $ltlist r] 79 set pref "" 80 while { [gets $f line] >= 0 } { 81 # Get the keyword, the first thing on the line: 82 # BEGIN/DEPRECATED/IGNORED/PREFIX 83 set keyword [lindex $line 0] 84 85 if { [string compare $keyword PREFIX] == 0 } { 86 # New prefix. 87 set pref [lindex $line 1] 88 } elseif { [string compare $keyword BEGIN] == 0 } { 89 # A log type we care about; put it on our list. 90 91 # Skip noop and debug. 92 if { [string compare [lindex $line 1] noop] == 0 } { 93 continue 94 } 95 if { [string compare [lindex $line 1] debug] == 0 } { 96 continue 97 } 98 99 error_check_good exist_put [$existdb put \ 100 ${pref}_[lindex $line 1] ""] 0 101 } elseif { [string compare $keyword DEPRECATED] == 0 || 102 [string compare $keyword IGNORED] == 0 } { 103 error_check_good deprec_put [$deprecdb put \ 104 ${pref}_[lindex $line 1] ""] 0 105 } 106 } 107 108 error_check_good exist_curs \ 109 [is_valid_cursor [set ec [$existdb cursor]] $existdb] TRUE 110 while { [llength [set dbt [$ec get -next]]] != 0 } { 111 set rec [lindex [lindex $dbt 0] 0] 112 if { [$seendb count $rec] == 0 && $one_test == "ALL" } { 113 if { $rec == "__db_pg_prepare" } { 114 puts "WARNING: log record type $rec can be\ 115 seen only on systems without FTRUNCATE." 116 } 117 puts "WARNING: log record type $rec: not tested" 118 } 119 } 120 error_check_good exist_curs_close [$ec close] 0 121 122 error_check_good seen_curs \ 123 [is_valid_cursor [set sc [$existdb cursor]] $existdb] TRUE 124 while { [llength [set dbt [$sc get -next]]] != 0 } { 125 set rec [lindex [lindex $dbt 0] 0] 126 if { [$existdb count $rec] == 0 } { 127 if { [$deprecdb count $rec] == 0 } { 128 puts "WARNING: log record type $rec: unknown" 129 } else { 130 puts \ 131 "WARNING: log record type $rec: deprecated" 132 } 133 } 134 } 135 error_check_good seen_curs_close [$sc close] 0 136 137 error_check_good seendb_close [$seendb close] 0 138 error_check_good existdb_close [$existdb close] 0 139 error_check_good deprecdb_close [$deprecdb close] 0 140 141 logtrack_clean 142} 143