add testsuite scripts git-svn-id: svn://coreboot.org/openbios/fcode-utils@92 f158a5a8-5612-0410-a976-696ce0be7e32
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 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359
diff --git a/testsuite/AutoCompare b/testsuite/AutoCompare
new file mode 100644
index 0000000..60e0eb6
--- /dev/null
+++ b/testsuite/AutoCompare
@@ -0,0 +1,183 @@
+#! /bin/csh -f
+#
+# Part of automation of the testing process for the Tokenizer/De-Tokenizer
+# Automate Comparison of results of Auto-Execution of the various test-cases
+
+# Updated Fri, 16 Jun 2006 at 12:12 PDT by David L. Paktor
+
+# To Do:
+# Conditional comparison of .DeTok files:
+# Detect difference in .fc file, but do not display
+# Display differences in .Log file
+# If difference detected in .fc file, display mssg
+# Otherwise, detect difference in .DeTok file and display mssg
+# If either diff detected in .fc or in .DeTok file, show .DeTok diffs
+# Display differences in .RomHdr
+#
+# Compare the source (.fth) files (for regression testing...)
+
+# Usage:
+# Run this from the parent-directory of the various Test categories.
+# This script uses the same TestArgs files that were used by
+# (and described in) the AutoExec script.
+#
+# This script needs a shell environment variable called CygTestLogs
+# whose value is the path to the parent-directory that contains
+# the results of Auto-Execution of the various test-cases under
+# Cygwin, which is the "Gold Standard" to which the other
+# platforms' results will be compared.
+#
+# This script accepts an optional environment variable called LogFilesDiff
+# which may be set to change the number of lines by which two .Log
+# files are expected to differ (due to different compilation-signatures)
+# If this is not supplied in the environment, a default will be provided.
+#
+# This script compares only one platform's results at a time;
+# the parent-directory that contains the Auto-Execution results
+# for the platform to be compared should be the current directory.
+#
+# This script displays both operational errors and detected discrepancies
+# in Standard Output and also collects the same in a log file whose
+# name is AutoComp.Log.<time-and-date-stamp>
+#
+# A secondary output file, called AutoComp.TKdiffs.<time-and-date-stamp>
+# is produced; it can be "source"d to cause a sequential tkdiff of
+# the detected discrepancies
+
+
+# Set the number of lines by which two .Log files are expected to differ.
+# (this is due to different compilation-signature lines)
+set LogFilesDiffLines = 6
+# Over-ride with optional shell env't variable called LogFilesDiff
+if ( $?LogFilesDiff ) then
+ set notallnumbers = `echo $LogFilesDiff | tr '0-9' ' '`
+ if ( "$notallnumbers" == "" ) then
+ set LogFilesDiffLines = $LogFilesDiff
+ endif
+endif
+
+# Preliminary error checking:
+if ( ! $?CygTestLogs ) then
+ echo 'Please define a shell environment variable called CygTestLogs'
+ echo ' whose value is the path to the Cygwin test-results directory.'
+ exit 1
+endif
+
+set TArgFiles = `find . -name TestArgs -exec expr {} : '\./\(.*\)' \;`
+if ( $#TArgFiles == 0 ) then
+ echo 'No TestArgs files found in subdirectories.'
+ echo 'Starting in wrong directory?'
+ exit 2
+endif
+
+set TArgReslts = `find $CygTestLogs -name TestArgs -exec expr {} : $CygTestLogs/'\(.*\)' \;`
+if ( $#TArgReslts != $#TArgFiles ) then
+ echo 'Number of TestArgs files in CygTestLogs ('$CygTestLogs') directory'
+ echo ' does not match those found under current directory.'
+ echo 'Please correct discrepancy and try again.'
+ exit 4
+endif
+
+if ( "$TArgReslts" != "$TArgFiles" ) then
+ echo 'List of TestArgs files in CygTestLogs ('$CygTestLogs') directory'
+ echo ' does not match those found under current directory.'
+ echo 'Please correct discrepancy and try again.'
+ exit 8
+endif
+
+# Let's save mismatch identifiers:
+set datemark = `date '+%y%m%d.%H%M%S'`
+set ErrResltFil = AutoComp.Log.$datemark
+set ScriptResltFil = AutoComp.TKdiffs.$datemark
+
+# Let's show a progress-downcount
+# Find the count of actual tests; leave the max number on display:
+set cnt = `egrep '^[^#].*' $TArgFiles | wc -l`
+echo ''
+echo $cnt
+
+foreach TArgFil ( $TArgFiles )
+ set dir = $TArgFil:h
+
+ set lindxmax = `cat $TArgFil | wc -l`
+ set lindx = 0
+ while ( $lindx < $lindxmax )
+ @ lindx++
+ set targline = `sed -n ${lindx}p $TArgFil`
+ if ( $#targline == 0 ) continue
+ if ( "$targline[1]" == "#" ) continue
+ set ttarg = $dir/$targline[1]
+# One more error-check:
+ if ( ! -f ${ttarg}.fth ) then
+ echo File Not found: ${ttarg}.fth
+ echo Please update ${TArgFil} file, line $lindx
+ continue
+ endif
+
+ set label = `echo $targline | awk -F , '{print $2}'`
+ if ( "$label" != "" ) set label = .$label
+
+# Now begins the real fun...
+# Show a running down-count
+ echo -n X${cnt}' ' | tr X \\015
+ @ cnt--
+
+# Check the extensions that are text-type files
+ foreach txext ( Log RomHdr fl fl.missing )
+# Is the file in both?
+ if ( -f $CygTestLogs/${ttarg}${label}.${txext} && ! -f ${ttarg}${label}.${txext} ) then
+ echo Missing ${ttarg}${label}.${txext} | tee -a $ErrResltFil
+ else
+ if ( -f ${ttarg}${label}.${txext} ) then
+ set lim = 0
+ set fxext = `echo $txext | tr '.' '_'`
+ if ( `eval echo '$?'${fxext}FilesDiffLines` ) then
+ set lim = `eval echo '$'${fxext}FilesDiffLines`
+ endif
+ set logdiff = `diff {,$CygTestLogs/}${ttarg}${label}.${txext} | wc -l`
+ if ( $logdiff > $lim ) then
+ echo ${ttarg}${label}.${txext} files differ. | tee -a $ErrResltFil
+ diff {$CygTestLogs/,}${ttarg}${label}.${txext} | tee -a $ErrResltFil
+ echo 'tkdiff {$CygTestLogs/,}'${ttarg}${label}.${txext} >> $ScriptResltFil
+ endif
+ endif
+ endif
+ end
+
+# Now, check the FCode file.
+# If there's an FCode file in the reference directory ($CygTestLogs)
+# there should be one in the directory under test.
+ if ( -f $CygTestLogs/${ttarg}${label}.fc && ! -f ${ttarg}${label}.fc ) then
+ echo Missing ${ttarg}${label}.fc | tee -a $ErrResltFil
+ else
+# Is there an FCode file in the directory under test?
+ unset ShowDetokDiffs
+ if ( -f ${ttarg}${label}.fc ) then
+ set bindiff = `cmp {,$CygTestLogs/}${ttarg}${label}.fc`
+ if ( "$bindiff" != "" ) then
+ echo "$bindiff" | tee -a $ErrResltFil
+# If the binaries are different, show the difference in the DeTok form
+# If the DeTok form is missing, it's an even stranger error!
+ if ( ! -f $CygTestLogs/${ttarg}${label}.DeTok || ! -f ${ttarg}${label}.DeTok ) then
+ echo Missing DeTok file for ${ttarg}${label} | tee -a $ErrResltFil
+ else
+ set ShowDetokDiffs
+ endif
+ else
+# Even if the binaries are not different,
+# check for changes in in the DeTok form
+ set detokdiff = `diff {,$CygTestLogs/}${ttarg}${label}.DeTok | wc -l`
+ if ( $detokdiff > 0 ) set ShowDetokDiffs
+ endif
+ endif
+ if ( $?ShowDetokDiffs ) then
+ echo ${ttarg}${label}.DeTok files differ. | tee -a $ErrResltFil
+ diff {$CygTestLogs/,}${ttarg}${label}.DeTok | tee -a $ErrResltFil
+ echo 'tkdiff {$CygTestLogs/,}'${ttarg}${label}.DeTok >> $ScriptResltFil
+ endif
+ endif
+
+ end
+end
+
+
diff --git a/testsuite/AutoExec b/testsuite/AutoExec
new file mode 100644
index 0000000..ece00a6
--- /dev/null
+++ b/testsuite/AutoExec
@@ -0,0 +1,164 @@
+#! /bin/csh -f
+#
+# Part of automation of the testing process for the Tokenizer/De-Tokenizer
+# Automate Execution of Tokenizing and De-Tokenizing the various test-cases
+
+# Updated Thu, 09 Feb 2006 at 13:10 PST by David L. Paktor
+
+# Run this from the parent-directory of the various Test categories.
+# Sym-links to the binaries should be here.
+
+# Each Test category directory must have a TestArgs file,
+# formatted as follows:
+# Lines starting with # (Pound-sign Space) are comments,
+# and are ignored
+# Blank lines are also allowed, and are also ignored
+# Valid lines have four comma-separated fields:
+# Test-file base-name
+# Result-file label
+# Extra command-line switches
+# A script-command, to be run after, for specific
+# verification of this Test. Arguments can also
+# be included in this field, as long as they have
+# no commas.
+# An unspecified intermediate field must be represented as
+# an empty field separated by commas from the fields
+# preceding and following.
+# Lines that have no label, no switches, and no script
+# do not need any commas.
+# The -v (verbose) switch will always be used and does not need
+# to be explicitly specified. However, if the "script-command"
+# field starts with +V (case-sensitive), then the -v (verbose)
+# switch will not be used.
+#
+# The Test-file base-name field may have multiple base-names,
+# to run a multiple-file batch command.
+# If a multiple-file batch is run:
+# The Result-file label will apply only to the Log file.
+
+# To Do:
+# Contrive a way to run the second through last input files as
+# separate individual jobs (with same command-line switches)
+# This needs to be co-ordinated with the Auto-Compare script:
+# It will need to compare the .FC files from the batch with
+# those from the individual runs.
+
+
+# Initial error-checking:
+if ( ( ! -x ./toke ) || ( ! -x ./detok ) ) then
+ echo 'Starting in wrong directory. Executable toke and detok are not here.'
+ exit 1
+endif
+
+set TArgFiles = `find . -name TestArgs -exec expr {} : '\./\(.*\)' \;`
+if ( $#TArgFiles == 0 ) then
+ echo 'No TestArgs files found in subdirectories.'
+ echo 'Starting in wrong directory?'
+ exit 1
+endif
+
+set parent = `pwd`
+set tokex = `pwd`/toke
+set detokex = `pwd`/detok
+set romhdrex = `pwd`/romheaders
+
+set chirren = `echo $TArgFiles | tr ' ' \\012 | sed -e 'sX/[^/]*$XXg'`
+
+# The "verbose" flag is now a variable.
+set vflg = '-v'
+
+# Let's show a progress-downcount and time, stamps and elapsed.
+# Find the count; leave the max number on display:
+set cnt = `egrep '^[^#].*' $TArgFiles | wc -l`
+echo ''
+set starttime = `date +'%T'`
+echo $starttime
+echo $cnt
+
+foreach dir ( $chirren )
+ cd $dir
+ set lindxmax = `cat TestArgs | wc -l`
+ set lindx = 0
+ while ( $lindx < $lindxmax )
+ @ lindx++
+ set targline = `sed -n ${lindx}p TestArgs`
+ if ( $#targline == 0 ) continue
+ if ( "$targline[1]" == "#" ) continue
+ set ttargs = `echo $targline | awk -F , '{print $1}'`
+# One more error-check:
+ set tfths = ''
+ set fcfils = ''
+ unset FMissing
+ foreach tfth ( $ttargs )
+ if ( ! -f ${tfth}.fth ) then
+ echo File Not found: ${dir}/${tfth}.fth
+ echo Please update ${dir}/TestArgs file, line $lindx
+ set FMissing
+ endif
+ set tfths = ( $tfths ${tfth}.fth )
+ set fcfils = ( $fcfils ${tfth}.fc )
+ end
+ if ( $?FMissing ) continue
+
+ set ttarg = $ttargs[1]
+
+ set outfile = ''
+ set label = `echo $targline | awk -F , '{print $2}'`
+ if ( "$label" != "" ) then
+ set label = .$label
+ if ( $#tfths == 1 ) then
+ set fcfils = ${ttarg}${label}.fc
+ set outfile = ( -o $fcfils )
+ endif
+ endif
+# We don't set the switches as a shell-variable because we might
+# need to preserve quoted groupings that have embedded spaces.
+
+# Collect the script-command.
+# Awkward place to expect a "+V" option, but it'll have to serve....
+ set scriptcmd = `echo $targline | awk -F , '{print $4}'`
+ if ( $#scriptcmd > 0 ) then
+ if ( "$scriptcmd[1]" == "+V" ) then
+ set vflg = ""
+ if ( $#scriptcmd == 1 ) then
+ set scriptcmd = ""
+ else
+ set scriptcmd = ( $scriptcmd[2-] )
+ endif
+ endif
+ endif
+
+ echo -n X${cnt}' ' | tr X \\015
+ @ cnt--
+
+# Now do it.
+ set doromhdr = 0
+ echo toke $vflg `sed -n ${lindx}p TestArgs | awk -F , '{print $3}'` $outfile ${tfths} >& ${ttarg}${label}.Log
+ echo '' >>& ${ttarg}${label}.Log
+ eval $tokex $vflg `sed -n ${lindx}p TestArgs | awk -F , '{print $3}'` $outfile ${tfths} >>& ${ttarg}${label}.Log
+ set vflg = '-v'
+
+ foreach fcfil ( $fcfils )
+ if ( -f ${fcfil} ) then
+ $detokex -v -o ${fcfil} > ${fcfil:r}.DeTok
+ set doromhdr = `grep 'PCI Header identified' ${fcfil:r}.DeTok | wc -l`
+ if ( $doromhdr ) then
+ $romhdrex ${fcfil} > ${fcfil:r}.RomHdr
+ endif
+ endif
+ end
+
+
+ if ( "$scriptcmd" != "" ) then
+ eval $scriptcmd
+ endif
+
+ end
+ cd $parent
+end
+# Clear the display-line
+echo -n X' 'X | tr X \\015
+# Show time, stamps and elapsed.
+date +'%T'
+echo $starttime ' (Started)'
+