libabigail/tests
Giuliano Procida 697347e402 Fix corpus_diff::has_net_changes for --leaf-changes-only mode
This function was not aware of --leaf-changes-only mode.

    - Stats counters for changed variables and types have
      different names in the different modes.
    - Net leaf type changes were not included in leaf mode.

For some inputs, this resulted in abidiff producing an empty report
but returning a non-zero exit status in --leaf-changes-only mode.

For other inputs the combination of both issues still resulted in the
correct return code. This included the following test-abidiff-exit
test cases:

    - test-leaf-peeling
    - test-leaf2
    - test-no-stray-comma

This patch makes corpus_diff::has_net_changes mirror emit_diff_stats,
modulo flags like --non-reachable-types which if absent can still
result in discrepancies between output and return code.

To achieve this in a more maintainable way, the patch introduces a new interface
reporter_base::diff_has_net_changes.  That interface is implemented by
all current reporters.  Each reporter focuses on its own
particularities to provide the required behavious. Then
corpus_diff:has_net_changes just has to invoke
reporter_base::diff_has_net_changes on the reporter that is currently
in used.

The tests below verify that the exit code is zero when all the changes
between the test files are suppressed.

	* include/abg-reporter.h ({reporter_base, default_reporter,
	leaf_reporter}::diff_has_net_changes): Add new virtual function.
	This breaks binary compatibility but should conserve source
	compatibility.
	* src/abg-default-reporter.cc
	(default_reporter::diff_has_net_changes): Define new member
	function.
	* src/abg-leaf-reporter.cc (leaf_reporter::diff_has_net_changes):
	Likewise.
	* src/abg-comparison.cc (corpus_diff::has_net_changes): Invoke
	reporter_base::diff_has_net_changes on the current reporter,
	rather than trying to handle all the different kinds of reporters
	here.
	(corpus_diff::priv::apply_filters_and_compute_diff_stats): Add a
	TODO to possibly delegate the implementation of this function to
	the reporters.
	* tests/data/Makefile.am: Add new test case files.
	* tests/data/test-abidiff-exit/test-net-change-report0.txt:
	Normal mode, nothing suppressed.
	* tests/data/test-abidiff-exit/test-net-change-report1.txt:
	Normal mode, everything suppressed.
	* tests/data/test-abidiff-exit/test-net-change-report2.txt:
	Leaf mode, nothing suppressed.
	* tests/data/test-abidiff-exit/test-net-change-report3.txt:
	Leaf mode, everything suppressions.
	* tests/data/test-abidiff-exit/test-net-change-v0.c: Test file
	* tests/data/test-abidiff-exit/test-net-change-v0.o: Test file
	* tests/data/test-abidiff-exit/test-net-change-v1.c: Test file
	* tests/data/test-abidiff-exit/test-net-change-v1.o: Test file
	* tests/data/test-abidiff-exit/test-net-change.abignore: This
	suppresses changes for all variables, functions and types in
	the test files, except for the 'victim' function.
	* tests/test-abidiff-exit.cc: Run new test cases.

Reviewed-by: Matthias Maennich <maennich@google.com>
Signed-off-by: Giuliano Procida <gprocida@google.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-07-21 08:53:19 +02:00
..
data Fix corpus_diff::has_net_changes for --leaf-changes-only mode 2020-07-21 08:53:19 +02:00
lib Testing: add Catch Unit test framework 2020-01-28 17:16:56 +00:00
.gitignore tests/.gitignore: ignore all files starting with runtest* 2020-05-13 11:26:28 +02:00
Makefile.am tests: Add symtab test suite 2020-05-27 11:00:51 +02:00
mockfedabipkgdiff.in Bug 22722 - Make fedabipkgdiff and its tests support both python 3 and 2 2018-03-29 13:46:50 +02:00
print-diff-tree.cc Update copyright year to 2020 2020-02-21 17:05:01 +01:00
runtestcanonicalizetypes.sh.in Bug 20180 - Support system-wide suppression specifications 2016-05-30 18:39:49 +02:00
runtestdefaultsupprs.py.in Fix typo in tests/runtestdefaultsupprs.py 2018-05-24 10:48:56 +02:00
runtestdefaultsupprspy3.sh.in Bug 22722 - Make fedabipkgdiff and its tests support both python 3 and 2 2018-03-29 13:46:50 +02:00
runtestfedabipkgdiff.py.in Bug 22722 - Make fedabipkgdiff and its tests support both python 3 and 2 2018-03-29 13:46:50 +02:00
runtestfedabipkgdiffpy3.sh.in Bug 22722 - Make fedabipkgdiff and its tests support both python 3 and 2 2018-03-29 13:46:50 +02:00
test-abicompat.cc Update copyright year to 2020 2020-02-21 17:05:01 +01:00
test-abidiff-exit.cc Fix corpus_diff::has_net_changes for --leaf-changes-only mode 2020-07-21 08:53:19 +02:00
test-abidiff.cc Update copyright year to 2020 2020-02-21 17:05:01 +01:00
test-alt-dwarf-file.cc Update copyright year to 2020 2020-02-21 17:05:01 +01:00
test-annotate.cc Handle several member anonymous types of the same kind 2019-05-07 14:31:16 +02:00
test-core-diff.cc Update copyright year to 2020 2020-02-21 17:05:01 +01:00
test-cxx-compat.cc cxx-compat: add test suite for cxx-compat 2020-05-13 11:55:12 +02:00
test-diff2.cc Update copyright year to 2020 2020-02-21 17:05:01 +01:00
test-diff-dwarf-abixml.cc Update copyright year to 2020 2020-02-21 17:05:01 +01:00
test-diff-dwarf.cc Update copyright year to 2020 2020-02-21 17:05:01 +01:00
test-diff-filter.cc Bug 25661 - Support data member replacement by anonymous data member 2020-05-18 13:42:50 +02:00
test-diff-pkg.cc configure: add more diagnostic options when ABIGAIL_DEVEL is set 2020-05-18 10:39:36 +02:00
test-diff-suppr.cc tests: parallelize diff-suppr test 2020-04-20 15:02:39 +02:00
test-dot.cc Update copyright year to 2020 2020-02-21 17:05:01 +01:00
test-elf-helpers.cc abg-dwarf-reader split: create abg-elf-helpers.{h,cc} and test case 2020-04-22 11:39:45 +02:00
test-ini.cc Update copyright year to 2020 2020-02-21 17:05:01 +01:00
test-ir-walker.cc Update copyright year to 2020 2020-02-21 17:05:01 +01:00
test-kmi-whitelist.cc Simplify generation of symbol whitelist regex. 2020-05-04 11:17:49 +02:00
test-lookup-syms.cc dwarf-reader: Fix bloom filter access in GNU_HASH section 2020-03-20 13:35:00 +01:00
test-read-dwarf.cc Fix bug that suppressed DWARF read tests. 2020-06-17 11:27:13 +02:00
test-read-write.cc configure: add more diagnostic options when ABIGAIL_DEVEL is set 2020-05-18 10:39:36 +02:00
test-svg.cc Update copyright year to 2020 2020-02-21 17:05:01 +01:00
test-symtab.cc tests: Add kernel symtab test suite 2020-05-27 11:00:51 +02:00
test-tools-utils.cc Update copyright year to 2020 2020-02-21 17:05:01 +01:00
test-types-stability.cc test-types-stability: parallelize test case alternatives 2020-05-04 15:34:42 +02:00
test-utils.cc Update copyright year to 2020 2020-02-21 17:05:01 +01:00
test-utils.h Update copyright year to 2020 2020-02-21 17:05:01 +01:00
test-valgrind-suppressions.supp Shut down a helgrind false positive in the "system" libc call 2017-03-17 09:02:19 +01:00
test-write-read-archive.cc Update copyright year to 2020 2020-02-21 17:05:01 +01:00
update-test-output.py Rename tests/update-test-read-dwarf-output.py 2016-12-02 12:59:32 +01:00