| 1 | #! /bin/csh -f |
|---|
| 2 | # |
|---|
| 3 | # Part of automation of the testing process for the Tokenizer/De-Tokenizer |
|---|
| 4 | # Automate Execution of Tokenizing and De-Tokenizing the various test-cases |
|---|
| 5 | |
|---|
| 6 | # Updated Thu, 09 Feb 2006 at 13:10 PST by David L. Paktor |
|---|
| 7 | |
|---|
| 8 | # Run this from the parent-directory of the various Test categories. |
|---|
| 9 | # Sym-links to the binaries should be here. |
|---|
| 10 | |
|---|
| 11 | # Each Test category directory must have a TestArgs file, |
|---|
| 12 | # formatted as follows: |
|---|
| 13 | # Lines starting with # (Pound-sign Space) are comments, |
|---|
| 14 | # and are ignored |
|---|
| 15 | # Blank lines are also allowed, and are also ignored |
|---|
| 16 | # Valid lines have four comma-separated fields: |
|---|
| 17 | # Test-file base-name |
|---|
| 18 | # Result-file label |
|---|
| 19 | # Extra command-line switches |
|---|
| 20 | # A script-command, to be run after, for specific |
|---|
| 21 | # verification of this Test. Arguments can also |
|---|
| 22 | # be included in this field, as long as they have |
|---|
| 23 | # no commas. |
|---|
| 24 | # An unspecified intermediate field must be represented as |
|---|
| 25 | # an empty field separated by commas from the fields |
|---|
| 26 | # preceding and following. |
|---|
| 27 | # Lines that have no label, no switches, and no script |
|---|
| 28 | # do not need any commas. |
|---|
| 29 | # The -v (verbose) switch will always be used and does not need |
|---|
| 30 | # to be explicitly specified. However, if the "script-command" |
|---|
| 31 | # field starts with +V (case-sensitive), then the -v (verbose) |
|---|
| 32 | # switch will not be used. |
|---|
| 33 | # |
|---|
| 34 | # The Test-file base-name field may have multiple base-names, |
|---|
| 35 | # to run a multiple-file batch command. |
|---|
| 36 | # If a multiple-file batch is run: |
|---|
| 37 | # The Result-file label will apply only to the Log file. |
|---|
| 38 | |
|---|
| 39 | # To Do: |
|---|
| 40 | # Contrive a way to run the second through last input files as |
|---|
| 41 | # separate individual jobs (with same command-line switches) |
|---|
| 42 | # This needs to be co-ordinated with the Auto-Compare script: |
|---|
| 43 | # It will need to compare the .FC files from the batch with |
|---|
| 44 | # those from the individual runs. |
|---|
| 45 | |
|---|
| 46 | |
|---|
| 47 | # Initial error-checking: |
|---|
| 48 | if ( ( ! -x ./toke ) || ( ! -x ./detok ) || ( ! -x ./romheaders ) ) then |
|---|
| 49 | echo 'Starting in wrong directory. Executable toke, detok and romheaders are not here.' |
|---|
| 50 | exit 1 |
|---|
| 51 | endif |
|---|
| 52 | |
|---|
| 53 | set TArgFiles = `find . -name TestArgs -exec expr {} : '\./\(.*\)' \;` |
|---|
| 54 | if ( $#TArgFiles == 0 ) then |
|---|
| 55 | echo 'No TestArgs files found in subdirectories.' |
|---|
| 56 | echo 'Starting in wrong directory?' |
|---|
| 57 | exit 1 |
|---|
| 58 | endif |
|---|
| 59 | |
|---|
| 60 | set parent = `pwd` |
|---|
| 61 | set tokex = `pwd`/toke |
|---|
| 62 | set detokex = `pwd`/detok |
|---|
| 63 | set romhdrex = `pwd`/romheaders |
|---|
| 64 | |
|---|
| 65 | set chirren = `echo $TArgFiles | tr ' ' \\012 | sed -e 'sX/[^/]*$XXg'` |
|---|
| 66 | |
|---|
| 67 | # The "verbose" flag is now a variable. |
|---|
| 68 | set vflg = '-v' |
|---|
| 69 | |
|---|
| 70 | # Let's show a progress-downcount and time, stamps and elapsed. |
|---|
| 71 | # Find the count; leave the max number on display: |
|---|
| 72 | set cnt = `egrep '^[^#].*' $TArgFiles | wc -l` |
|---|
| 73 | echo '' |
|---|
| 74 | set starttime = `date +'%T'` |
|---|
| 75 | echo $starttime |
|---|
| 76 | echo $cnt |
|---|
| 77 | |
|---|
| 78 | foreach dir ( $chirren ) |
|---|
| 79 | cd $dir |
|---|
| 80 | set lindxmax = `cat TestArgs | wc -l` |
|---|
| 81 | set lindx = 0 |
|---|
| 82 | while ( $lindx < $lindxmax ) |
|---|
| 83 | @ lindx++ |
|---|
| 84 | set targline = `sed -n ${lindx}p TestArgs` |
|---|
| 85 | if ( $#targline == 0 ) continue |
|---|
| 86 | if ( "$targline[1]" == "#" ) continue |
|---|
| 87 | set ttargs = `echo $targline | awk -F , '{print $1}'` |
|---|
| 88 | # One more error-check: |
|---|
| 89 | set tfths = '' |
|---|
| 90 | set fcfils = '' |
|---|
| 91 | unset FMissing |
|---|
| 92 | foreach tfth ( $ttargs ) |
|---|
| 93 | if ( ! -f ${tfth}.fth ) then |
|---|
| 94 | echo File Not found: ${dir}/${tfth}.fth |
|---|
| 95 | echo Please update ${dir}/TestArgs file, line $lindx |
|---|
| 96 | set FMissing |
|---|
| 97 | endif |
|---|
| 98 | set tfths = ( $tfths ${tfth}.fth ) |
|---|
| 99 | set fcfils = ( $fcfils ${tfth}.fc ) |
|---|
| 100 | end |
|---|
| 101 | if ( $?FMissing ) continue |
|---|
| 102 | |
|---|
| 103 | set ttarg = $ttargs[1] |
|---|
| 104 | |
|---|
| 105 | set outfile = '' |
|---|
| 106 | set label = `echo $targline | awk -F , '{print $2}'` |
|---|
| 107 | if ( "$label" != "" ) then |
|---|
| 108 | set label = .$label |
|---|
| 109 | if ( $#tfths == 1 ) then |
|---|
| 110 | set fcfils = ${ttarg}${label}.fc |
|---|
| 111 | set outfile = ( -o $fcfils ) |
|---|
| 112 | endif |
|---|
| 113 | endif |
|---|
| 114 | # We don't set the switches as a shell-variable because we might |
|---|
| 115 | # need to preserve quoted groupings that have embedded spaces. |
|---|
| 116 | |
|---|
| 117 | # Collect the script-command. |
|---|
| 118 | # Awkward place to expect a "+V" option, but it'll have to serve.... |
|---|
| 119 | set scriptcmd = `echo $targline | awk -F , '{print $4}'` |
|---|
| 120 | if ( $#scriptcmd > 0 ) then |
|---|
| 121 | if ( "$scriptcmd[1]" == "+V" ) then |
|---|
| 122 | set vflg = "" |
|---|
| 123 | if ( $#scriptcmd == 1 ) then |
|---|
| 124 | set scriptcmd = "" |
|---|
| 125 | else |
|---|
| 126 | set scriptcmd = ( $scriptcmd[2-] ) |
|---|
| 127 | endif |
|---|
| 128 | endif |
|---|
| 129 | endif |
|---|
| 130 | |
|---|
| 131 | echo -n X${cnt}' ' | tr X \\015 |
|---|
| 132 | @ cnt-- |
|---|
| 133 | |
|---|
| 134 | # Now do it. |
|---|
| 135 | set doromhdr = 0 |
|---|
| 136 | echo toke $vflg `sed -n ${lindx}p TestArgs | awk -F , '{print $3}'` $outfile ${tfths} >& ${ttarg}${label}.Log |
|---|
| 137 | echo '' >>& ${ttarg}${label}.Log |
|---|
| 138 | eval $tokex $vflg `sed -n ${lindx}p TestArgs | awk -F , '{print $3}'` $outfile ${tfths} >>& ${ttarg}${label}.Log |
|---|
| 139 | set vflg = '-v' |
|---|
| 140 | |
|---|
| 141 | foreach fcfil ( $fcfils ) |
|---|
| 142 | if ( -f ${fcfil} ) then |
|---|
| 143 | $detokex -v -o ${fcfil} > ${fcfil:r}.DeTok |
|---|
| 144 | set doromhdr = `grep 'PCI Header identified' ${fcfil:r}.DeTok | wc -l` |
|---|
| 145 | if ( $doromhdr ) then |
|---|
| 146 | $romhdrex ${fcfil} > ${fcfil:r}.RomHdr |
|---|
| 147 | endif |
|---|
| 148 | endif |
|---|
| 149 | end |
|---|
| 150 | |
|---|
| 151 | |
|---|
| 152 | if ( "$scriptcmd" != "" ) then |
|---|
| 153 | eval $scriptcmd |
|---|
| 154 | endif |
|---|
| 155 | |
|---|
| 156 | end |
|---|
| 157 | cd $parent |
|---|
| 158 | end |
|---|
| 159 | # Clear the display-line |
|---|
| 160 | echo -n X' 'X | tr X \\015 |
|---|
| 161 | # Show time, stamps and elapsed. |
|---|
| 162 | date +'%T' |
|---|
| 163 | echo $starttime ' (Started)' |
|---|