summaryrefslogtreecommitdiff
path: root/tests/utils/digest.pp
blob: c11c2ea7a61fc21ddc514490d5cb06b781104e14 (plain)
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
{
    This file is part of the Free Pascal test suite.
    Copyright (c) 2002 by the Free Pascal development team.

    This program generates a digest
    of the last tests run.

    See the file COPYING.FPC, included in this distribution,
    for details about the copyright.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

 **********************************************************************}

program digest;

uses
  teststr;


const
  failed_to_compile_count : longint = 0;
  success_compilation_failed_count : longint = 0;
  failed_compilation_successful_count : longint = 0;
  successfully_compiled_count : longint = 0;
  failed_to_run_count : longint = 0;
  known_run_problem : longint = 0;
  successfully_run_count : longint = 0;
  skipping_graph_test_count : longint = 0;
  skipping_interactive_test_count : longint = 0;
  skipping_known_bug_count : longint = 0;
  skipping_other_version_count : longint = 0;
  skipping_other_cpu_count : longint = 0;
  skipping_other_target_count : longint = 0;
  skipping_run_unit_count : longint = 0;
  skipping_run_test_count : longint = 0;
  unknown_lines : longint = 0;
  unexpected_run : longint = 0;
  next_should_be_run : boolean = false;

var
  prevline : string;

procedure analyse (const st : string);
var
  should_be_run : boolean;
begin
  if st=prevline then
    exit;
  prevline:=st;
  should_be_run:=next_should_be_run;
  if next_should_be_run and
     (pos(failed_to_run,st)<>1) and
     (pos(successfully_run,st)<>1) and
     (pos(skipping_known_bug,st)<>1) and
     (pos(skipping_run_test,st)<>1) and
     (pos(skipping_run_unit,st)<>1) then
    begin
      Writeln('No run found for "',prevline,'"');
    end;
  next_should_be_run:=false;
  if pos(failed_to_compile,st)=1 then
    begin
      inc(failed_to_compile_count);
    end
  else if pos(success_compilation_failed,st)=1 then
    begin
      inc(success_compilation_failed_count);
    end
  else if pos(failed_compilation_successful,st)=1 then
    begin
      inc(failed_compilation_successful_count);
    end
  else if pos(successfully_compiled,st)=1 then
    begin
      inc(successfully_compiled_count);
      next_should_be_run:=true;
    end
  else if (pos(failed_to_run,st)=1) then
    begin
      inc(failed_to_run_count);
      if not should_be_run then
        inc(unexpected_run);
      if pos(known_problem,st)>0 then
        inc(known_run_problem);
    end
  else if pos(successfully_run,st)=1 then
    begin
      inc(successfully_run_count);
      if not should_be_run then
        inc(unexpected_run);
    end
  else if pos(skipping_graph_test,st)=1 then
    begin
      inc(skipping_graph_test_count);
    end
  else if pos(skipping_interactive_test,st)=1 then
    begin
      inc(skipping_interactive_test_count);
    end
  else if pos(skipping_known_bug,st)=1 then
    begin
      inc(skipping_known_bug_count);
    end
  else if pos(skipping_compiler_version_too_low,st)=1 then
    begin
      inc(skipping_other_version_count);
    end
  else if pos(skipping_compiler_version_too_high,st)=1 then
    begin
      inc(skipping_other_version_count);
    end
  else if pos(skipping_other_cpu,st)=1 then
    begin
      inc(skipping_other_cpu_count);
    end
  else if pos(skipping_other_target,st)=1 then
    begin
      inc(skipping_other_target_count);
    end
  else if pos(skipping_run_unit,st)=1 then
    begin
      inc(skipping_run_unit_count);
    end
  else if pos(skipping_run_test,st)=1 then
    begin
      inc(skipping_run_test_count);
    end
  else
    begin
      Writeln('Unknown line "',st,'"');
      inc(unknown_lines);
    end;
end;

procedure display_results;
var
  number_compilations : longint;
  number_skipped : longint;
  number_runs : longint;
  all_errors : longint;
  all_success : longint;

begin
  all_errors:=failed_to_compile_count
    +failed_compilation_successful_count
    +failed_to_run_count;
  all_success:=success_compilation_failed_count
    +successfully_compiled_count
    +successfully_run_count;
  { about compilations }
  number_compilations:=failed_to_compile_count
    +success_compilation_failed_count
    +failed_compilation_successful_count
    +successfully_compiled_count;
  { about runs }
  number_runs:=failed_to_run_count+successfully_run_count;

  Writeln('Total = ',number_compilations+number_runs,' (',
    all_errors,':',
    all_success,')');

  Writeln('Total number of compilations = ', number_compilations,' (',
    failed_to_compile_count+failed_compilation_successful_count,':',
    successfully_compiled_count+success_compilation_failed_count,')');
  Writeln('Successfully compiled = ', successfully_compiled_count);
  Writeln('Successfully failed = ', success_compilation_failed_count);
  Writeln('Compilation failures = ', failed_to_compile_count);
  Writeln('Compilation that did not fail while they should = ', failed_compilation_successful_count);

  Writeln('Total number of runs = ', number_runs,' (',
    failed_to_run_count,':',
    successfully_run_count,')');
  Writeln('Successful runs = ', successfully_run_count);
  Writeln('Failed runs = ', failed_to_run_count);
  if known_run_problem>0 then
    Writeln('From these ',known_run_problem,' known problems');

  if successfully_compiled_count <>
     number_runs+skipping_run_unit_count+skipping_run_test_count then
    begin
      Writeln('Number units compiled = ',skipping_run_unit_count);
      Writeln('Number program that should not be run = ',skipping_run_test_count);
    end;
  { about skipped tests }
  number_skipped:= skipping_graph_test_count
    +skipping_interactive_test_count
    +skipping_known_bug_count
    +skipping_other_version_count
    +skipping_other_cpu_count
    +skipping_other_target_count;
  { don't count these ones ...
    skipping_run_unit_count
    skipping_run_test_count }
  Writeln('Number of skipped tests = ',number_skipped);
  Writeln('Number of skipped graph tests = ',skipping_graph_test_count);
  Writeln('Number of skipped interactive tests = ',skipping_interactive_test_count);
  Writeln('Number of skipped known bug tests = ',skipping_known_bug_count);
  Writeln('Number of skipped tests for other versions = ',skipping_other_version_count);
  Writeln('Number of skipped tests for other cpus = ',skipping_other_cpu_count);
  Writeln('Number of skipped tests for other targets = ',skipping_other_target_count);
  if unknown_lines>0 then
    Writeln('Number of unrecognized lines = ',unknown_lines);

  if unexpected_run>0 then
    Writeln('Number of unexpected runs = ',unexpected_run);
end;

var
  logfile : text;
  logfilename,
  line : string;

begin
  if Paramcount>0 then
    logfilename:=Paramstr(1)
  else
    logfilename:=ResLogfile;

  assign(logfile,logfilename);
{$i-}
  reset(logfile);
  if ioresult<>0 then
    begin
      Writeln('Unable to open ',logfilename);
      halt(1);
    end;
{$i+}
  while not eof(logfile) do
    begin
      readln(logfile,line);
      analyse(line);
    end;
  close(logfile);
  display_results;
end.