root/fcode-utils/testsuite/AutoCompare

Revision 92, 6.8 KB (checked in by stepan, 2 years ago)

add testsuite scripts

Line 
1#!  /bin/csh -f
2#
3#  Part of automation of the testing process for the Tokenizer/De-Tokenizer
4#  Automate Comparison of results of Auto-Execution of the various test-cases
5
6#  Updated Fri, 16 Jun 2006 at 12:12 PDT by David L. Paktor
7
8#  To Do:
9#    Conditional comparison of .DeTok files:
10#        Detect difference in .fc file, but do not display
11#        Display differences in .Log file
12#        If difference detected in .fc file, display mssg
13#        Otherwise, detect difference in .DeTok file and display mssg
14#        If either diff detected in .fc  or in .DeTok file, show .DeTok  diffs
15#        Display differences in .RomHdr
16#
17#    Compare the source (.fth) files (for regression testing...)
18
19#  Usage:
20#  Run this from the parent-directory of the various Test categories.
21#  This script uses the same  TestArgs  files that were used by
22#     (and described in) the  AutoExec  script.
23#
24#  This script needs a shell environment variable called  CygTestLogs
25#      whose value is the path to the parent-directory that contains
26#      the results of Auto-Execution of the various test-cases under
27#      Cygwin, which is the "Gold Standard" to which the other
28#      platforms' results will be compared.
29#
30#  This script accepts an optional environment variable called  LogFilesDiff
31#      which may be set to change the number of lines by which two .Log
32#      files are expected to differ (due to different compilation-signatures)
33#      If this is not supplied in the environment, a default will be provided.
34#
35#  This script compares only one platform's results at a time;
36#      the parent-directory that contains the Auto-Execution  results
37#      for the platform to be compared should be the current directory.
38#
39#  This script displays both operational errors and detected discrepancies
40#      in Standard Output and also collects the same in a log file whose
41#      name is  AutoComp.Log.<time-and-date-stamp>
42#
43#  A secondary output file, called AutoComp.TKdiffs.<time-and-date-stamp>
44#      is produced; it can be "source"d to cause a sequential  tkdiff  of
45#      the detected discrepancies
46
47
48#  Set the number of lines by which two .Log files are expected to differ.
49#      (this is due to different compilation-signature lines)
50set LogFilesDiffLines = 6
51#  Over-ride with optional shell env't variable called  LogFilesDiff
52if ( $?LogFilesDiff ) then
53    set notallnumbers = `echo $LogFilesDiff | tr '0-9' ' '`
54    if ( "$notallnumbers" == "" ) then
55        set LogFilesDiffLines = $LogFilesDiff
56    endif
57endif
58
59#  Preliminary error checking:
60if ( ! $?CygTestLogs ) then
61    echo 'Please define a shell environment variable called  CygTestLogs'
62    echo '    whose value is the path to the Cygwin test-results directory.'
63    exit 1
64endif
65
66set TArgFiles = `find . -name TestArgs -exec expr {} : '\./\(.*\)' \;`
67if ( $#TArgFiles == 0 ) then
68    echo 'No TestArgs files found in subdirectories.'
69    echo 'Starting in wrong directory?'
70    exit 2
71endif
72
73set TArgReslts = `find $CygTestLogs -name TestArgs -exec expr {} : $CygTestLogs/'\(.*\)' \;`
74if ( $#TArgReslts != $#TArgFiles ) then
75    echo 'Number of TestArgs files in CygTestLogs ('$CygTestLogs') directory'
76    echo '    does not match those found under current directory.'
77    echo 'Please correct discrepancy and try again.'
78    exit 4
79endif
80
81if ( "$TArgReslts" != "$TArgFiles" ) then
82    echo 'List of TestArgs files in CygTestLogs ('$CygTestLogs') directory'
83    echo '    does not match those found under current directory.'
84    echo 'Please correct discrepancy and try again.'
85    exit 8
86endif
87
88#  Let's save mismatch identifiers:
89set datemark = `date '+%y%m%d.%H%M%S'`
90set ErrResltFil = AutoComp.Log.$datemark
91set ScriptResltFil = AutoComp.TKdiffs.$datemark
92
93#  Let's show a progress-downcount
94#  Find the count of actual tests; leave the max number on display:
95set cnt = `egrep '^[^#].*' $TArgFiles | wc -l`
96echo ''
97echo $cnt
98
99foreach TArgFil ( $TArgFiles )
100   set dir = $TArgFil:h
101
102   set lindxmax = `cat $TArgFil | wc -l`
103   set lindx = 0
104   while ( $lindx < $lindxmax )
105      @ lindx++
106      set targline = `sed -n ${lindx}p $TArgFil`
107      if ( $#targline == 0 ) continue
108      if ( "$targline[1]" == "#" ) continue
109      set ttarg = $dir/$targline[1]
110#  One more error-check:
111      if ( ! -f ${ttarg}.fth ) then
112         echo File Not found: ${ttarg}.fth
113         echo Please update ${TArgFil} file, line $lindx
114         continue
115      endif
116
117      set label = `echo $targline | awk -F , '{print $2}'`
118      if ( "$label" != "" ) set label = .$label
119
120#  Now begins the real fun...
121#  Show a running down-count
122      echo -n X${cnt}' ' | tr X \\015
123      @ cnt--
124
125#  Check the extensions that are text-type files
126      foreach txext ( Log RomHdr fl fl.missing )
127#  Is the file in both?
128         if ( -f $CygTestLogs/${ttarg}${label}.${txext} && ! -f ${ttarg}${label}.${txext} ) then
129             echo Missing ${ttarg}${label}.${txext} | tee -a $ErrResltFil
130         else
131             if ( -f ${ttarg}${label}.${txext} ) then
132                set lim = 0
133                set fxext = `echo $txext | tr '.' '_'`
134                if ( `eval echo '$?'${fxext}FilesDiffLines` ) then
135                    set lim = `eval echo '$'${fxext}FilesDiffLines`
136                endif
137                set logdiff = `diff {,$CygTestLogs/}${ttarg}${label}.${txext} | wc -l`
138                if ( $logdiff > $lim ) then
139                    echo ${ttarg}${label}.${txext} files differ. | tee -a $ErrResltFil
140                    diff {$CygTestLogs/,}${ttarg}${label}.${txext} | tee -a $ErrResltFil
141                    echo  'tkdiff {$CygTestLogs/,}'${ttarg}${label}.${txext} >> $ScriptResltFil
142                endif
143             endif
144         endif
145      end
146
147#  Now, check the FCode file.
148#  If there's an FCode file in the reference directory ($CygTestLogs)
149#      there should be one in the directory under test.
150      if ( -f $CygTestLogs/${ttarg}${label}.fc && ! -f ${ttarg}${label}.fc ) then
151          echo Missing ${ttarg}${label}.fc | tee -a $ErrResltFil
152      else
153#  Is there an FCode file in the directory under test?
154          unset ShowDetokDiffs
155          if ( -f ${ttarg}${label}.fc ) then
156             set bindiff = `cmp {,$CygTestLogs/}${ttarg}${label}.fc`
157             if ( "$bindiff" != "" ) then
158                echo "$bindiff" | tee -a $ErrResltFil
159#  If the binaries are different, show the difference in the DeTok form
160#  If the DeTok form is missing, it's an even stranger error!
161                if ( ! -f $CygTestLogs/${ttarg}${label}.DeTok || ! -f ${ttarg}${label}.DeTok ) then
162                    echo Missing DeTok file for ${ttarg}${label} | tee -a $ErrResltFil
163                else
164                    set ShowDetokDiffs
165                endif
166             else
167#  Even if the binaries are not different,
168#      check for changes in in the DeTok form
169             set detokdiff = `diff {,$CygTestLogs/}${ttarg}${label}.DeTok | wc -l`
170             if ( $detokdiff > 0 ) set ShowDetokDiffs
171             endif
172          endif
173          if ( $?ShowDetokDiffs ) then
174            echo ${ttarg}${label}.DeTok files differ. | tee -a $ErrResltFil
175            diff {$CygTestLogs/,}${ttarg}${label}.DeTok | tee -a $ErrResltFil
176            echo  'tkdiff {$CygTestLogs/,}'${ttarg}${label}.DeTok >> $ScriptResltFil
177          endif
178      endif
179
180   end
181end
182
Note: See TracBrowser for help on using the browser.