libabigail/tests/Makefile.am
Dodji Seketeli 217ba7fdb8 dwarf-reader: Avoid duplicating anonymous member types
Sometimes, anonymous member types are duplicated in some classes read
by the DWARF reader.  This is because the DWARF reader doesn't lookup
anonymous member types in their class scope before adding them into
their scope.

This patch teaches the DWARF reader how to name an anonymous class,
union or enum by using its flat pretty representation, e.g:

    struct {int blah; char meh;}

That flat representation is used as the name of the anonymous type to
look it up in a given class scope before adding it to that scope.  If
the scope already contains the type, then the type is not added.

Now that class scopes have their proper anonymous member types, it
appeared that the filtering of change reports needed a number of
adaptations because we are now seeing things that we were not seeing
before.  For instance two new change categories
NON_COMPATIBLE_DISTINCT_CHANGE_CATEGORY and
NON_COMPATIBLE_NAME_CHANGE_CATEGORY are added.  The former is for a
change where a given type becomes another type of a different kind in
an non-compatible way.  For instance, a struct type becomes an enum
type.  The later category is for a change in a name of the type,
resulting in a non-compatible change.  Thus, new non-compatible
changes can now be categorized and reported as such.

	* include/abg-comp-filter.h (has_void_ptr_to_ptr_change)
	(has_harmless_enum_to_int_change)
	(has_benign_array_of_unknown_size_change): Declare new functions.
	* include/abg-comparison.h (enum diff_category): Add
	NON_COMPATIBLE_DISTINCT_CHANGE_CATEGORY,
	NON_COMPATIBLE_NAME_CHANGE_CATEGORY enumerators.  Update the other
	enumerator values.  Also, update the EVERYTHING_CATEGORY
	enumerator value.
	* include/abg-ir.h (class_decl::find_base_class): Document the
	name of the parameter.
	* src/abg-comp-filter.cc (type_diff_has_cv_qual_change_only)
	(is_non_compatible_distinct_change, is_void_ptr_to_ptr): Define
	new static functions.
	(has_subtype_changes): Remove static function.
	(class_diff_has_only_harmless_changes): Do not bother checking if
	the class_diff has subtype changes.  If there are, the category of
	those changes is going to be propagated upward to this current
	diff node.  Update the comments.
	(has_harmless_name_change): A diff node carrying compatible types
	or types that differ only from their CV qualifiers should qualify
	as having a harmless name change.
	(has_harmless_enum_to_int_change): Make this function be
	non-static.
	(type_diff_has_cv_qual_change_only): Introduce an overload that
	takes two ABI artifacts instead of one diff node.  Make the diff
	node overload use the new one.  Simplify logic by essentially
	peeling off qualified or typedefs first.  Then if what remain is
	pointer or array types, look at their underlying types.  If the
	remaining underlying types are equal then return true.
	(has_void_ptr_to_ptr_change): Use the new is_void_ptr_to_ptr
	function.  This allows the function to detect void* -> pointer and
	pointer -> void* changes.  And it simplifies the logic.
	* src/abg-comparison.cc (distinct_diff::compatible_child_diff):
	Build a compatible child diff node iff the two diff subject are
	actually compatible meaning, they are equal modulo a typedef.
	(get_default_harmful_categories_bitmap): Add the new
	abigail::comparison::{NON_COMPATIBLE_DISTINCT_CHANGE_CATEGORY,NON_COMPATIBLE_NAME_CHANGE_CATEGORY}
	enumerators to the bitmap of harmful categories.
	(operator<<(ostream& o, diff_category c)): Update this to support
	emitting the new
	abigail::comparison::{NON_COMPATIBLE_DISTINCT_CHANGE_CATEGORY,NON_COMPATIBLE_NAME_CHANGE_CATEGORY}
	enumerators.
	(class_or_union_diff::priv::count_filtered_{subtype_}changed_dm):
	Fix logic for counting local changes.
	diff::has_local_changes_to_be_reported is not reliable so do not
	rely on it.  We might want to remove that function in the end.
	(category_propagation_visitor::visit_end): If the current diff
	node has a harmless void pointer to pointer, enum to int, or a
	benign array of unknown size change, do not propagate the
	NON_COMPATIBLE_{NAME,DISTINCT}_CHANGE_CATEGORY that have
	necessarily bubbled up from some of their distant children nodes.
	* src/abg-dwarf-reader.cc
	(maybe_set_member_type_access_specifier)
	(get_next_member_sibling_die): Declare this pre-existing static
	function.
	(get_internal_anonymous_die_name)
	(lookup_class_typedef_or_enum_type_from_corpus)
	(lookup_class_typedef_or_enum_type_from_corpus): Remove.
	(die_return_and_parm_names_from_fn_type_die): Add is_method_type
	and return_type_name parameters. Fix the representation of member
	functions.
	(die_function_signature): Add qualified_name parameter. Adjust
	call to die_return_and_parm_names_from_fn_type_die.
	(die_type_name, die_enum_flat_representation)
	(die_class_flat_representation)
	(die_class_or_enum_flat_representation): Define new static
	functions.
	(reader::get_die_qualified_type_name, die_qualified_type_name):
	For anonymous class or enum types, use the new
	die_class_or_enum_flat_representation.  Adjust the call to
	die_return_and_parm_names_from_fn_type_die. For function types fix
	the name representation.
	(die_pretty_print_type): Adjust call to
	die_return_and_parm_names_from_fn_type_die.
	(die_pretty_print_decl): Take qualified_name and include_fns
	parameters.  Use the new die_type_name for variable type names.
	Adjust call to die_function_signature.
	(die_pretty_print): Adjust call die_pretty_print_decl.
	(get_member_child_die): Remove useless vertical space.
	(build_enum_underlying_type): Sort this enum underlying type (and
	potentially hash it) before canonicalizing it.
	(add_or_update_class_type): If an anonymous type is in the global
	scope, take that into account when building its internal anonymous
	die name.  Lookup anonymous member types before adding them to the
	class scope to avoid duplicating them in their scope.
	(add_or_update_union_type): Likewise, lookup anonymous member
	types before adding them to the union scope to avoid duplicating
	them in their scope.
	(build_subranges_from_array_type_die): Const-ify the input reader.
	Adjust call to build_ir_node_from_die.  Associate the subrange DIE
	to the IR node built.
	(build_ir_node_from_die): Get the current corpus from the reader
	because it might be set for scope passed to this function, or the
	scope might be nullptr.  Schedule base types for canonicalization
	like all the other types.  Also, lookup all class/union types
	before adding them to their class scope.
	* src/abg-leaf-reporter.cc (leaf_reporter::report): In the
	overload for class_or_union_diff, report changed data members and
	their sub-types.
	* tests/Makefile.am: Do not XFAIL the test runtestabidiffexit.  No
	more tests are XFAILED.  All tests should now pass.
	* tests/data/test-abidiff-exit/PR30503/libsdl/libsdl-1.2.60-1.2.64-report.txt:
	Adjust.
	* tests/data/test-abidiff-exit/PR31513/reported/PR31513-reported-report-1.txt:
	Likewise.
	* tests/data/test-abidiff-exit/qualifier-typedef-array-report-1.txt:
	Likewise.
	* tests/data/test-annotate/libtest24-drop-fns-2.so.abi: Likewise.
	* tests/data/test-annotate/libtest24-drop-fns.so.abi: Likewise.
	* tests/data/test-annotate/test0.abi: Likewise.
	* tests/data/test-annotate/test1.abi: Likewise.
	* tests/data/test-annotate/test15-pr18892.so.abi: Likewise.
	* tests/data/test-annotate/test18-pr19037-libvtkRenderingLIC-6.1.so.abi:
	Likewise.
	* tests/data/test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi:
	Likewise.
	* tests/data/test-annotate/test20-pr19025-libvtkParallelCore-6.1.so.abi:
	Likewise.
	* tests/data/test-annotate/test21-pr19092.so.abi: Likewise.
	* tests/data/test-diff-dwarf/PR25058-liblttng-ctl-report-1.txt:
	Likewise.
	* tests/data/test-diff-dwarf/test4-report.txt: Likewise.
	* tests/data/test-diff-dwarf/test5-report.txt: Likewise.
	* tests/data/test-diff-filter/test-PR26739-2-report-0.txt:
	Likewise.
	* tests/data/test-diff-filter/test30-pr18904-rvalueref-report0.txt:
	Likewise.
	* tests/data/test-diff-filter/test30-pr18904-rvalueref-report1.txt:
	Likewise.
	* tests/data/test-diff-filter/test30-pr18904-rvalueref-report2.txt:
	Likewise.
	* tests/data/test-diff-filter/test31-pr18535-libstdc++-report-0.txt:
	Likewise.
	* tests/data/test-diff-filter/test31-pr18535-libstdc++-report-1.txt:
	Likewise.
	* tests/data/test-diff-filter/test35-pr18754-no-added-syms-report-0.txt:
	Likewise.
	* tests/data/test-diff-filter/test41-report-0.txt: Likewise.
	* tests/data/test-diff-filter/test5-report.txt: Likewise.
	* tests/data/test-diff-pkg/libICE-1.0.6-1.el6.x86_64.rpm--libICE-1.0.9-2.el7.x86_64.rpm-report-0.txt:
	Likewise.
	* tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-2.txt:
	Likewise.
	* tests/data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-0.txt:
	Likewise.
	* tests/data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-1.txt:
	Likewise.
	* tests/data/test-read-dwarf/PR22015-libboost_iostreams.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/PR22122-libftdc.so.abi: Likewise.
	* tests/data/test-read-dwarf/PR24378-fn-is-not-scope.abi:
	Likewise.
	* tests/data/test-read-dwarf/PR25007-sdhci.ko.abi: Likewise.
	* tests/data/test-read-dwarf/libtest24-drop-fns-2.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/libtest24-drop-fns.so.abi: Likewise.
	* tests/data/test-read-dwarf/test-libaaudio.so.abi: Likewise.
	* tests/data/test-read-dwarf/test-libandroid.so.abi: Likewise.
	* tests/data/test-read-dwarf/test0.abi: Likewise.
	* tests/data/test-read-dwarf/test0.hash.abi: Likewise.
	* tests/data/test-read-dwarf/test1.abi: Likewise.
	* tests/data/test-read-dwarf/test1.hash.abi: Likewise.
	* tests/data/test-read-dwarf/test10-pr18818-gcc.so.abi: Likewise.
	* tests/data/test-read-dwarf/test11-pr18828.so.abi: Likewise.
	* tests/data/test-read-dwarf/test12-pr18844.so.abi: Likewise.
	* tests/data/test-read-dwarf/test15-pr18892.so.abi: Likewise.
	* tests/data/test-read-dwarf/test16-pr18904.so.abi: Likewise.
	* tests/data/test-read-dwarf/test18-pr19037-libvtkRenderingLIC-6.1.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/test20-pr19025-libvtkParallelCore-6.1.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/test21-pr19092.so.abi: Likewise.
	* tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2024-08-29 17:15:43 +02:00

279 lines
8.2 KiB
Makefile

## SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
SUBDIRS = data
AM_CXXFLAGS = $(VISIBILITY_FLAGS)
FEDABIPKGDIFF_TEST =
if ENABLE_FEDABIPKGDIFF
if ENABLE_RUNNING_TESTS_WITH_PY3
FEDABIPKGDIFF_TEST += runtestfedabipkgdiffpy3.sh
else
FEDABIPKGDIFF_TEST += runtestfedabipkgdiff.py
endif
endif
ABIDB_TESTS =
if ENABLE_ABIDB
ABIDB_TESTS += runtestabidb1.sh runtestabidb2.sh
endif
RUN_TEST_SLOW_SELF_COMPARE=runtestslowselfcompare.sh
# rather expensive tests (keep in this order), > 1s runtime
TESTS= \
$(RUN_TEST_SLOW_SELF_COMPARE) \
runtestaltdwarf \
runtestdiffsuppr \
runtesttypesstability \
runtestdiffpkg \
runtestannotate \
runtestdifffilter \
runtestreaddwarf \
runtestcanonicalizetypes.sh \
$(ABIDB_TESTS)
if CTF_READER
TESTS += runtestreadctf
endif
if BTF_READER
TESTS += runtestreadbtf
endif
# rather cheap tests
TESTS+= \
runtestabicompat \
runtestabidiff \
runtestabidiffexit \
runtestcorediff \
runtestcxxcompat \
runtestdiffdwarf \
runtestdiffdwarfabixml \
runtestelfhelpers \
runtestini \
runtestkmiwhitelist \
runtestlookupsyms \
runtestreadwrite \
runtestsymtab \
runtestsymtabreader \
runtesttoolsutils \
runtestsvg \
$(FEDABIPKGDIFF_TEST)
if ENABLE_RUNNING_TESTS_WITH_PY3
TESTS += runtestdefaultsupprspy3.sh
else
TESTS += runtestdefaultsupprs.py
endif
EXTRA_DIST = \
runtestcanonicalizetypes.sh.in \
runtestfedabipkgdiff.py.in \
runtestslowselfcompare.sh.in \
mockfedabipkgdiff.in \
test-valgrind-suppressions.supp
if ENABLE_RUNNING_TESTS_WITH_PY3
EXTRA_DIST += \
runtestfedabipkgdiffpy3.sh.in \
runtestdefaultsupprspy3.sh.in
endif
if ENABLE_ABIDB
EXTRA_DIST += runtestabidb1.sh.in runtestabidb2.sh.in
endif
CLEANFILES = \
runtestcanonicalizetypes.output.txt \
runtestcanonicalizetypes.output.final.txt
noinst_PROGRAMS= $(TESTS) testirwalker testdiff2 printdifftree
noinst_SCRIPTS = mockfedabipkgdiff
noinst_LTLIBRARIES = libtestutils.la libtestreadcommon.la libcatch.la
libtestutils_la_SOURCES= \
test-utils.h \
test-utils.cc
libtestutils_la_CXXFLAGS= \
-DABIGAIL_SRC_DIR=\"${abs_top_srcdir}\" \
-DABIGAIL_BUILD_DIR=\"${abs_top_builddir}\"
libtestreadcommon_la_SOURCES= \
test-read-common.h \
test-read-common.cc
libtestreadcommon_la_CXXFLAGS= \
-DABIGAIL_SRC_DIR=\"${abs_top_srcdir}\" \
-DABIGAIL_BUILD_DIR=\"${abs_top_builddir}\"
libcatch_la_SOURCES = lib/catch.cc lib/catch.hpp
runtestreadwrite_SOURCES=test-read-write.cc
runtestreadwrite_LDADD=libtestutils.la $(top_builddir)/src/libabigail.la
runtestreaddwarf_SOURCES=test-read-dwarf.cc
runtestreaddwarf_LDADD=libtestreadcommon.la libtestutils.la \
$(top_builddir)/src/libabigail.la
runtestreaddwarf_LDFLAGS=-pthread
if CTF_READER
runtestreadctf_SOURCES=test-read-ctf.cc
runtestreadctf_LDADD=libtestreadcommon.la libtestutils.la \
$(top_builddir)/src/libabigail.la
runtestreadctf_LDFLAGS=-pthread
endif
if BTF_READER
runtestreadbtf_SOURCES=test-read-btf.cc
runtestreadbtf_LDADD=libtestreadcommon.la libtestutils.la \
$(top_builddir)/src/libabigail.la
runtestreadbtf_LDFLAGS=-pthread
endif
runtestannotate_SOURCES=test-annotate.cc
runtestannotate_LDADD=libtestutils.la $(top_builddir)/src/libabigail.la
runtestlookupsyms_SOURCES=test-lookup-syms.cc
runtestlookupsyms_LDADD=libtestutils.la $(top_builddir)/src/libabigail.la
runtestaltdwarf_SOURCES=test-alt-dwarf-file.cc
runtestaltdwarf_LDADD=libtestutils.la $(top_builddir)/src/libabigail.la
runtestcorediff_SOURCES=test-core-diff.cc
runtestcorediff_LDADD=libtestutils.la $(top_builddir)/src/libabigail.la
runtestabidiff_SOURCES = test-abidiff.cc
runtestabidiff_LDADD = libtestutils.la $(top_builddir)/src/libabigail.la
runtestabidiffexit_SOURCES = test-abidiff-exit.cc
runtestabidiffexit_LDADD = libtestutils.la $(top_builddir)/src/libabigail.la
runtestdiffdwarf_SOURCES = test-diff-dwarf.cc
runtestdiffdwarf_LDADD = libtestutils.la $(top_builddir)/src/libabigail.la
runtestdifffilter_SOURCES = test-diff-filter.cc
runtestdifffilter_LDADD = libtestutils.la $(top_builddir)/src/libabigail.la
runtestdiffsuppr_SOURCES = test-diff-suppr.cc
runtestdiffsuppr_LDADD = libtestutils.la $(top_builddir)/src/libabigail.la
runtestdiffdwarfabixml_SOURCES = test-diff-dwarf-abixml.cc
runtestdiffdwarfabixml_LDADD = libtestutils.la $(top_builddir)/src/libabigail.la
runtestabicompat_SOURCES = test-abicompat.cc
runtestabicompat_LDADD = libtestutils.la $(top_builddir)/src/libabigail.la
runtestdiffpkg_SOURCES = test-diff-pkg.cc
runtestdiffpkg_LDADD = libtestutils.la $(top_builddir)/src/libabigail.la
runtesttypesstability_SOURCES = test-types-stability.cc
runtesttypesstability_LDADD = libtestutils.la $(top_builddir)/src/libabigail.la
runtestini_SOURCES = test-ini.cc
runtestini_LDADD = libtestutils.la $(top_builddir)/src/libabigail.la
runtesttoolsutils_SOURCES = test-tools-utils.cc
runtesttoolsutils_LDADD = libtestutils.la $(top_builddir)/src/libabigail.la
runtestkmiwhitelist_SOURCES = test-kmi-whitelist.cc
runtestkmiwhitelist_LDADD = libtestutils.la libcatch.la $(top_builddir)/src/libabigail.la
runtestelfhelpers_SOURCES = test-elf-helpers.cc
runtestelfhelpers_LDADD = libcatch.la $(top_builddir)/src/libabigail.la
runtestcxxcompat_SOURCES = test-cxx-compat.cc
runtestcxxcompat_LDADD = libcatch.la $(top_builddir)/src/libabigail.la
runtestsymtab_SOURCES = test-symtab.cc
runtestsymtab_LDADD = libtestutils.la libcatch.la $(top_builddir)/src/libabigail.la
runtestsymtabreader_SOURCES = test-symtab-reader.cc
runtestsymtabreader_LDADD = libcatch.la $(top_builddir)/src/libabigail.la
runtestsvg_SOURCES=test-svg.cc
runtestsvg_LDADD=$(top_builddir)/src/libabigail.la
testirwalker_SOURCES=test-ir-walker.cc
testirwalker_LDADD=$(top_builddir)/src/libabigail.la
testdiff2_SOURCES=test-diff2.cc
testdiff2_LDADD=$(top_builddir)/src/libabigail.la
printdifftree_SOURCES = print-diff-tree.cc
printdifftree_LDADD = $(top_builddir)/src/libabigail.la
runtestslowselfcompare_sh_SOURCES =
runtestslowselfcompare.sh$(EXEEXT):
runtestcanonicalizetypes_sh_SOURCES =
runtestcanonicalizetypes.sh$(EXEEXT):
runtestfedabipkgdiff_py_SOURCES =
runtestfedabipkgdiff.py$(EXEEXT):
runtestdefaultsupprs_py_SOURCES =
runtestdefaultsupprs.py$(EXEEXT):
runtestfedabipkgdiffpy3_sh_SOURCES =
runtestfedabipkgdiffpy3.sh$(EXEEXT):
runtestdefaultsupprspy3_sh_SOURCES =
runtestdefaultsupprspy3.sh$(EXEEXT):
runtestabidb1_sh_SOURCES =
runtestabidb1.sh$(EXEEXT):
runtestabidb2_sh_SOURCES =
runtestabidb2.sh$(EXEEXT):
AM_CPPFLAGS=-I${abs_top_srcdir}/include -I${abs_top_srcdir}/src \
-I${abs_top_builddir}/include -I${abs_top_srcdir}/tools -fPIC
clean-local: clean-local-check
.PHONY: clean-local-check
clean-local-check:
-rm -rf ${builddir}/output *.svg *.gv
@VALGRIND_CHECK_RULES@
VALGRIND_SUPPRESSIONS_FILES = ${srcdir}/test-valgrind-suppressions.supp
# These are flags passed to Valgrind so that it follows children
# processes of the test programs. This is because many test programs
# actually fork libabigail command line tools, and we want to valgrind
# those libabigail command line tools as well.
#
# The problem though is that there are many other command line
# programs that are forked too. For instance, /bin/sh is forked
# because tests are using the system() function to execute commands.
# So we must tell Valgrind to avoid following a bunch of command line
# programs that we don't care about and that take a lot of time to
# valgrind.
RECURSIVE_VALGRIND_FLAGS = \
--num-callers=30 \
--trace-children=yes \
--trace-children-skip=/bin/diff,/bin/rm,/bin/mkdir,/bin/cd,*cpio,/bin/dpkg,/bin/rpm,/bin/test,/bin/tar,/bin/sed,/bin/ls,/bin/g++,/*collect*,/bin/ld
# Use the target below to run tests under Valgrind's memcheck tool by
# telling it to follow children process, so that it can also check
# libabigail tools that are forked by the tests. This usually takes a
# while. So, to launch just one test in this configuration, if you
# are in the top-most source directory you can do:
#
# make -C <build-directory>/tests check-valgrind-memcheck-recursive TESTS=runtestdiffsuppr
check-valgrind-memcheck-recursive:
$(MAKE) check-valgrind-memcheck VALGRIND_FLAGS="${RECURSIVE_VALGRIND_FLAGS}"
check-valgrind-helgrind-recursive:
$(MAKE) check-valgrind-helgrind VALGRIND_FLAGS="${RECURSIVE_VALGRIND_FLAGS}"
check-self-compare:
$(MAKE) check TESTS=runtestslowselfcompare.sh ENABLE_SLOW_TEST=yes AM_TESTSUITE_SUMMARY_HEADER=' for runtestslowselfcompare.sh'