• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2 // -*- Mode: C++ -*-
3 //
4 // Copyright (C) 2013-2022 Red Hat, Inc.
5 //
6 // Author: Dodji Seketeli
7 
8 /// @file
9 ///
10 /// This program runs a diff between input ELF files containing DWARF
11 /// debugging information and compares the resulting report with a
12 /// reference report.  If the resulting report is different from the
13 /// reference report, the test has failed.  Note that the comparison
14 /// is done using the abidiff command line comparison tool.
15 ///
16 /// The set of input files and reference reports to consider should be
17 /// present in the source distribution.
18 
19 #include <sys/wait.h>
20 #include <cassert>
21 #include <cstdlib>
22 #include <fstream>
23 #include <iostream>
24 #include <memory>
25 #include <string>
26 #include "abg-workers.h"
27 #include "abg-tools-utils.h"
28 #include "test-utils.h"
29 
30 using std::string;
31 using std::cerr;
32 
33 /// This is an aggregate that specifies where a test shall get its
34 /// input from and where it shall write its ouput to.
35 struct InOutSpec
36 {
37   const char* in_elfv0_path;
38   const char* in_elfv1_path;
39   const char* abidiff_options;
40   const char* in_report_path;
41   const char* out_report_path;
42 }; // end struct InOutSpec;
43 
44 InOutSpec in_out_specs[] =
45 {
46   {
47     "data/test-diff-filter/test0-v0.o",
48     "data/test-diff-filter/test0-v1.o",
49     "--no-default-suppression --no-linkage-name --no-show-locs --no-redundant",
50     "data/test-diff-filter/test0-report.txt",
51     "output/test-diff-filter/test0-report.txt",
52   },
53   {
54     "data/test-diff-filter/test0-v0.o",
55     "data/test-diff-filter/test0-v1.o",
56     "--no-default-suppression --harmless --no-linkage-name "
57     "--no-show-locs --no-redundant",
58     "data/test-diff-filter/test01-report.txt",
59     "output/test-diff-filter/test01-report.txt",
60   },
61   {
62     "data/test-diff-filter/test1-v0.o",
63     "data/test-diff-filter/test1-v1.o",
64     "--no-default-suppression --no-linkage-name --no-show-locs --no-redundant",
65     "data/test-diff-filter/test1-report.txt",
66     "output/test-diff-filter/test1-report.txt",
67   },
68   {
69     "data/test-diff-filter/test2-v0.o",
70     "data/test-diff-filter/test2-v1.o",
71     "--no-default-suppression --no-linkage-name --no-show-locs --no-redundant",
72     "data/test-diff-filter/test2-report.txt",
73     "output/test-diff-filter/test2-report.txt",
74   },
75   {
76     "data/test-diff-filter/test3-v0.o",
77     "data/test-diff-filter/test3-v1.o",
78     "--no-default-suppression --no-linkage-name --no-show-locs --no-redundant",
79     "data/test-diff-filter/test3-report.txt",
80     "output/test-diff-filter/test3-report.txt",
81   },
82   {
83     "data/test-diff-filter/test4-v0.o",
84     "data/test-diff-filter/test4-v1.o",
85     "--no-default-suppression --no-linkage-name --no-show-locs --no-redundant",
86     "data/test-diff-filter/test4-report.txt",
87     "output/test-diff-filter/test4-report.txt",
88   },
89   {
90     "data/test-diff-filter/test5-v0.o",
91     "data/test-diff-filter/test5-v1.o",
92     "--no-default-suppression --no-linkage-name --no-show-locs --no-redundant",
93     "data/test-diff-filter/test5-report.txt",
94     "output/test-diff-filter/test5-report.txt",
95   },
96   {
97     "data/test-diff-filter/test6-v0.o",
98     "data/test-diff-filter/test6-v1.o",
99     "--no-default-suppression --no-linkage-name --no-show-locs --no-redundant",
100     "data/test-diff-filter/test6-report.txt",
101     "output/test-diff-filter/test6-report.txt",
102   },
103   {
104     "data/test-diff-filter/test7-v0.o",
105     "data/test-diff-filter/test7-v1.o",
106     "--no-default-suppression --no-linkage-name --no-show-locs --no-redundant",
107     "data/test-diff-filter/test7-report.txt",
108     "output/test-diff-filter/test7-report.txt",
109   },
110   {
111     "data/test-diff-filter/test8-v0.o",
112     "data/test-diff-filter/test8-v1.o",
113     "--no-default-suppression --no-linkage-name --no-show-locs --no-redundant",
114     "data/test-diff-filter/test8-report.txt",
115     "output/test-diff-filter/test8-report.txt",
116   },
117   {
118     "data/test-diff-filter/test9-v0.o",
119     "data/test-diff-filter/test9-v1.o",
120     "--no-default-suppression --no-linkage-name --no-show-locs --no-redundant",
121     "data/test-diff-filter/test9-report.txt",
122     "output/test-diff-filter/test9-report.txt",
123   },
124   {
125     "data/test-diff-filter/test10-v0.o",
126     "data/test-diff-filter/test10-v1.o",
127     "--no-default-suppression --no-linkage-name --no-show-locs --no-redundant",
128     "data/test-diff-filter/test10-report.txt",
129     "output/test-diff-filter/test10-report.txt",
130   },
131   {
132     "data/test-diff-filter/test11-v0.o",
133     "data/test-diff-filter/test11-v1.o",
134     "--no-default-suppression --no-linkage-name --no-show-locs --no-redundant",
135     "data/test-diff-filter/test11-report.txt",
136     "output/test-diff-filter/test11-report.txt",
137   },
138   {
139     "data/test-diff-filter/test12-v0.o",
140     "data/test-diff-filter/test12-v1.o",
141     "--no-default-suppression --no-linkage-name --no-show-locs --no-redundant",
142     "data/test-diff-filter/test12-report.txt",
143     "output/test-diff-filter/test12-report.txt",
144   },
145   {
146     "data/test-diff-filter/test13-v0.o",
147     "data/test-diff-filter/test13-v1.o",
148     "--no-default-suppression --no-linkage-name --no-show-locs --no-redundant",
149     "data/test-diff-filter/test13-report.txt",
150     "output/test-diff-filter/test13-report.txt",
151   },
152   {
153     "data/test-diff-filter/test14-v0.o",
154     "data/test-diff-filter/test14-v1.o",
155     "--no-default-suppression --no-show-locs --no-redundant",
156     "data/test-diff-filter/test14-0-report.txt",
157     "output/test-diff-filter/test14-0-report.txt",
158   },
159   {
160     "data/test-diff-filter/test14-v0.o",
161     "data/test-diff-filter/test14-v1.o",
162     "--no-default-suppression --no-show-locs --redundant",
163     "data/test-diff-filter/test14-1-report.txt",
164     "output/test-diff-filter/test14-1-report.txt",
165   },
166   {
167     "data/test-diff-filter/test15-v0.o",
168     "data/test-diff-filter/test15-v1.o",
169     "--no-default-suppression --no-show-locs --no-redundant",
170     "data/test-diff-filter/test15-0-report.txt",
171     "output/test-diff-filter/test15-0-report.txt",
172   },
173   {
174     "data/test-diff-filter/test15-v0.o",
175     "data/test-diff-filter/test15-v1.o",
176     "--no-default-suppression --no-show-locs --redundant",
177     "data/test-diff-filter/test15-1-report.txt",
178     "output/test-diff-filter/test15-1-report.txt",
179   },
180   {
181     "data/test-diff-filter/test16-v0.o",
182     "data/test-diff-filter/test16-v1.o",
183     "--no-default-suppression --no-show-locs --no-redundant",
184     "data/test-diff-filter/test16-report.txt",
185     "output/test-diff-filter/test16-report.txt",
186   },
187   {
188     "data/test-diff-filter/test16-v0.o",
189     "data/test-diff-filter/test16-v1.o",
190     "--no-default-suppression --no-show-locs --redundant",
191     "data/test-diff-filter/test16-report-2.txt",
192     "output/test-diff-filter/test16-report-2.txt",
193   },
194   {
195     "data/test-diff-filter/test17-v0.o",
196     "data/test-diff-filter/test17-v1.o",
197     "--no-default-suppression --no-show-locs --no-redundant",
198     "data/test-diff-filter/test17-0-report.txt",
199     "output/test-diff-filter/test17-0-report.txt",
200   },
201   {
202     "data/test-diff-filter/test17-v0.o",
203     "data/test-diff-filter/test17-v1.o",
204     "--no-default-suppression --no-show-locs --redundant",
205     "data/test-diff-filter/test17-1-report.txt",
206     "output/test-diff-filter/test17-1-report.txt",
207   },
208   {
209     "data/test-diff-filter/test18-v0.o",
210     "data/test-diff-filter/test18-v1.o",
211     "--no-default-suppression --no-show-locs --no-redundant",
212     "data/test-diff-filter/test18-report.txt",
213     "output/test-diff-filter/test18-report.txt",
214   },
215   {
216     "data/test-diff-filter/test19-enum-v0.o",
217     "data/test-diff-filter/test19-enum-v1.o",
218     "--no-default-suppression --no-show-locs --no-redundant",
219     "data/test-diff-filter/test19-enum-report-0.txt",
220     "output/test-diff-filter/test19-enum-report-0.txt",
221   },
222   {
223     "data/test-diff-filter/test19-enum-v0.o",
224     "data/test-diff-filter/test19-enum-v1.o",
225     "--no-default-suppression --no-show-locs --harmless",
226     "data/test-diff-filter/test19-enum-report-1.txt",
227     "output/test-diff-filter/test19-enum-report-1.txt",
228   },
229   {
230     "data/test-diff-filter/test20-inline-v0.o",
231     "data/test-diff-filter/test20-inline-v1.o",
232     "--no-default-suppression --no-show-locs --no-redundant",
233     "data/test-diff-filter/test20-inline-report-0.txt",
234     "output/test-diff-filter/test20-inline-report-0.txt",
235   },
236   {
237     "data/test-diff-filter/test20-inline-v0.o",
238     "data/test-diff-filter/test20-inline-v1.o",
239     "--no-default-suppression --no-show-locs --harmless",
240     "data/test-diff-filter/test20-inline-report-1.txt",
241     "output/test-diff-filter/test20-inline-report-1.txt",
242   },
243   {
244     "data/test-diff-filter/libtest21-compatible-vars-v0.so",
245     "data/test-diff-filter/libtest21-compatible-vars-v1.so",
246     "--no-default-suppression --no-show-locs --harmless",
247     "data/test-diff-filter/test21-compatible-vars-report-0.txt",
248     "output/test-diff-filter/test21-compatible-vars-report-0.txt",
249   },
250   {
251     "data/test-diff-filter/libtest21-compatible-vars-v0.so",
252     "data/test-diff-filter/libtest21-compatible-vars-v1.so",
253     "--no-default-suppression --no-show-locs --no-redundant",
254     "data/test-diff-filter/test21-compatible-vars-report-1.txt",
255     "output/test-diff-filter/test21-compatible-vars-report-1.txt",
256   },
257   {
258     "data/test-diff-filter/libtest22-compatible-fns-v0.so",
259     "data/test-diff-filter/libtest22-compatible-fns-v1.so",
260     "--no-default-suppression --no-show-locs --harmless",
261     "data/test-diff-filter/test22-compatible-fns-report-0.txt",
262     "output/test-diff-filter/test22-compatible-fns-report-0.txt",
263   },
264   {
265     "data/test-diff-filter/libtest22-compatible-fns-v0.so",
266     "data/test-diff-filter/libtest22-compatible-fns-v1.so",
267     "--no-default-suppression --no-show-locs --no-redundant",
268     "data/test-diff-filter/test22-compatible-fns-report-1.txt",
269     "output/test-diff-filter/test22-compatible-fns-report-1.txt",
270   },
271   {
272     "data/test-diff-filter/libtest23-redundant-fn-parm-change-v0.so",
273     "data/test-diff-filter/libtest23-redundant-fn-parm-change-v1.so",
274     "--no-default-suppression --no-show-locs",
275     "data/test-diff-filter/test23-redundant-fn-parm-change-report-0.txt ",
276     "output/test-diff-filter/test23-redundant-fn-parm-change-report-0.txt ",
277   },
278   {
279     "data/test-diff-filter/libtest24-compatible-vars-v0.so",
280     "data/test-diff-filter/libtest24-compatible-vars-v1.so",
281     "--no-default-suppression --no-show-locs",
282     "data/test-diff-filter/test24-compatible-vars-report-0.txt ",
283     "output/test-diff-filter/test24-compatible-vars-report-0.txt ",
284   },
285   {
286     "data/test-diff-filter/libtest24-compatible-vars-v0.so",
287     "data/test-diff-filter/libtest24-compatible-vars-v1.so",
288     "--no-default-suppression --no-show-locs --harmless",
289     "data/test-diff-filter/test24-compatible-vars-report-1.txt ",
290     "output/test-diff-filter/test24-compatible-vars-report-1.txt ",
291   },
292   {
293     "data/test-diff-filter/libtest25-cyclic-type-v0.so",
294     "data/test-diff-filter/libtest25-cyclic-type-v1.so",
295     "--no-default-suppression --no-show-locs",
296     "data/test-diff-filter/test25-cyclic-type-report-0.txt ",
297     "output/test-diff-filter/test25-cyclic-type-report-0.txt "
298   },
299   {
300     "data/test-diff-filter/libtest25-cyclic-type-v0.so",
301     "data/test-diff-filter/libtest25-cyclic-type-v1.so",
302     "--no-default-suppression --no-show-locs --redundant",
303     "data/test-diff-filter/test25-cyclic-type-report-1.txt ",
304     "output/test-diff-filter/test25-cyclic-type-report-1.txt "
305   },
306   {
307     "data/test-diff-filter/libtest26-qualified-redundant-node-v0.so",
308     "data/test-diff-filter/libtest26-qualified-redundant-node-v1.so",
309     "--no-default-suppression --no-show-locs",
310     "data/test-diff-filter/test26-qualified-redundant-node-report-0.txt",
311     "output/test-diff-filter/test26-qualified-redundant-node-report-0.txt"
312   },
313   {
314     "data/test-diff-filter/libtest26-qualified-redundant-node-v0.so",
315     "data/test-diff-filter/libtest26-qualified-redundant-node-v1.so",
316     "--no-default-suppression --no-show-locs --redundant",
317     "data/test-diff-filter/test26-qualified-redundant-node-report-1.txt",
318     "output/test-diff-filter/test26-qualified-redundant-node-report-1.txt"
319   },
320   {
321     "data/test-diff-filter/libtest27-redundant-and-filtered-children-nodes-v0.so",
322     "data/test-diff-filter/libtest27-redundant-and-filtered-children-nodes-v1.so",
323     "--no-default-suppression --no-linkage-name --no-show-locs --no-redundant",
324     "data/test-diff-filter/test27-redundant-and-filtered-children-nodes-report-0.txt",
325     "output/test-diff-filter/test27-redundant-and-filtered-children-nodes-report-0.txt"
326   },
327   {
328     "data/test-diff-filter/libtest27-redundant-and-filtered-children-nodes-v0.so",
329     "data/test-diff-filter/libtest27-redundant-and-filtered-children-nodes-v1.so",
330     "--no-default-suppression --no-linkage-name --no-show-locs --redundant",
331     "data/test-diff-filter/test27-redundant-and-filtered-children-nodes-report-1.txt",
332     "output/test-diff-filter/test27-redundant-and-filtered-children-nodes-report-1.txt"
333   },
334   {
335     "data/test-diff-filter/libtest27-redundant-and-filtered-children-nodes-v0.so",
336     "data/test-diff-filter/libtest27-redundant-and-filtered-children-nodes-v1.so",
337     "--no-default-suppression --no-linkage-name --redundant --no-show-locs --harmless",
338     "data/test-diff-filter/test27-redundant-and-filtered-children-nodes-report-2.txt",
339     "output/test-diff-filter/test27-redundant-and-filtered-children-nodes-report-2.txt"
340   },
341   {
342     "data/test-diff-filter/libtest28-redundant-and-filtered-children-nodes-v0.so",
343     "data/test-diff-filter/libtest28-redundant-and-filtered-children-nodes-v1.so",
344     "--no-default-suppression --no-linkage-name --no-show-locs --no-redundant",
345    "data/test-diff-filter/test28-redundant-and-filtered-children-nodes-report-0.txt",
346     "output/test-diff-filter/test28-redundant-and-filtered-children-nodes-report-0.txt",
347   },
348   {
349     "data/test-diff-filter/libtest28-redundant-and-filtered-children-nodes-v0.so",
350     "data/test-diff-filter/libtest28-redundant-and-filtered-children-nodes-v1.so",
351     "--no-default-suppression --no-linkage-name --redundant --no-show-locs --harmless",
352    "data/test-diff-filter/test28-redundant-and-filtered-children-nodes-report-1.txt",
353     "output/test-diff-filter/test28-redundant-and-filtered-children-nodes-report-1.txt",
354   },
355   {
356     "data/test-diff-filter/test29-finer-redundancy-marking-v0.o",
357     "data/test-diff-filter/test29-finer-redundancy-marking-v1.o",
358     "--no-default-suppression --no-linkage-name --no-show-locs --no-redundant",
359     "data/test-diff-filter/test29-finer-redundancy-marking-report-0.txt",
360     "output/test-diff-filter/test29-finer-redundancy-marking-report-0.txt",
361   },
362   {
363     "data/test-diff-filter/test30-pr18904-rvalueref-liba.so",
364     "data/test-diff-filter/test30-pr18904-rvalueref-libb.so",
365     "--no-default-suppression --no-linkage-name --no-show-locs --no-redundant",
366     "data/test-diff-filter/test30-pr18904-rvalueref-report0.txt",
367     "output/test-diff-filter/test30-pr18904-rvalueref-report0.txt",
368   },
369   { // Just like the previous test, but emit loc info.
370     "data/test-diff-filter/test30-pr18904-rvalueref-liba.so",
371     "data/test-diff-filter/test30-pr18904-rvalueref-libb.so",
372     "--no-default-suppression --no-linkage-name --no-redundant",
373     "data/test-diff-filter/test30-pr18904-rvalueref-report1.txt",
374     "output/test-diff-filter/test30-pr18904-rvalueref-report1.txt",
375   },
376   { // Just like the previous test, but emit sizes in hex and bytes
377     "data/test-diff-filter/test30-pr18904-rvalueref-liba.so",
378     "data/test-diff-filter/test30-pr18904-rvalueref-libb.so",
379     "--no-default-suppression --no-linkage-name --no-redundant "
380     "--show-hex --show-bytes",
381     "data/test-diff-filter/test30-pr18904-rvalueref-report2.txt",
382     "output/test-diff-filter/test30-pr18904-rvalueref-report2.txt",
383   },
384   {
385     "data/test-diff-filter/test31-pr18535-libstdc++-4.8.3.so",
386     "data/test-diff-filter/test31-pr18535-libstdc++-4.9.2.so",
387     "--no-default-suppression --no-linkage-name --no-show-locs --no-redundant",
388     "data/test-diff-filter/test31-pr18535-libstdc++-report-0.txt",
389     "output/test-diff-filter/test31-pr18535-libstdc++-report-0.txt",
390   },
391   { // Just like the previous test, but emit loc info.
392     "data/test-diff-filter/test31-pr18535-libstdc++-4.8.3.so",
393     "data/test-diff-filter/test31-pr18535-libstdc++-4.9.2.so",
394     "--no-default-suppression --no-linkage-name --no-redundant",
395     "data/test-diff-filter/test31-pr18535-libstdc++-report-1.txt",
396     "output/test-diff-filter/test31-pr18535-libstdc++-report-1.txt",
397   },
398   {
399     "data/test-diff-filter/libtest32-struct-change-v0.so",
400     "data/test-diff-filter/libtest32-struct-change-v1.so",
401     "--no-default-suppression --no-linkage-name --no-show-locs --no-redundant",
402     "data/test-diff-filter/test32-ppc64le-struct-change-report0.txt",
403     "output/test-diff-filter/test32-ppc64le-struct-change-report0.txt",
404   },
405   {
406     "data/test-diff-filter/test33-libelf.so.0.8.13-gcc",
407     "data/test-diff-filter/test33-libelf.so.0.8.13-intel16.0.3",
408     "--no-default-suppression --no-linkage-name --no-show-locs --no-redundant",
409     "data/test-diff-filter/test33-report-0.txt",
410     "output/test-diff-filter/test33-report-0.txt",
411   },
412   {
413     "data/test-diff-filter/test34-libjemalloc.so.2-gcc-6.1.0",
414     "data/test-diff-filter/test34-libjemalloc.so.2-intel-16.0.3",
415     "--no-default-suppression --no-linkage-name --no-show-locs --no-redundant",
416     "data/test-diff-filter/test34-report-0.txt",
417     "output/test-diff-filter/test34-report-0.txt",
418   },
419   {
420     "data/test-diff-filter/test30-pr18904-rvalueref-liba.so",
421     "data/test-diff-filter/test30-pr18904-rvalueref-libb.so",
422     "--no-default-suppression --no-linkage-name --no-show-locs --no-redundant --no-added-syms",
423     "data/test-diff-filter/test35-pr18754-no-added-syms-report-0.txt",
424     "output/test-diff-filter/test35-pr18754-no-added-syms-report-0.txt",
425   },
426   {
427     "data/test-diff-filter/test30-pr18904-rvalueref-liba.so",
428     "data/test-diff-filter/test30-pr18904-rvalueref-libb.so",
429     "--no-default-suppression --no-linkage-name --no-show-locs --no-redundant --deleted-fns --changed-vars --no-added-syms",
430     "data/test-diff-filter/test35-pr18754-no-added-syms-report-1.txt",
431     "output/test-diff-filter/test35-pr18754-no-added-syms-report-1.txt",
432   },
433   {
434     "data/test-diff-filter/libtest36-v0.so",
435     "data/test-diff-filter/libtest36-v1.so",
436     "--no-default-suppression --no-linkage-name",
437     "data/test-diff-filter/test36-report-0.txt",
438     "output/test-diff-filter/test36-report-0.txt",
439   },
440   {
441     "data/test-diff-filter/libtest37-v0.so",
442     "data/test-diff-filter/libtest37-v1.so",
443     "--no-default-suppression --no-linkage-name",
444     "data/test-diff-filter/test37-report-0.txt",
445     "output/test-diff-filter/test37-report-0.txt",
446   },
447   {
448     "data/test-diff-filter/test38/test38-v0",
449     "data/test-diff-filter/test38/test38-v1",
450     "--no-default-suppression --no-linkage-name",
451     "data/test-diff-filter/test38/test38-report-0.txt",
452     "output/test-diff-filter/test38/test38-report-0.txt",
453   },
454   {
455     "data/test-diff-filter/test39/test39-v0",
456     "data/test-diff-filter/test39/test39-v1",
457     "--no-default-suppression --no-linkage-name",
458     "data/test-diff-filter/test39/test39-report-0.txt",
459     "output/test-diff-filter/test39/test39-report-0.txt",
460   },
461   {
462     "data/test-diff-filter/libtest40-v0.so",
463     "data/test-diff-filter/libtest40-v1.so",
464     "--no-default-suppression --no-linkage-name",
465     "data/test-diff-filter/test40-report-0.txt",
466     "output/test-diff-filter/test40-report-0.txt",
467   },
468   {
469     "data/test-diff-filter/test41-PR21486-abg-writer.gcc.o",
470     "data/test-diff-filter/test41-PR21486-abg-writer.llvm.o",
471     "--no-default-suppression",
472     "data/test-diff-filter/test41-report-0.txt",
473     "output/test-diff-filter/test41-report-0.txt",
474   },
475   {
476     "data/test-diff-filter/libtest42-leaf-report-v0.so",
477     "data/test-diff-filter/libtest42-leaf-report-v1.so",
478     "--no-default-suppression --leaf-changes-only --impacted-interfaces",
479     "data/test-diff-filter/test42-leaf-report-output-0.txt",
480     "output/test-diff-filter/test42-leaf-report-output-0.txt",
481   },
482   {
483     "data/test-diff-filter/libtest43-decl-only-def-change-leaf-report-v0.so",
484     "data/test-diff-filter/libtest43-decl-only-def-change-leaf-report-v1.so",
485     "--no-default-suppression --leaf-changes-only",
486     "data/test-diff-filter/test43-decl-only-def-change-leaf-report-0.txt",
487     "output/test-diff-filter/test43-decl-only-def-change-leaf-report-0.txt",
488   },
489   {
490     "data/test-diff-filter/libtest44-anonymous-data-member-v0.so",
491     "data/test-diff-filter/libtest44-anonymous-data-member-v1.so",
492     "--no-default-suppression",
493     "data/test-diff-filter/test44-anonymous-data-member-report-0.txt",
494     "output/test-diff-filter/test44-anonymous-data-member-report-0.txt",
495   },
496   {
497     "data/test-diff-filter/libtest44-anonymous-data-member-v0.so",
498     "data/test-diff-filter/libtest44-anonymous-data-member-v1.so",
499     "--no-default-suppression --leaf-changes-only",
500     "data/test-diff-filter/test44-anonymous-data-member-report-1.txt",
501     "output/test-diff-filter/test44-anonymous-data-member-report-1.txt",
502   },
503   {
504     "data/test-diff-filter/libtest45-basic-type-change-v0.so",
505     "data/test-diff-filter/libtest45-basic-type-change-v1.so",
506     "--no-default-suppression",
507     "data/test-diff-filter/libtest45-basic-type-change-report-0.txt",
508     "output/test-diff-filter/libtest45-basic-type-change-report-0.txt",
509   },
510   {
511     "data/test-diff-filter/libtest45-basic-type-change-v0.so",
512     "data/test-diff-filter/libtest45-basic-type-change-v1.so",
513     "--no-default-suppression --leaf-changes-only",
514     "data/test-diff-filter/libtest45-basic-type-change-report-1.txt",
515     "output/test-diff-filter/libtest45-basic-type-change-report-1.txt",
516   },
517   {
518     "data/test-diff-filter/test46-fn-return-qual-change-v0.o",
519     "data/test-diff-filter/test46-fn-return-qual-change-v1.o",
520     "--no-default-suppression",
521     "data/test-diff-filter/test46-fn-return-qual-change-report-0.txt",
522     "output/test-diff-filter/test46-fn-return-qual-change-report-0.txt",
523   },
524   {
525     "data/test-diff-filter/test47-filter-void-ptr-change-v0.o",
526     "data/test-diff-filter/test47-filter-void-ptr-change-v1.o",
527     "--no-default-suppression",
528     "data/test-diff-filter/test47-filter-void-ptr-change-report-0.txt",
529     "output/test-diff-filter/test47-filter-void-ptr-change-report-0.txt",
530   },
531   {
532     "data/test-diff-filter/PR24430-fold-qualified-array-clang",
533     "data/test-diff-filter/PR24430-fold-qualified-array-gcc",
534     "--no-default-suppression",
535     "data/test-diff-filter/PR24430-fold-qualified-array-report-0.txt",
536     "output/test-diff-filter/PR24430-fold-qualified-array-report-0.txt",
537   },
538   {
539     "data/test-diff-filter/test-PR24731-v0.o ",
540     "data/test-diff-filter/test-PR24731-v1.o ",
541     "--no-default-suppression",
542     "data/test-diff-filter/test-PR24731-report-0.txt",
543     "output/test-diff-filter/test-PR24731-report-0.txt",
544   },
545   {
546     "data/test-diff-filter/test-PR24731-v0.o ",
547     "data/test-diff-filter/test-PR24731-v1.o ",
548     "--no-default-suppression --harmless",
549     "data/test-diff-filter/test-PR24731-report-1.txt",
550     "output/test-diff-filter/test-PR24731-report-1.txt",
551   },
552   {
553     "data/test-diff-filter/PR24787-libone.so",
554     "data/test-diff-filter/PR24787-libtwo.so",
555     "--no-default-suppression",
556     "data/test-diff-filter/PR24787-report-0.txt",
557     "output/test-diff-filter/PR24787-report-0.txt",
558   },
559   {
560    "data/test-diff-filter/test-PR25661-1-v0.o",
561    "data/test-diff-filter/test-PR25661-1-v1.o",
562    "--no-default-suppression",
563    "data/test-diff-filter/test-PR25661-1-report-1.txt",
564    "output/test-diff-filter/test-PR25661-1-report-1.txt",
565   },
566   {
567    "data/test-diff-filter/test-PR25661-1-v0.o",
568    "data/test-diff-filter/test-PR25661-1-v1.o",
569    "--no-default-suppression --harmless",
570    "data/test-diff-filter/test-PR25661-1-report-2.txt",
571    "output/test-diff-filter/test-PR25661-1-report-2.txt",
572   },
573   {
574    "data/test-diff-filter/test-PR25661-1-v0.o",
575    "data/test-diff-filter/test-PR25661-1-v1.o",
576    "--no-default-suppression --leaf-changes-only",
577    "data/test-diff-filter/test-PR25661-1-report-3.txt",
578    "output/test-diff-filter/test-PR25661-1-report-3.txt",
579   },
580   {
581    "data/test-diff-filter/test-PR25661-1-v0.o",
582    "data/test-diff-filter/test-PR25661-1-v1.o",
583    "--no-default-suppression --harmless --leaf-changes-only",
584    "data/test-diff-filter/test-PR25661-1-report-4.txt",
585    "output/test-diff-filter/test-PR25661-1-report-4.txt",
586   },
587   {
588    "data/test-diff-filter/test-PR25661-2-v0.o",
589    "data/test-diff-filter/test-PR25661-2-v1.o",
590    "--no-default-suppression",
591    "data/test-diff-filter/test-PR25661-2-report-1.txt",
592    "output/test-diff-filter/test-PR25661-2-report-1.txt",
593   },
594   {
595    "data/test-diff-filter/test-PR25661-2-v0.o",
596    "data/test-diff-filter/test-PR25661-2-v1.o",
597    "--no-default-suppression --harmless",
598    "data/test-diff-filter/test-PR25661-2-report-2.txt",
599    "output/test-diff-filter/test-PR25661-2-report-2.txt",
600   },
601   {
602    "data/test-diff-filter/test-PR25661-2-v0.o",
603    "data/test-diff-filter/test-PR25661-2-v1.o",
604    "--no-default-suppression --leaf-changes-only",
605    "data/test-diff-filter/test-PR25661-2-report-3.txt",
606    "output/test-diff-filter/test-PR25661-2-report-3.txt",
607   },
608   {
609    "data/test-diff-filter/test-PR25661-2-v0.o",
610    "data/test-diff-filter/test-PR25661-2-v1.o",
611    "--no-default-suppression --harmless --leaf-changes-only",
612    "data/test-diff-filter/test-PR25661-2-report-4.txt",
613    "output/test-diff-filter/test-PR25661-2-report-4.txt",
614   },
615   {
616    "data/test-diff-filter/test-PR25661-3-v0.o",
617    "data/test-diff-filter/test-PR25661-3-v1.o",
618    "--no-default-suppression",
619    "data/test-diff-filter/test-PR25661-3-report-1.txt",
620    "output/test-diff-filter/test-PR25661-3-report-1.txt",
621   },
622   {
623    "data/test-diff-filter/test-PR25661-3-v0.o",
624    "data/test-diff-filter/test-PR25661-3-v1.o",
625    "--no-default-suppression --harmless",
626    "data/test-diff-filter/test-PR25661-3-report-2.txt",
627    "output/test-diff-filter/test-PR25661-3-report-2.txt",
628   },
629   {
630    "data/test-diff-filter/test-PR25661-3-v0.o",
631    "data/test-diff-filter/test-PR25661-3-v1.o",
632    "--no-default-suppression --leaf-changes-only",
633    "data/test-diff-filter/test-PR25661-3-report-3.txt",
634    "output/test-diff-filter/test-PR25661-3-report-3.txt",
635   },
636   {
637    "data/test-diff-filter/test-PR25661-3-v0.o",
638    "data/test-diff-filter/test-PR25661-3-v1.o",
639    "--no-default-suppression --harmless --leaf-changes-only",
640    "data/test-diff-filter/test-PR25661-3-report-4.txt",
641    "output/test-diff-filter/test-PR25661-3-report-4.txt",
642   },
643   {
644    "data/test-diff-filter/test-PR25661-4-v0.o",
645    "data/test-diff-filter/test-PR25661-4-v1.o",
646    "--no-default-suppression",
647    "data/test-diff-filter/test-PR25661-4-report-1.txt",
648    "output/test-diff-filter/test-PR25661-4-report-1.txt",
649   },
650   {
651    "data/test-diff-filter/test-PR25661-4-v0.o",
652    "data/test-diff-filter/test-PR25661-4-v1.o",
653    "--no-default-suppression --harmless",
654    "data/test-diff-filter/test-PR25661-4-report-2.txt",
655    "output/test-diff-filter/test-PR25661-4-report-2.txt",
656   },
657   {
658    "data/test-diff-filter/test-PR25661-4-v0.o",
659    "data/test-diff-filter/test-PR25661-4-v1.o",
660    "--no-default-suppression --leaf-changes-only",
661    "data/test-diff-filter/test-PR25661-4-report-3.txt",
662    "output/test-diff-filter/test-PR25661-4-report-3.txt",
663   },
664   {
665    "data/test-diff-filter/test-PR25661-4-v0.o",
666    "data/test-diff-filter/test-PR25661-4-v1.o",
667    "--no-default-suppression --harmless --leaf-changes-only",
668    "data/test-diff-filter/test-PR25661-4-report-4.txt",
669    "output/test-diff-filter/test-PR25661-4-report-4.txt",
670   },
671   {
672    "data/test-diff-filter/test-PR25661-5-v0.o",
673    "data/test-diff-filter/test-PR25661-5-v1.o",
674    "--no-default-suppression",
675    "data/test-diff-filter/test-PR25661-5-report-1.txt",
676    "output/test-diff-filter/test-PR25661-5-report-1.txt",
677   },
678   {
679    "data/test-diff-filter/test-PR25661-5-v0.o",
680    "data/test-diff-filter/test-PR25661-5-v1.o",
681    "--no-default-suppression --harmless",
682    "data/test-diff-filter/test-PR25661-5-report-2.txt",
683    "output/test-diff-filter/test-PR25661-5-report-2.txt",
684   },
685   {
686    "data/test-diff-filter/test-PR25661-5-v0.o",
687    "data/test-diff-filter/test-PR25661-5-v1.o",
688    "--no-default-suppression --leaf-changes-only",
689    "data/test-diff-filter/test-PR25661-5-report-3.txt",
690    "output/test-diff-filter/test-PR25661-5-report-3.txt",
691   },
692   {
693    "data/test-diff-filter/test-PR25661-5-v0.o",
694    "data/test-diff-filter/test-PR25661-5-v1.o",
695    "--no-default-suppression --harmless --leaf-changes-only",
696    "data/test-diff-filter/test-PR25661-5-report-4.txt",
697    "output/test-diff-filter/test-PR25661-5-report-4.txt",
698   },
699   {
700    "data/test-diff-filter/test-PR25661-6-v0.o",
701    "data/test-diff-filter/test-PR25661-6-v1.o",
702    "--no-default-suppression",
703    "data/test-diff-filter/test-PR25661-6-report-1.txt",
704    "output/test-diff-filter/test-PR25661-6-report-1.txt",
705   },
706   {
707    "data/test-diff-filter/test-PR25661-6-v0.o",
708    "data/test-diff-filter/test-PR25661-6-v1.o",
709    "--no-default-suppression --leaf-changes-only",
710    "data/test-diff-filter/test-PR25661-6-report-2.txt",
711    "output/test-diff-filter/test-PR25661-6-report-2.txt",
712   },
713   {
714    "data/test-diff-filter/test-PR25661-6-v0.o",
715    "data/test-diff-filter/test-PR25661-6-v1.o",
716    "--no-default-suppression --harmless",
717    "data/test-diff-filter/test-PR25661-6-report-3.txt",
718    "output/test-diff-filter/test-PR25661-6-report-3.txt",
719   },
720   {
721    "data/test-diff-filter/test-PR25661-6-v0.o",
722    "data/test-diff-filter/test-PR25661-6-v1.o",
723    "--no-default-suppression --harmless --leaf-changes-only",
724    "data/test-diff-filter/test-PR25661-6-report-4.txt",
725    "output/test-diff-filter/test-PR25661-6-report-4.txt",
726   },
727   {
728    "data/test-diff-filter/test-PR25661-7-v0.o",
729    "data/test-diff-filter/test-PR25661-7-v1.o",
730    "--no-default-suppression",
731    "data/test-diff-filter/test-PR25661-7-report-1.txt",
732    "output/test-diff-filter/test-PR25661-7-report-1.txt",
733   },
734   {
735    "data/test-diff-filter/test-PR25661-7-v0.o",
736    "data/test-diff-filter/test-PR25661-7-v1.o",
737    "--no-default-suppression --leaf-changes-only",
738    "data/test-diff-filter/test-PR25661-7-report-2.txt",
739    "output/test-diff-filter/test-PR25661-7-report-2.txt",
740   },
741   {
742    "data/test-diff-filter/test-PR25661-7-v0.o",
743    "data/test-diff-filter/test-PR25661-7-v1.o",
744    "--no-default-suppression --harmless",
745    "data/test-diff-filter/test-PR25661-7-report-3.txt",
746    "output/test-diff-filter/test-PR25661-7-report-3.txt",
747   },
748   {
749    "data/test-diff-filter/test-PR25661-7-v0.o",
750    "data/test-diff-filter/test-PR25661-7-v1.o",
751    "--no-default-suppression --harmless --leaf-changes-only",
752    "data/test-diff-filter/test-PR25661-7-report-4.txt",
753    "output/test-diff-filter/test-PR25661-7-report-4.txt",
754   },
755   {
756    "data/test-diff-filter/test-PR26309-v0.o",
757    "data/test-diff-filter/test-PR26309-v1.o",
758    "--no-default-suppression --leaf-changes-only",
759    "data/test-diff-filter/test-PR26309-report-0.txt",
760    "output/test-diff-filter/test-PR26309-report-0.txt",
761   },
762   {
763    "data/test-diff-filter/test-PR26739-v0.o",
764    "data/test-diff-filter/test-PR26739-v1.o",
765    "--no-default-suppression",
766    "data/test-diff-filter/test-PR26739-report-0.txt",
767    "output/test-diff-filter/test-PR26739-report-0.txt",
768   },
769   {
770    "data/test-diff-filter/test-PR26739-2-v0.o",
771    "data/test-diff-filter/test-PR26739-2-v1.o",
772    "--no-default-suppression",
773    "data/test-diff-filter/test-PR26739-2-report-0.txt",
774    "output/test-diff-filter/test-PR26739-2-report-0.txt",
775   },
776   {
777    "data/test-diff-filter/test-PR26684-dwarf4.o",
778    "data/test-diff-filter/test-PR26684-dwarf5.o",
779    "--no-default-suppression --leaf-changes-only",
780    "data/test-diff-filter/test-PR26684-report-0.txt",
781    "output/test-diff-filter/test-PR26684-report-0.txt",
782   },
783   {
784    "data/test-diff-filter/test-PR27331-v0.o",
785    "data/test-diff-filter/test-PR27331-v1.o",
786    "--no-default-suppression --leaf-changes-only",
787    "data/test-diff-filter/test-PR27331-report-0.txt",
788    "output/test-diff-filter/test-PR27331-report-0.txt",
789   },
790   {
791    "data/test-diff-filter/test-PR27569-v0.abi",
792    "data/test-diff-filter/test-PR27569-v1.abi",
793    "--no-default-suppression",
794    "data/test-diff-filter/test-PR27569-report-0.txt",
795    "output/test-diff-filter/test-PR27569-report-0.txt",
796   },
797   {
798    "data/test-diff-filter/test-PR27598-v0.o",
799    "data/test-diff-filter/test-PR27598-v0.o",
800    "--no-default-suppression",
801    "data/test-diff-filter/test-PR27598-report-0.txt",
802    "output/test-diff-filter/test-PR27598-report-0.txt",
803   },
804   {
805    "data/test-diff-filter/test-PR27995.abi",
806    "data/test-diff-filter/test-PR27995.abi",
807    "--no-default-suppression",
808    "data/test-diff-filter/test-PR27995-report-0.txt",
809    "output/test-diff-filter/test-PR27995-report-0.txt",
810   },
811   {
812    "data/test-diff-filter/test-PR28013-fn-variadic.c.0.abi",
813    "data/test-diff-filter/test-PR28013-fn-variadic.c.1.abi",
814    "--no-default-suppression",
815    "data/test-diff-filter/test-PR28013-fn-variadic.c.report.txt",
816    "output/test-diff-filter/test-PR28013-fn-variadic.c.report.txt",
817   },
818   {
819    "data/test-diff-filter/test-PR29387-v0.o",
820    "data/test-diff-filter/test-PR29387-v1.o",
821    "--no-default-suppression",
822    "data/test-diff-filter/test-PR29387-report.txt",
823    "output/test-diff-filter/test-PR29387-report.txt",
824   },
825   // This should be the last entry
826   {NULL, NULL, NULL, NULL, NULL}
827 };
828 
829 /// A task which launches abidiff on the binaries passed to the
830 /// constructor of the task.  The test also launches gnu diff on the
831 /// result of the abidiff to compare it against a reference abidiff
832 /// result.
833 struct test_task : public abigail::workers::task
834 {
835   InOutSpec spec;
836   bool is_ok;
837   string diff_cmd;
838   string error_message;
839 
test_tasktest_task840   test_task(const InOutSpec& s)
841     : spec(s),
842       is_ok(true)
843   {}
844 
845   /// This virtual function overload actually performs the job of the
846   /// task.
847   ///
848   /// It actually launches abidiff on the binaries passed to the
849   /// constructor of the task.  It also launches gnu diff on the
850   /// result of the abidiff to compare it against a reference abidiff
851   /// result.
852   virtual void
performtest_task853   perform()
854   {
855     using abigail::tests::get_src_dir;
856     using abigail::tests::get_build_dir;
857     using abigail::tools_utils::ensure_parent_dir_created;
858     using abigail::tools_utils::abidiff_status;
859 
860     string in_elfv0_path, in_elfv1_path,
861       abidiff_options, abidiff, cmd,
862       ref_diff_report_path, out_diff_report_path;
863 
864     in_elfv0_path = string(get_src_dir()) + "/tests/" + spec.in_elfv0_path;
865     in_elfv1_path = string(get_src_dir()) + "/tests/" + spec.in_elfv1_path;
866     abidiff_options = spec.abidiff_options;
867     ref_diff_report_path =
868       string(get_src_dir()) + "/tests/" + spec.in_report_path;
869     out_diff_report_path =
870       string(get_build_dir()) + "/tests/" + spec.out_report_path;
871 
872     if (!ensure_parent_dir_created(out_diff_report_path))
873       {
874 	error_message = string("could not create parent directory for ")
875 	  + out_diff_report_path;
876 	is_ok = false;
877 	return;
878       }
879 
880     abidiff = string(get_build_dir()) + "/tools/abidiff";
881     abidiff += " " + abidiff_options;
882 
883     cmd = abidiff + " " + in_elfv0_path + " " + in_elfv1_path;
884     cmd += " > " + out_diff_report_path;
885 
886     bool abidiff_ok = true;
887     int code = system(cmd.c_str());
888     if (!WIFEXITED(code))
889       abidiff_ok = false;
890     else
891       {
892 	abidiff_status status =
893 	  static_cast<abidiff_status>(WEXITSTATUS(code));
894 	if (abigail::tools_utils::abidiff_status_has_error(status))
895 	  abidiff_ok = false;
896       }
897 
898     if (abidiff_ok)
899       {
900 	cmd = "diff -u " + ref_diff_report_path
901 	  + " " + out_diff_report_path;
902 
903 	string cmd_no_out = cmd + " > /dev/null";
904 	if (system(cmd_no_out.c_str()))
905 	  {
906 	    is_ok = false;
907 	    diff_cmd = cmd;
908 	  }
909       }
910     else
911       is_ok = false;
912 
913     if (!abidiff_ok)
914       error_message += "cmd failed: " + cmd;
915   }
916 }; //end struct test_task.
917 
918 /// A convenience typedef for shared
919 typedef shared_ptr<test_task> test_task_sptr;
920 
921 int
main()922 main()
923 {
924   using std::vector;
925   using std::dynamic_pointer_cast;
926   using abigail::workers::queue;
927   using abigail::workers::task;
928   using abigail::workers::task_sptr;
929   using abigail::workers::get_number_of_threads;
930 
931   /// Create a task queue.  The max number of worker threads of the
932   /// queue is the number of the concurrent threads supported by the
933   /// processor of the machine this code runs on.
934   const size_t num_tests = sizeof(in_out_specs) / sizeof (InOutSpec) - 1;
935   size_t num_workers = std::min(get_number_of_threads(), num_tests);
936   queue task_queue(num_workers);
937 
938   bool is_ok = true;
939 
940   for (InOutSpec* s = in_out_specs; s->in_elfv0_path; ++s)
941     {
942       test_task_sptr t(new test_task(*s));
943       ABG_ASSERT(task_queue.schedule_task(t));
944     }
945 
946   /// Wait for all worker threads to finish their job, and wind down.
947   task_queue.wait_for_workers_to_complete();
948 
949   // Now walk the results and print whatever error messages need to be
950   // printed.
951 
952   const vector<task_sptr>& completed_tasks =
953     task_queue.get_completed_tasks();
954 
955   ABG_ASSERT(completed_tasks.size() == num_tests);
956 
957   for (vector<task_sptr>::const_iterator ti = completed_tasks.begin();
958        ti != completed_tasks.end();
959        ++ti)
960     {
961       test_task_sptr t = dynamic_pointer_cast<test_task>(*ti);
962       if (!t->is_ok)
963 	{
964 	  is_ok = false;
965 	  if (!t->diff_cmd.empty())
966 	    if (system(t->diff_cmd.c_str()) == -1)
967 	      cerr << "execution of '" << t->diff_cmd << "' failed\n";
968 	  if (!t->error_message.empty())
969 	    cerr << t->error_message << '\n';
970 	}
971     }
972 
973   return !is_ok;
974 }
975