Add regression tests for ctf reading
This patch implements some regression tests for ctf reading.
Since the code shares a lot of functionalities already used
in the readi-dwarf test, a library was built and test common
harness were moved to a common location. So input files for
test-read-{dwarf,ctf}.cc now are located in:
tests/data/test-read-common directory, ABIs description are
stored in the same location but in a separate file, one for
each binary debugging information: (e.g, test4-ctf.so.abi
and test4-dwarf.so.abi)
* tests/test-read-ctf.cc: New ctf reading regression test.
* tests/test-read-common.cc: New library to be used with
test-read-{ctf,dwarf}.cc.
* tests/test-read-common.h: Likewise.
* tests/test-annotate.cc (in_out_specs): Adjust path for input files.
* tests/Makefile.am: Build new tests/test-read-ctf.cc file.
* tests/data/Makefile.am: Add test inputs and expected files.
Add libtestreadcommon.a test library and use it for test-read-{ctf,dwarf}.
* tests/test-read-dwarf.cc: Adapt test to use libtestreadcommon.a in
test-read-common.{cc,h}.
* tests/data/test-annotate/test3.so.abi: Adjust ELF input path file
location to ./tests/data/test-read-common.
* tests/data/test-annotate/test4.so.abi: Likewise.
* tests/data/test-read-common/PR26261: Move test harness to
test-read-common directory.
* tests/data/test-read-common/PR27700: Likewise.
* tests/data/test-read-common/test-PR26568-*: Likewise.
* tests/data/test-read-common/test3.{c,so}: Likewise.
* tests/data/test-read-common/test4.{c,so}: Likewise.
* tests/data/test-read-common/crti*: Helper object to export
_init and _fini sysmbols.
* tests/data/test-read-ctf/test-ambiguous-struct-A.c: New testcase.
* tests/data/test-read-ctf/test-ambiguous-struct-B.c: Likewise.
* tests/data/test-read-ctf/test-conflicting-type-syms-a.c: Likewise.
* tests/data/test-read-ctf/test-conflicting-type-syms-b.c: Likewise.
* tests/data/test-read-ctf/test-enum.c: Likewise.
* tests/data/test-read-ctf/test-enum-many.c: Likewise.
* tests/data/test-read-ctf/test-enum-symbol.c: Likewise.
* tests/data/test-read-ctf/test-struct-iteration.c: Likewise.
* tests/data/test-read-ctf/test-dynamic-array.c: Likewise.
* tests/data/test-read-ctf/test0.c: Likewise.
* tests/data/test-read-ctf/test1.c: Likewise.
* tests/data/test-read-ctf/test2.c: Likewise.
* tests/data/test-read-ctf/test5.c: Likewise.
* tests/data/test-read-ctf/test7.{c,h}: Likewise.
* tests/data/test-read-ctf/test8.c: Likewise.
* tests/data/test-read-ctf/test9.c: Likewise.
* tests/data/test-read-ctf/test-ambiguous-struct-A.o.hash.abi: Testcase
expected result.
* tests/data/test-read-ctf/PR26261/PR26261-exe.abi: Likewise.
* tests/data/test-read-ctf/PR27700/test-PR27700.abi: Likewise.
* tests/data/test-read-ctf/test-ambiguous-struct-A.o.hash.abi: Likewise.
* tests/data/test-read-ctf/test-ambiguous-struct-B.o.hash.abi: Likewise.
* tests/data/test-read-ctf/test-conflicting-type-syms-a.o.hash.abi: Likewise.
* tests/data/test-read-ctf/test-conflicting-type-syms-b.o.hash.abi: Likewise.
* tests/data/test-read-ctf/test-enum.o.abi: Likewise.
* tests/data/test-read-ctf/test-enum-many.o.hash.abi: Likewise.
* tests/data/test-read-ctf/test-enum-symbol.o.hash.abi: Likewise.
* tests/data/test-read-ctf/test-struct-iteration.o.abi: Likewise.
* tests/data/test-read-ctf/test-dynamic-array.o.abi: Likewise.
* tests/data/test-read-ctf/test0: Likewise.
* tests/data/test-read-ctf/test0*.abi: Likewise.
* tests/data/test-read-ctf/test1.so: Likewise.
* tests/data/test-read-ctf/test1*.abi: Likewise.
* tests/data/test-read-ctf/test2.so: Likewise.
* tests/data/test-read-ctf/test2*.abi: Likewise.
* tests/data/test-read-ctf/test3.so.abi: Likewise.
* tests/data/test-read-ctf/test4*.abi: Likewise.
* tests/data/test-read-ctf/test5.o.abi: Likewise.
* tests/data/test-read-ctf/test7.o.abi: Likewise.
* tests/data/test-read-ctf/test8.o.abi: Likewise.
* tests/data/test-read-ctf/test9.o.abi: Likewise.
* tests/data/test-read-dwarf/PR26261/PR26261-exe.abi: Update
expected abixml file.
* tests/data/test-read-dwarf/PR27700/test-PR27700.abi: Likewise.
* tests/data/test-read-dwarf/test-PR26568-1.*.abi: Likewise.
* tests/data/test-read-dwarf/test3*.abi: Likewise.
* tests/data/test-read-dwarf/test4*.abi: Likewise.
* doc/api/libabigail.doxy: Add tests/test-read-common.{cc,h} to
doxygen.
Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2021-12-14 06:25:15 +00:00
|
|
|
// -*- Mode: C++ -*-
|
|
|
|
//
|
|
|
|
|
|
|
|
/// @file
|
|
|
|
///
|
|
|
|
/// This file implements the common functionality for the tests in
|
|
|
|
/// CTF and DWARF readers, it does the abstraction in the `act` test
|
|
|
|
/// stage.
|
|
|
|
|
|
|
|
#include <fstream>
|
|
|
|
#include <cstring>
|
|
|
|
#include "test-read-common.h"
|
|
|
|
|
|
|
|
using std::ofstream;
|
|
|
|
using std::cerr;
|
|
|
|
using std::dynamic_pointer_cast;
|
|
|
|
|
|
|
|
using abigail::tools_utils::emit_prefix;
|
|
|
|
using abigail::tests::get_build_dir;
|
|
|
|
using abigail::xml_writer::write_context_sptr;
|
|
|
|
using abigail::xml_writer::create_write_context;
|
|
|
|
using abigail::xml_writer::write_corpus;
|
|
|
|
|
|
|
|
namespace abigail
|
|
|
|
{
|
|
|
|
namespace tests
|
|
|
|
{
|
|
|
|
namespace read_common
|
|
|
|
{
|
|
|
|
|
|
|
|
/// Constructor.
|
|
|
|
///
|
|
|
|
/// Task to be executed for each test entry in @ref
|
|
|
|
/// abigail::tests::read_common::InOutSpec.
|
|
|
|
///
|
|
|
|
/// @param InOutSpec the set of tests.
|
|
|
|
///
|
|
|
|
/// @param a_out_abi_base the output base directory for abixml files.
|
|
|
|
///
|
|
|
|
/// @param a_in_elf_base the input base directory for object files.
|
|
|
|
///
|
|
|
|
/// @param a_in_elf_base the input base directory for expected
|
|
|
|
/// abixml files.
|
|
|
|
test_task::test_task(const InOutSpec &s,
|
|
|
|
string& a_out_abi_base,
|
|
|
|
string& a_in_elf_base,
|
|
|
|
string& a_in_abi_base)
|
|
|
|
: is_ok(true),
|
|
|
|
spec(s),
|
|
|
|
out_abi_base(a_out_abi_base),
|
|
|
|
in_elf_base(a_in_elf_base),
|
|
|
|
in_abi_base(a_in_abi_base)
|
|
|
|
{}
|
|
|
|
|
|
|
|
/// Serialize the abixml @p out_abi_path file.
|
|
|
|
///
|
|
|
|
/// @param out_abi_path the abixml path file.
|
|
|
|
///
|
|
|
|
/// @param corp the ABI @ref abigail::ir::corpus.
|
|
|
|
///
|
|
|
|
/// @return true if abixml file was serialized successfully. Otherwise
|
|
|
|
/// `error_message` is set with @p out_abi_path and false is returned.
|
|
|
|
bool
|
|
|
|
test_task::serialize_corpus(const string& out_abi_path,
|
|
|
|
corpus_sptr corp)
|
|
|
|
{
|
|
|
|
ofstream of(out_abi_path.c_str(), std::ios_base::trunc);
|
|
|
|
if (!of.is_open())
|
|
|
|
{
|
|
|
|
error_message = string("failed to read ") + out_abi_path + "\n";
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
write_context_sptr write_ctxt
|
|
|
|
= create_write_context(corp->get_environment(), of);
|
|
|
|
set_type_id_style(*write_ctxt, spec.type_id_style);
|
Emit & read undefined interfaces to & from ABIXML
This patch teaches the ABIXML writer to emit information about
undefined interfaces. It also teaches the ABIXML reader to read
information about undefined interfaces.
It introduces two new ABIXML elements:
'undefined-elf-function-symbols' and 'undefined-elf-variable-symbols'
to represent undefined function and variable symbols.
Then, in the 'abi-instr' element functions and variables that
reference undefined elf symbols now have an 'elf-symbol-id' attribute
referencing the undefined symbol listed in the new
'undefined-elf-variable-symbols' or 'undefined-elf-function-symbols'
element.
The patch introduces tests that perform compatibility checks done on
ABIXML files.
* include/abg-writer.h (set_write_undefined_symbols): Declare new
function.
(set_common_options): Use the new set_write_undefined_symbols in
this function template.
* src/abg-dwarf-reader.cc (reader::{get_die_language, die_is_in_c,
die_is_in_cplus_plus, die_is_in_c_or_cplusplus}): Move these
member functions into ...
(get_die_language, die_is_in_c, die_is_in_cplus_plus)
(die_is_in_c_or_cplusplus): ... these static non-member functions.
(fn_die_equal_by_linkage_name): Adjust and remove the now useless
reader parameter.
(compare_dies, get_scope_die, function_is_suppressed)
(variable_is_suppressed): Adjust.
(build_translation_unit_and_add_to_ir): When we are asked to load
undefined symbol, make sure to also analyze top-level class types
and if we are in C++, also analyze top-level unions and structs as
these might also have some undefined interfaces.
* src/abg-reader.cc (build_elf_symbol_db): Let's not construct and
return the symbol DB anymore. Rather, let's let the caller
construct it, so we can just update it with the input gathered.
(read_symbol_db_from_input): Support getting undefined function
and variable symbols from the new undefined-elf-function-symbols
and undefined-elf-variable-symbols elements. Note that undefined
and defined function symbols go into the same symbol DB whereas
undefined and defined variable symbols go into another symbol DB.
Now, we suppose that the variable & symbol DBs are allocated by
the caller. We pass it down to build_elf_symbol_db that populates
it. Maybe we should rename build_elf_symbol_db into
populate_elf_symbol_db.
(reader::read_corpus): Allocate the function
and variable symbol DB and let read_symbol_db_from_input populate
it. Sort functions and variables after reading the whole ABIXML.
* src/abg-writer.cc (write_context::write_context): Define new
data member.
(write_context::write_context): Initialize it.
(write_context::{get,set}::write_undefined_symbols): Define
accessors.
(set_write_undefined_symbols): Define a new function.
(write_context::decl_is_emitted): Add a new overload.
(write_elf_symbol_reference): Add a writer context and a corpus
parameter. If the symbol is not in the corpus or if the symbol is
undefined and we were not asked to emit undefined symbols then do
not emit any reference to it.
(write_translation_unit): Emit the undefined functions and
variables that belong to the current translation unit, along with
their reference to the undefined ELF symbol they are associated
to.
(write_var_decl, write_function_decl): Let
write_elf_symbol_reference decide whether it should emit the
reference to ELF symbol or not, as it now know how to make that
decision.
(write_corpus): Write the undefined function & variable ELF symbol
data bases. These in the new 'undefined-elf-function-symbols' and
'undefined-elf-variable-symbols' elements.
* tools/abidw.cc (options::load_undefined_interfaces): Define new
data member.
(options:options): Initialize it.
(display_usage): Add a help string for the
--no-load-undefined-interfaces option.
(parse_command_line): Parse the --no-load-undefined-interfaces
option.
(set_generic_options): Set the
fe_iface::option_type::load_undefined_interfaces option.
* doc/manuals/abidw.rst: Document the new
--no-load-undefined-interfaces of abidw.
* tests/data/test-abicompat/test10/libtest10-with-exported-symbols.so:
New binary input file.
* tests/data/test-abicompat/test10/libtest10-with-incompatible-exported-symbols.so:
New binary input file.
* tests/data/test-abicompat/test10/libtest10-with-incompatible-exported-symbols.so.abi:
New abixml input file.
* tests/data/test-abicompat/test10/test10-app-with-undefined-symbols:
New binary input file.
* tests/data/test-abicompat/test10/test10-app-with-undefined-symbols.abi:
New abixml input file.
* tests/data/test-abicompat/test10/test10-app-with-undefined-symbols.cc:
New source file for binary test input
* tests/data/test-abicompat/test10/test10-fn-changed-report-0.txt:
New source file for binary test input
* tests/data/test-abicompat/test10/test10-fn-changed-report-1.txt:
New source file for binary test input
* tests/data/test-abicompat/test10/test10-fn-changed-report-2.txt:
New source file for binary test input
* tests/data/test-abicompat/test10/test10-fn-changed-report-3.txt:
New source file for binary test input
* tests/data/test-abicompat/test10/test10-fn-changed-report-4.txt:
New source file for binary test input
* tests/data/test-abicompat/test10/test10-with-exported-symbols.cc:
New source file for binary test input
* tests/data/test-abicompat/test10/test10-with-exported-symbols.h:
New source file for binary test input
* tests/data/test-abicompat/test10/test10-with-incompatible-exported-symbols.cc:
New source file for binary test input
* tests/data/test-abicompat/test10/test10-with-incompatible-exported-symbols.h:
New source file for binary test input.
* tests/data/Makefile.am: Add new test input files to source
distribution.
* tests/test-abicompat.cc (in_out_specs): Add the new test inputs
to this test harness.
* tests/test-annotate.cc (main): Use the new
--no-load-undefined-interfaces option of abidw to keep the old
behavior.
* tests/test-read-common.cc (test_task::serialize_corpus): Do not
emit undefined symbols.
* tests/test-read-dwarf.cc (test_task_dwarf::perform): Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2024-03-08 14:31:44 +00:00
|
|
|
set_write_undefined_symbols(*write_ctxt, false);
|
Add regression tests for ctf reading
This patch implements some regression tests for ctf reading.
Since the code shares a lot of functionalities already used
in the readi-dwarf test, a library was built and test common
harness were moved to a common location. So input files for
test-read-{dwarf,ctf}.cc now are located in:
tests/data/test-read-common directory, ABIs description are
stored in the same location but in a separate file, one for
each binary debugging information: (e.g, test4-ctf.so.abi
and test4-dwarf.so.abi)
* tests/test-read-ctf.cc: New ctf reading regression test.
* tests/test-read-common.cc: New library to be used with
test-read-{ctf,dwarf}.cc.
* tests/test-read-common.h: Likewise.
* tests/test-annotate.cc (in_out_specs): Adjust path for input files.
* tests/Makefile.am: Build new tests/test-read-ctf.cc file.
* tests/data/Makefile.am: Add test inputs and expected files.
Add libtestreadcommon.a test library and use it for test-read-{ctf,dwarf}.
* tests/test-read-dwarf.cc: Adapt test to use libtestreadcommon.a in
test-read-common.{cc,h}.
* tests/data/test-annotate/test3.so.abi: Adjust ELF input path file
location to ./tests/data/test-read-common.
* tests/data/test-annotate/test4.so.abi: Likewise.
* tests/data/test-read-common/PR26261: Move test harness to
test-read-common directory.
* tests/data/test-read-common/PR27700: Likewise.
* tests/data/test-read-common/test-PR26568-*: Likewise.
* tests/data/test-read-common/test3.{c,so}: Likewise.
* tests/data/test-read-common/test4.{c,so}: Likewise.
* tests/data/test-read-common/crti*: Helper object to export
_init and _fini sysmbols.
* tests/data/test-read-ctf/test-ambiguous-struct-A.c: New testcase.
* tests/data/test-read-ctf/test-ambiguous-struct-B.c: Likewise.
* tests/data/test-read-ctf/test-conflicting-type-syms-a.c: Likewise.
* tests/data/test-read-ctf/test-conflicting-type-syms-b.c: Likewise.
* tests/data/test-read-ctf/test-enum.c: Likewise.
* tests/data/test-read-ctf/test-enum-many.c: Likewise.
* tests/data/test-read-ctf/test-enum-symbol.c: Likewise.
* tests/data/test-read-ctf/test-struct-iteration.c: Likewise.
* tests/data/test-read-ctf/test-dynamic-array.c: Likewise.
* tests/data/test-read-ctf/test0.c: Likewise.
* tests/data/test-read-ctf/test1.c: Likewise.
* tests/data/test-read-ctf/test2.c: Likewise.
* tests/data/test-read-ctf/test5.c: Likewise.
* tests/data/test-read-ctf/test7.{c,h}: Likewise.
* tests/data/test-read-ctf/test8.c: Likewise.
* tests/data/test-read-ctf/test9.c: Likewise.
* tests/data/test-read-ctf/test-ambiguous-struct-A.o.hash.abi: Testcase
expected result.
* tests/data/test-read-ctf/PR26261/PR26261-exe.abi: Likewise.
* tests/data/test-read-ctf/PR27700/test-PR27700.abi: Likewise.
* tests/data/test-read-ctf/test-ambiguous-struct-A.o.hash.abi: Likewise.
* tests/data/test-read-ctf/test-ambiguous-struct-B.o.hash.abi: Likewise.
* tests/data/test-read-ctf/test-conflicting-type-syms-a.o.hash.abi: Likewise.
* tests/data/test-read-ctf/test-conflicting-type-syms-b.o.hash.abi: Likewise.
* tests/data/test-read-ctf/test-enum.o.abi: Likewise.
* tests/data/test-read-ctf/test-enum-many.o.hash.abi: Likewise.
* tests/data/test-read-ctf/test-enum-symbol.o.hash.abi: Likewise.
* tests/data/test-read-ctf/test-struct-iteration.o.abi: Likewise.
* tests/data/test-read-ctf/test-dynamic-array.o.abi: Likewise.
* tests/data/test-read-ctf/test0: Likewise.
* tests/data/test-read-ctf/test0*.abi: Likewise.
* tests/data/test-read-ctf/test1.so: Likewise.
* tests/data/test-read-ctf/test1*.abi: Likewise.
* tests/data/test-read-ctf/test2.so: Likewise.
* tests/data/test-read-ctf/test2*.abi: Likewise.
* tests/data/test-read-ctf/test3.so.abi: Likewise.
* tests/data/test-read-ctf/test4*.abi: Likewise.
* tests/data/test-read-ctf/test5.o.abi: Likewise.
* tests/data/test-read-ctf/test7.o.abi: Likewise.
* tests/data/test-read-ctf/test8.o.abi: Likewise.
* tests/data/test-read-ctf/test9.o.abi: Likewise.
* tests/data/test-read-dwarf/PR26261/PR26261-exe.abi: Update
expected abixml file.
* tests/data/test-read-dwarf/PR27700/test-PR27700.abi: Likewise.
* tests/data/test-read-dwarf/test-PR26568-1.*.abi: Likewise.
* tests/data/test-read-dwarf/test3*.abi: Likewise.
* tests/data/test-read-dwarf/test4*.abi: Likewise.
* doc/api/libabigail.doxy: Add tests/test-read-common.{cc,h} to
doxygen.
Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2021-12-14 06:25:15 +00:00
|
|
|
is_ok = write_corpus(*write_ctxt, corp, /*indent=*/0);
|
|
|
|
of.close();
|
|
|
|
|
|
|
|
return is_ok;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Spawn `abidw --abidiff` tool appending @p extargs argument.
|
|
|
|
///
|
|
|
|
/// Thew input file object used by `abidw` will be specified by
|
|
|
|
/// `in_elf_path'.
|
|
|
|
///
|
|
|
|
/// @param extargs the extra argument(s) passed to `abidw` tool.
|
|
|
|
///
|
|
|
|
/// @return true if `abidw` tool was executed correctly. Otherwise
|
|
|
|
/// `error_message` shows the full path of the input file object and
|
|
|
|
/// the full output path for the abixml file.
|
|
|
|
bool
|
|
|
|
test_task::run_abidw(const string& extargs)
|
|
|
|
{
|
|
|
|
string abidw = string(get_build_dir()) + "/tools/abidw";
|
|
|
|
string drop_private_types;
|
Use the CTF reader by default when applicable
At the moment, the tools abidw, abidiff, abipkgdiff and kmidiff all
use the DWARF front-end by default. When the "--ctf" option is added
to the command line, they use the CTF front-end.
This patch changes that behaviour in the way described below.
If the "--ctf" command line option is passed to the tool and if the
binary to analyze contains CTF debug info, then the CTF front-end is
used.
If the binary contains ONLY CTF debug info, then the CTF front-end is
used, even if no "--ctf" option was provided.
In all the other cases, the DWARF front-end is used.
Of course, the CTF front-end is not used at all if the CTF
functionality hasn't been enabled at configure time.
This new behaviour is effective for user space and Linux kernel
binaries.
* doc/manuals/abidiff.rst: Adjust.
* doc/manuals/abidw.rst: Likewise.
* doc/manuals/abipkgdiff.rst: Likewise.
* doc/manuals/kmidiff.rst: Likewise.
* include/abg-elf-based-reader.h (initialize): Add member function.
* include/abg-elf-reader.h (has_{dwarf,ctf}_debug_info): Add predicate
functions.
* include/abg-tools-utils.h (create_best_elf_based_reader): Add arguments.
* src/abg-ctf-reader.cc (process_ctf_typedef, process_ctf_base_type)
(process_ctf_function_type, process_ctf_sou_members, process_ctf_forward_type)
(process_ctf_struct_type, process_ctf_union_type, process_ctf_array_type)
(process_ctf_qualified_type, process_ctf_pointer_type, process_ctf_enum_type):
Remove arguments. Using getters to access required information instead.
(reader::cur_tu_): Add data member.
(initialize): Add arguments.
(cur_transl_unit): Add {get,set)ter.
(slurp_elf_info): Clear `STATUS_DEBUG_INFO_NOT_FOUND' if corpus is
`LINUX_KERNEL_BINARY_ORIGIN'.
(reader::lookup_type): Remove.
(reader::build_type): New member function.
* src/abg-elf-reader.cc (reader::reader): Locate ctf debug info
from binary file.
(reader::reader): Reset base `fe_iface' constructor.
(reader::has_{dwarf,ctf}_debug_info): New definitions.
(reader::read_corpus): Set `STATUS_DEBUG_INFO_NOT_FOUND' according
to corpus::origin.
* src/abg-tools-utils.cc (dir_contains_ctf_archive): Define new member.
(file_has_ctf_debug_info): Looks for kernel ctf debug information archive.
(maybe_load_vmlinux_{dwarf,ctf}_corpus): Remove.
(load_vmlinux_corpus): Define function to load IR from kernel
regardless of the corpus::origin.
(build_corpus_group_from_kernel_dist_under): Use
create_best_elf_based_reader to select the front-end.
(create_best_elf_based_reader): Adjust to allow fallback behaviour
for different front-ends.
* tests/data/Makefile.am: Add tests.
* tests/data/test-diff-pkg-ctf/dirpkg-3-report-2.txt: Adjust.
* tests/data/test-read-ctf/test-fallback.abi: New test case.
* tests/data/test-read-ctf/test-fallback.c: Likewise.
* tests/data/test-read-ctf/test-fallback.o: Likewise.
* tests/data/test-read-dwarf/test-fallback.abi: Likewise.
* tests/data/test-read-dwarf/test-fallback.c: Likewise.
* tests/data/test-read-dwarf/test-fallback.o: Likewise.
* tests/test-diff-pkg.cc: Adjust.
* tests/test-read-common.cc (test_task::run_abidw): Use the
`options:option' field.
* tests/test-read-common.h (InOutSpec): Add new member.
* tests/test-read-ctf.cc (in_out_specs): Add option field to test
suite. Add new test case.
* tests/test-read-dwarf.cc: Likewise.
* tools/abidiff.cc (main): Use create_best_elf_based_reader.
* tools/abidw.cc: Likewise.
* tools/abipkgdiff.cc: Likewise.
Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2022-11-22 16:00:50 +00:00
|
|
|
string spec_options = spec.options ? spec.options : "";
|
2022-05-07 01:43:05 +00:00
|
|
|
set_in_abi_path();
|
|
|
|
|
Add regression tests for ctf reading
This patch implements some regression tests for ctf reading.
Since the code shares a lot of functionalities already used
in the readi-dwarf test, a library was built and test common
harness were moved to a common location. So input files for
test-read-{dwarf,ctf}.cc now are located in:
tests/data/test-read-common directory, ABIs description are
stored in the same location but in a separate file, one for
each binary debugging information: (e.g, test4-ctf.so.abi
and test4-dwarf.so.abi)
* tests/test-read-ctf.cc: New ctf reading regression test.
* tests/test-read-common.cc: New library to be used with
test-read-{ctf,dwarf}.cc.
* tests/test-read-common.h: Likewise.
* tests/test-annotate.cc (in_out_specs): Adjust path for input files.
* tests/Makefile.am: Build new tests/test-read-ctf.cc file.
* tests/data/Makefile.am: Add test inputs and expected files.
Add libtestreadcommon.a test library and use it for test-read-{ctf,dwarf}.
* tests/test-read-dwarf.cc: Adapt test to use libtestreadcommon.a in
test-read-common.{cc,h}.
* tests/data/test-annotate/test3.so.abi: Adjust ELF input path file
location to ./tests/data/test-read-common.
* tests/data/test-annotate/test4.so.abi: Likewise.
* tests/data/test-read-common/PR26261: Move test harness to
test-read-common directory.
* tests/data/test-read-common/PR27700: Likewise.
* tests/data/test-read-common/test-PR26568-*: Likewise.
* tests/data/test-read-common/test3.{c,so}: Likewise.
* tests/data/test-read-common/test4.{c,so}: Likewise.
* tests/data/test-read-common/crti*: Helper object to export
_init and _fini sysmbols.
* tests/data/test-read-ctf/test-ambiguous-struct-A.c: New testcase.
* tests/data/test-read-ctf/test-ambiguous-struct-B.c: Likewise.
* tests/data/test-read-ctf/test-conflicting-type-syms-a.c: Likewise.
* tests/data/test-read-ctf/test-conflicting-type-syms-b.c: Likewise.
* tests/data/test-read-ctf/test-enum.c: Likewise.
* tests/data/test-read-ctf/test-enum-many.c: Likewise.
* tests/data/test-read-ctf/test-enum-symbol.c: Likewise.
* tests/data/test-read-ctf/test-struct-iteration.c: Likewise.
* tests/data/test-read-ctf/test-dynamic-array.c: Likewise.
* tests/data/test-read-ctf/test0.c: Likewise.
* tests/data/test-read-ctf/test1.c: Likewise.
* tests/data/test-read-ctf/test2.c: Likewise.
* tests/data/test-read-ctf/test5.c: Likewise.
* tests/data/test-read-ctf/test7.{c,h}: Likewise.
* tests/data/test-read-ctf/test8.c: Likewise.
* tests/data/test-read-ctf/test9.c: Likewise.
* tests/data/test-read-ctf/test-ambiguous-struct-A.o.hash.abi: Testcase
expected result.
* tests/data/test-read-ctf/PR26261/PR26261-exe.abi: Likewise.
* tests/data/test-read-ctf/PR27700/test-PR27700.abi: Likewise.
* tests/data/test-read-ctf/test-ambiguous-struct-A.o.hash.abi: Likewise.
* tests/data/test-read-ctf/test-ambiguous-struct-B.o.hash.abi: Likewise.
* tests/data/test-read-ctf/test-conflicting-type-syms-a.o.hash.abi: Likewise.
* tests/data/test-read-ctf/test-conflicting-type-syms-b.o.hash.abi: Likewise.
* tests/data/test-read-ctf/test-enum.o.abi: Likewise.
* tests/data/test-read-ctf/test-enum-many.o.hash.abi: Likewise.
* tests/data/test-read-ctf/test-enum-symbol.o.hash.abi: Likewise.
* tests/data/test-read-ctf/test-struct-iteration.o.abi: Likewise.
* tests/data/test-read-ctf/test-dynamic-array.o.abi: Likewise.
* tests/data/test-read-ctf/test0: Likewise.
* tests/data/test-read-ctf/test0*.abi: Likewise.
* tests/data/test-read-ctf/test1.so: Likewise.
* tests/data/test-read-ctf/test1*.abi: Likewise.
* tests/data/test-read-ctf/test2.so: Likewise.
* tests/data/test-read-ctf/test2*.abi: Likewise.
* tests/data/test-read-ctf/test3.so.abi: Likewise.
* tests/data/test-read-ctf/test4*.abi: Likewise.
* tests/data/test-read-ctf/test5.o.abi: Likewise.
* tests/data/test-read-ctf/test7.o.abi: Likewise.
* tests/data/test-read-ctf/test8.o.abi: Likewise.
* tests/data/test-read-ctf/test9.o.abi: Likewise.
* tests/data/test-read-dwarf/PR26261/PR26261-exe.abi: Update
expected abixml file.
* tests/data/test-read-dwarf/PR27700/test-PR27700.abi: Likewise.
* tests/data/test-read-dwarf/test-PR26568-1.*.abi: Likewise.
* tests/data/test-read-dwarf/test3*.abi: Likewise.
* tests/data/test-read-dwarf/test4*.abi: Likewise.
* doc/api/libabigail.doxy: Add tests/test-read-common.{cc,h} to
doxygen.
Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2021-12-14 06:25:15 +00:00
|
|
|
if (!in_public_headers_path.empty())
|
|
|
|
drop_private_types += "--headers-dir " + in_public_headers_path +
|
|
|
|
" --drop-private-types";
|
Use the CTF reader by default when applicable
At the moment, the tools abidw, abidiff, abipkgdiff and kmidiff all
use the DWARF front-end by default. When the "--ctf" option is added
to the command line, they use the CTF front-end.
This patch changes that behaviour in the way described below.
If the "--ctf" command line option is passed to the tool and if the
binary to analyze contains CTF debug info, then the CTF front-end is
used.
If the binary contains ONLY CTF debug info, then the CTF front-end is
used, even if no "--ctf" option was provided.
In all the other cases, the DWARF front-end is used.
Of course, the CTF front-end is not used at all if the CTF
functionality hasn't been enabled at configure time.
This new behaviour is effective for user space and Linux kernel
binaries.
* doc/manuals/abidiff.rst: Adjust.
* doc/manuals/abidw.rst: Likewise.
* doc/manuals/abipkgdiff.rst: Likewise.
* doc/manuals/kmidiff.rst: Likewise.
* include/abg-elf-based-reader.h (initialize): Add member function.
* include/abg-elf-reader.h (has_{dwarf,ctf}_debug_info): Add predicate
functions.
* include/abg-tools-utils.h (create_best_elf_based_reader): Add arguments.
* src/abg-ctf-reader.cc (process_ctf_typedef, process_ctf_base_type)
(process_ctf_function_type, process_ctf_sou_members, process_ctf_forward_type)
(process_ctf_struct_type, process_ctf_union_type, process_ctf_array_type)
(process_ctf_qualified_type, process_ctf_pointer_type, process_ctf_enum_type):
Remove arguments. Using getters to access required information instead.
(reader::cur_tu_): Add data member.
(initialize): Add arguments.
(cur_transl_unit): Add {get,set)ter.
(slurp_elf_info): Clear `STATUS_DEBUG_INFO_NOT_FOUND' if corpus is
`LINUX_KERNEL_BINARY_ORIGIN'.
(reader::lookup_type): Remove.
(reader::build_type): New member function.
* src/abg-elf-reader.cc (reader::reader): Locate ctf debug info
from binary file.
(reader::reader): Reset base `fe_iface' constructor.
(reader::has_{dwarf,ctf}_debug_info): New definitions.
(reader::read_corpus): Set `STATUS_DEBUG_INFO_NOT_FOUND' according
to corpus::origin.
* src/abg-tools-utils.cc (dir_contains_ctf_archive): Define new member.
(file_has_ctf_debug_info): Looks for kernel ctf debug information archive.
(maybe_load_vmlinux_{dwarf,ctf}_corpus): Remove.
(load_vmlinux_corpus): Define function to load IR from kernel
regardless of the corpus::origin.
(build_corpus_group_from_kernel_dist_under): Use
create_best_elf_based_reader to select the front-end.
(create_best_elf_based_reader): Adjust to allow fallback behaviour
for different front-ends.
* tests/data/Makefile.am: Add tests.
* tests/data/test-diff-pkg-ctf/dirpkg-3-report-2.txt: Adjust.
* tests/data/test-read-ctf/test-fallback.abi: New test case.
* tests/data/test-read-ctf/test-fallback.c: Likewise.
* tests/data/test-read-ctf/test-fallback.o: Likewise.
* tests/data/test-read-dwarf/test-fallback.abi: Likewise.
* tests/data/test-read-dwarf/test-fallback.c: Likewise.
* tests/data/test-read-dwarf/test-fallback.o: Likewise.
* tests/test-diff-pkg.cc: Adjust.
* tests/test-read-common.cc (test_task::run_abidw): Use the
`options:option' field.
* tests/test-read-common.h (InOutSpec): Add new member.
* tests/test-read-ctf.cc (in_out_specs): Add option field to test
suite. Add new test case.
* tests/test-read-dwarf.cc: Likewise.
* tools/abidiff.cc (main): Use create_best_elf_based_reader.
* tools/abidw.cc: Likewise.
* tools/abipkgdiff.cc: Likewise.
Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2022-11-22 16:00:50 +00:00
|
|
|
string cmd = abidw + " " + spec_options + drop_private_types +
|
2024-03-26 15:20:18 +00:00
|
|
|
" --abidiff " + extargs + in_elf_path;
|
Add regression tests for ctf reading
This patch implements some regression tests for ctf reading.
Since the code shares a lot of functionalities already used
in the readi-dwarf test, a library was built and test common
harness were moved to a common location. So input files for
test-read-{dwarf,ctf}.cc now are located in:
tests/data/test-read-common directory, ABIs description are
stored in the same location but in a separate file, one for
each binary debugging information: (e.g, test4-ctf.so.abi
and test4-dwarf.so.abi)
* tests/test-read-ctf.cc: New ctf reading regression test.
* tests/test-read-common.cc: New library to be used with
test-read-{ctf,dwarf}.cc.
* tests/test-read-common.h: Likewise.
* tests/test-annotate.cc (in_out_specs): Adjust path for input files.
* tests/Makefile.am: Build new tests/test-read-ctf.cc file.
* tests/data/Makefile.am: Add test inputs and expected files.
Add libtestreadcommon.a test library and use it for test-read-{ctf,dwarf}.
* tests/test-read-dwarf.cc: Adapt test to use libtestreadcommon.a in
test-read-common.{cc,h}.
* tests/data/test-annotate/test3.so.abi: Adjust ELF input path file
location to ./tests/data/test-read-common.
* tests/data/test-annotate/test4.so.abi: Likewise.
* tests/data/test-read-common/PR26261: Move test harness to
test-read-common directory.
* tests/data/test-read-common/PR27700: Likewise.
* tests/data/test-read-common/test-PR26568-*: Likewise.
* tests/data/test-read-common/test3.{c,so}: Likewise.
* tests/data/test-read-common/test4.{c,so}: Likewise.
* tests/data/test-read-common/crti*: Helper object to export
_init and _fini sysmbols.
* tests/data/test-read-ctf/test-ambiguous-struct-A.c: New testcase.
* tests/data/test-read-ctf/test-ambiguous-struct-B.c: Likewise.
* tests/data/test-read-ctf/test-conflicting-type-syms-a.c: Likewise.
* tests/data/test-read-ctf/test-conflicting-type-syms-b.c: Likewise.
* tests/data/test-read-ctf/test-enum.c: Likewise.
* tests/data/test-read-ctf/test-enum-many.c: Likewise.
* tests/data/test-read-ctf/test-enum-symbol.c: Likewise.
* tests/data/test-read-ctf/test-struct-iteration.c: Likewise.
* tests/data/test-read-ctf/test-dynamic-array.c: Likewise.
* tests/data/test-read-ctf/test0.c: Likewise.
* tests/data/test-read-ctf/test1.c: Likewise.
* tests/data/test-read-ctf/test2.c: Likewise.
* tests/data/test-read-ctf/test5.c: Likewise.
* tests/data/test-read-ctf/test7.{c,h}: Likewise.
* tests/data/test-read-ctf/test8.c: Likewise.
* tests/data/test-read-ctf/test9.c: Likewise.
* tests/data/test-read-ctf/test-ambiguous-struct-A.o.hash.abi: Testcase
expected result.
* tests/data/test-read-ctf/PR26261/PR26261-exe.abi: Likewise.
* tests/data/test-read-ctf/PR27700/test-PR27700.abi: Likewise.
* tests/data/test-read-ctf/test-ambiguous-struct-A.o.hash.abi: Likewise.
* tests/data/test-read-ctf/test-ambiguous-struct-B.o.hash.abi: Likewise.
* tests/data/test-read-ctf/test-conflicting-type-syms-a.o.hash.abi: Likewise.
* tests/data/test-read-ctf/test-conflicting-type-syms-b.o.hash.abi: Likewise.
* tests/data/test-read-ctf/test-enum.o.abi: Likewise.
* tests/data/test-read-ctf/test-enum-many.o.hash.abi: Likewise.
* tests/data/test-read-ctf/test-enum-symbol.o.hash.abi: Likewise.
* tests/data/test-read-ctf/test-struct-iteration.o.abi: Likewise.
* tests/data/test-read-ctf/test-dynamic-array.o.abi: Likewise.
* tests/data/test-read-ctf/test0: Likewise.
* tests/data/test-read-ctf/test0*.abi: Likewise.
* tests/data/test-read-ctf/test1.so: Likewise.
* tests/data/test-read-ctf/test1*.abi: Likewise.
* tests/data/test-read-ctf/test2.so: Likewise.
* tests/data/test-read-ctf/test2*.abi: Likewise.
* tests/data/test-read-ctf/test3.so.abi: Likewise.
* tests/data/test-read-ctf/test4*.abi: Likewise.
* tests/data/test-read-ctf/test5.o.abi: Likewise.
* tests/data/test-read-ctf/test7.o.abi: Likewise.
* tests/data/test-read-ctf/test8.o.abi: Likewise.
* tests/data/test-read-ctf/test9.o.abi: Likewise.
* tests/data/test-read-dwarf/PR26261/PR26261-exe.abi: Update
expected abixml file.
* tests/data/test-read-dwarf/PR27700/test-PR27700.abi: Likewise.
* tests/data/test-read-dwarf/test-PR26568-1.*.abi: Likewise.
* tests/data/test-read-dwarf/test3*.abi: Likewise.
* tests/data/test-read-dwarf/test4*.abi: Likewise.
* doc/api/libabigail.doxy: Add tests/test-read-common.{cc,h} to
doxygen.
Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2021-12-14 06:25:15 +00:00
|
|
|
if (system(cmd.c_str()))
|
|
|
|
{
|
2024-03-26 15:20:18 +00:00
|
|
|
error_message = string("self comparison with abidw failed:\n")
|
2022-03-31 13:03:38 +00:00
|
|
|
+ "command was: '" + cmd + "'\n";
|
2024-03-26 15:20:18 +00:00
|
|
|
std::cerr << error_message;
|
Add regression tests for ctf reading
This patch implements some regression tests for ctf reading.
Since the code shares a lot of functionalities already used
in the readi-dwarf test, a library was built and test common
harness were moved to a common location. So input files for
test-read-{dwarf,ctf}.cc now are located in:
tests/data/test-read-common directory, ABIs description are
stored in the same location but in a separate file, one for
each binary debugging information: (e.g, test4-ctf.so.abi
and test4-dwarf.so.abi)
* tests/test-read-ctf.cc: New ctf reading regression test.
* tests/test-read-common.cc: New library to be used with
test-read-{ctf,dwarf}.cc.
* tests/test-read-common.h: Likewise.
* tests/test-annotate.cc (in_out_specs): Adjust path for input files.
* tests/Makefile.am: Build new tests/test-read-ctf.cc file.
* tests/data/Makefile.am: Add test inputs and expected files.
Add libtestreadcommon.a test library and use it for test-read-{ctf,dwarf}.
* tests/test-read-dwarf.cc: Adapt test to use libtestreadcommon.a in
test-read-common.{cc,h}.
* tests/data/test-annotate/test3.so.abi: Adjust ELF input path file
location to ./tests/data/test-read-common.
* tests/data/test-annotate/test4.so.abi: Likewise.
* tests/data/test-read-common/PR26261: Move test harness to
test-read-common directory.
* tests/data/test-read-common/PR27700: Likewise.
* tests/data/test-read-common/test-PR26568-*: Likewise.
* tests/data/test-read-common/test3.{c,so}: Likewise.
* tests/data/test-read-common/test4.{c,so}: Likewise.
* tests/data/test-read-common/crti*: Helper object to export
_init and _fini sysmbols.
* tests/data/test-read-ctf/test-ambiguous-struct-A.c: New testcase.
* tests/data/test-read-ctf/test-ambiguous-struct-B.c: Likewise.
* tests/data/test-read-ctf/test-conflicting-type-syms-a.c: Likewise.
* tests/data/test-read-ctf/test-conflicting-type-syms-b.c: Likewise.
* tests/data/test-read-ctf/test-enum.c: Likewise.
* tests/data/test-read-ctf/test-enum-many.c: Likewise.
* tests/data/test-read-ctf/test-enum-symbol.c: Likewise.
* tests/data/test-read-ctf/test-struct-iteration.c: Likewise.
* tests/data/test-read-ctf/test-dynamic-array.c: Likewise.
* tests/data/test-read-ctf/test0.c: Likewise.
* tests/data/test-read-ctf/test1.c: Likewise.
* tests/data/test-read-ctf/test2.c: Likewise.
* tests/data/test-read-ctf/test5.c: Likewise.
* tests/data/test-read-ctf/test7.{c,h}: Likewise.
* tests/data/test-read-ctf/test8.c: Likewise.
* tests/data/test-read-ctf/test9.c: Likewise.
* tests/data/test-read-ctf/test-ambiguous-struct-A.o.hash.abi: Testcase
expected result.
* tests/data/test-read-ctf/PR26261/PR26261-exe.abi: Likewise.
* tests/data/test-read-ctf/PR27700/test-PR27700.abi: Likewise.
* tests/data/test-read-ctf/test-ambiguous-struct-A.o.hash.abi: Likewise.
* tests/data/test-read-ctf/test-ambiguous-struct-B.o.hash.abi: Likewise.
* tests/data/test-read-ctf/test-conflicting-type-syms-a.o.hash.abi: Likewise.
* tests/data/test-read-ctf/test-conflicting-type-syms-b.o.hash.abi: Likewise.
* tests/data/test-read-ctf/test-enum.o.abi: Likewise.
* tests/data/test-read-ctf/test-enum-many.o.hash.abi: Likewise.
* tests/data/test-read-ctf/test-enum-symbol.o.hash.abi: Likewise.
* tests/data/test-read-ctf/test-struct-iteration.o.abi: Likewise.
* tests/data/test-read-ctf/test-dynamic-array.o.abi: Likewise.
* tests/data/test-read-ctf/test0: Likewise.
* tests/data/test-read-ctf/test0*.abi: Likewise.
* tests/data/test-read-ctf/test1.so: Likewise.
* tests/data/test-read-ctf/test1*.abi: Likewise.
* tests/data/test-read-ctf/test2.so: Likewise.
* tests/data/test-read-ctf/test2*.abi: Likewise.
* tests/data/test-read-ctf/test3.so.abi: Likewise.
* tests/data/test-read-ctf/test4*.abi: Likewise.
* tests/data/test-read-ctf/test5.o.abi: Likewise.
* tests/data/test-read-ctf/test7.o.abi: Likewise.
* tests/data/test-read-ctf/test8.o.abi: Likewise.
* tests/data/test-read-ctf/test9.o.abi: Likewise.
* tests/data/test-read-dwarf/PR26261/PR26261-exe.abi: Update
expected abixml file.
* tests/data/test-read-dwarf/PR27700/test-PR27700.abi: Likewise.
* tests/data/test-read-dwarf/test-PR26568-1.*.abi: Likewise.
* tests/data/test-read-dwarf/test3*.abi: Likewise.
* tests/data/test-read-dwarf/test4*.abi: Likewise.
* doc/api/libabigail.doxy: Add tests/test-read-common.{cc,h} to
doxygen.
Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2021-12-14 06:25:15 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Spawn external `diff` command.
|
|
|
|
///
|
|
|
|
/// The files to be compared are: abixml generated by the input
|
|
|
|
/// object file and the expected abixml file stored in `in_abi_path`.
|
|
|
|
///
|
|
|
|
/// @return true if `diff` command didn't find defences. Otherwise
|
|
|
|
/// `error_message` shows the full path of the input file object and
|
|
|
|
/// the full output path for the abixml file.
|
|
|
|
bool
|
|
|
|
test_task::run_diff()
|
|
|
|
{
|
|
|
|
set_in_abi_path();
|
|
|
|
string cmd = "diff -u " + in_abi_path + " " + out_abi_path;
|
|
|
|
if (system(cmd.c_str()))
|
|
|
|
{
|
2022-03-31 13:03:38 +00:00
|
|
|
error_message = string("ABI files differ:\n")
|
Add regression tests for ctf reading
This patch implements some regression tests for ctf reading.
Since the code shares a lot of functionalities already used
in the readi-dwarf test, a library was built and test common
harness were moved to a common location. So input files for
test-read-{dwarf,ctf}.cc now are located in:
tests/data/test-read-common directory, ABIs description are
stored in the same location but in a separate file, one for
each binary debugging information: (e.g, test4-ctf.so.abi
and test4-dwarf.so.abi)
* tests/test-read-ctf.cc: New ctf reading regression test.
* tests/test-read-common.cc: New library to be used with
test-read-{ctf,dwarf}.cc.
* tests/test-read-common.h: Likewise.
* tests/test-annotate.cc (in_out_specs): Adjust path for input files.
* tests/Makefile.am: Build new tests/test-read-ctf.cc file.
* tests/data/Makefile.am: Add test inputs and expected files.
Add libtestreadcommon.a test library and use it for test-read-{ctf,dwarf}.
* tests/test-read-dwarf.cc: Adapt test to use libtestreadcommon.a in
test-read-common.{cc,h}.
* tests/data/test-annotate/test3.so.abi: Adjust ELF input path file
location to ./tests/data/test-read-common.
* tests/data/test-annotate/test4.so.abi: Likewise.
* tests/data/test-read-common/PR26261: Move test harness to
test-read-common directory.
* tests/data/test-read-common/PR27700: Likewise.
* tests/data/test-read-common/test-PR26568-*: Likewise.
* tests/data/test-read-common/test3.{c,so}: Likewise.
* tests/data/test-read-common/test4.{c,so}: Likewise.
* tests/data/test-read-common/crti*: Helper object to export
_init and _fini sysmbols.
* tests/data/test-read-ctf/test-ambiguous-struct-A.c: New testcase.
* tests/data/test-read-ctf/test-ambiguous-struct-B.c: Likewise.
* tests/data/test-read-ctf/test-conflicting-type-syms-a.c: Likewise.
* tests/data/test-read-ctf/test-conflicting-type-syms-b.c: Likewise.
* tests/data/test-read-ctf/test-enum.c: Likewise.
* tests/data/test-read-ctf/test-enum-many.c: Likewise.
* tests/data/test-read-ctf/test-enum-symbol.c: Likewise.
* tests/data/test-read-ctf/test-struct-iteration.c: Likewise.
* tests/data/test-read-ctf/test-dynamic-array.c: Likewise.
* tests/data/test-read-ctf/test0.c: Likewise.
* tests/data/test-read-ctf/test1.c: Likewise.
* tests/data/test-read-ctf/test2.c: Likewise.
* tests/data/test-read-ctf/test5.c: Likewise.
* tests/data/test-read-ctf/test7.{c,h}: Likewise.
* tests/data/test-read-ctf/test8.c: Likewise.
* tests/data/test-read-ctf/test9.c: Likewise.
* tests/data/test-read-ctf/test-ambiguous-struct-A.o.hash.abi: Testcase
expected result.
* tests/data/test-read-ctf/PR26261/PR26261-exe.abi: Likewise.
* tests/data/test-read-ctf/PR27700/test-PR27700.abi: Likewise.
* tests/data/test-read-ctf/test-ambiguous-struct-A.o.hash.abi: Likewise.
* tests/data/test-read-ctf/test-ambiguous-struct-B.o.hash.abi: Likewise.
* tests/data/test-read-ctf/test-conflicting-type-syms-a.o.hash.abi: Likewise.
* tests/data/test-read-ctf/test-conflicting-type-syms-b.o.hash.abi: Likewise.
* tests/data/test-read-ctf/test-enum.o.abi: Likewise.
* tests/data/test-read-ctf/test-enum-many.o.hash.abi: Likewise.
* tests/data/test-read-ctf/test-enum-symbol.o.hash.abi: Likewise.
* tests/data/test-read-ctf/test-struct-iteration.o.abi: Likewise.
* tests/data/test-read-ctf/test-dynamic-array.o.abi: Likewise.
* tests/data/test-read-ctf/test0: Likewise.
* tests/data/test-read-ctf/test0*.abi: Likewise.
* tests/data/test-read-ctf/test1.so: Likewise.
* tests/data/test-read-ctf/test1*.abi: Likewise.
* tests/data/test-read-ctf/test2.so: Likewise.
* tests/data/test-read-ctf/test2*.abi: Likewise.
* tests/data/test-read-ctf/test3.so.abi: Likewise.
* tests/data/test-read-ctf/test4*.abi: Likewise.
* tests/data/test-read-ctf/test5.o.abi: Likewise.
* tests/data/test-read-ctf/test7.o.abi: Likewise.
* tests/data/test-read-ctf/test8.o.abi: Likewise.
* tests/data/test-read-ctf/test9.o.abi: Likewise.
* tests/data/test-read-dwarf/PR26261/PR26261-exe.abi: Update
expected abixml file.
* tests/data/test-read-dwarf/PR27700/test-PR27700.abi: Likewise.
* tests/data/test-read-dwarf/test-PR26568-1.*.abi: Likewise.
* tests/data/test-read-dwarf/test3*.abi: Likewise.
* tests/data/test-read-dwarf/test4*.abi: Likewise.
* doc/api/libabigail.doxy: Add tests/test-read-common.{cc,h} to
doxygen.
Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2021-12-14 06:25:15 +00:00
|
|
|
+ in_abi_path
|
|
|
|
+ "\nand:\n"
|
|
|
|
+ out_abi_path
|
2022-03-31 13:03:38 +00:00
|
|
|
+ "\n"
|
|
|
|
+ "command was: '" + cmd + "'\n";
|
Add regression tests for ctf reading
This patch implements some regression tests for ctf reading.
Since the code shares a lot of functionalities already used
in the readi-dwarf test, a library was built and test common
harness were moved to a common location. So input files for
test-read-{dwarf,ctf}.cc now are located in:
tests/data/test-read-common directory, ABIs description are
stored in the same location but in a separate file, one for
each binary debugging information: (e.g, test4-ctf.so.abi
and test4-dwarf.so.abi)
* tests/test-read-ctf.cc: New ctf reading regression test.
* tests/test-read-common.cc: New library to be used with
test-read-{ctf,dwarf}.cc.
* tests/test-read-common.h: Likewise.
* tests/test-annotate.cc (in_out_specs): Adjust path for input files.
* tests/Makefile.am: Build new tests/test-read-ctf.cc file.
* tests/data/Makefile.am: Add test inputs and expected files.
Add libtestreadcommon.a test library and use it for test-read-{ctf,dwarf}.
* tests/test-read-dwarf.cc: Adapt test to use libtestreadcommon.a in
test-read-common.{cc,h}.
* tests/data/test-annotate/test3.so.abi: Adjust ELF input path file
location to ./tests/data/test-read-common.
* tests/data/test-annotate/test4.so.abi: Likewise.
* tests/data/test-read-common/PR26261: Move test harness to
test-read-common directory.
* tests/data/test-read-common/PR27700: Likewise.
* tests/data/test-read-common/test-PR26568-*: Likewise.
* tests/data/test-read-common/test3.{c,so}: Likewise.
* tests/data/test-read-common/test4.{c,so}: Likewise.
* tests/data/test-read-common/crti*: Helper object to export
_init and _fini sysmbols.
* tests/data/test-read-ctf/test-ambiguous-struct-A.c: New testcase.
* tests/data/test-read-ctf/test-ambiguous-struct-B.c: Likewise.
* tests/data/test-read-ctf/test-conflicting-type-syms-a.c: Likewise.
* tests/data/test-read-ctf/test-conflicting-type-syms-b.c: Likewise.
* tests/data/test-read-ctf/test-enum.c: Likewise.
* tests/data/test-read-ctf/test-enum-many.c: Likewise.
* tests/data/test-read-ctf/test-enum-symbol.c: Likewise.
* tests/data/test-read-ctf/test-struct-iteration.c: Likewise.
* tests/data/test-read-ctf/test-dynamic-array.c: Likewise.
* tests/data/test-read-ctf/test0.c: Likewise.
* tests/data/test-read-ctf/test1.c: Likewise.
* tests/data/test-read-ctf/test2.c: Likewise.
* tests/data/test-read-ctf/test5.c: Likewise.
* tests/data/test-read-ctf/test7.{c,h}: Likewise.
* tests/data/test-read-ctf/test8.c: Likewise.
* tests/data/test-read-ctf/test9.c: Likewise.
* tests/data/test-read-ctf/test-ambiguous-struct-A.o.hash.abi: Testcase
expected result.
* tests/data/test-read-ctf/PR26261/PR26261-exe.abi: Likewise.
* tests/data/test-read-ctf/PR27700/test-PR27700.abi: Likewise.
* tests/data/test-read-ctf/test-ambiguous-struct-A.o.hash.abi: Likewise.
* tests/data/test-read-ctf/test-ambiguous-struct-B.o.hash.abi: Likewise.
* tests/data/test-read-ctf/test-conflicting-type-syms-a.o.hash.abi: Likewise.
* tests/data/test-read-ctf/test-conflicting-type-syms-b.o.hash.abi: Likewise.
* tests/data/test-read-ctf/test-enum.o.abi: Likewise.
* tests/data/test-read-ctf/test-enum-many.o.hash.abi: Likewise.
* tests/data/test-read-ctf/test-enum-symbol.o.hash.abi: Likewise.
* tests/data/test-read-ctf/test-struct-iteration.o.abi: Likewise.
* tests/data/test-read-ctf/test-dynamic-array.o.abi: Likewise.
* tests/data/test-read-ctf/test0: Likewise.
* tests/data/test-read-ctf/test0*.abi: Likewise.
* tests/data/test-read-ctf/test1.so: Likewise.
* tests/data/test-read-ctf/test1*.abi: Likewise.
* tests/data/test-read-ctf/test2.so: Likewise.
* tests/data/test-read-ctf/test2*.abi: Likewise.
* tests/data/test-read-ctf/test3.so.abi: Likewise.
* tests/data/test-read-ctf/test4*.abi: Likewise.
* tests/data/test-read-ctf/test5.o.abi: Likewise.
* tests/data/test-read-ctf/test7.o.abi: Likewise.
* tests/data/test-read-ctf/test8.o.abi: Likewise.
* tests/data/test-read-ctf/test9.o.abi: Likewise.
* tests/data/test-read-dwarf/PR26261/PR26261-exe.abi: Update
expected abixml file.
* tests/data/test-read-dwarf/PR27700/test-PR27700.abi: Likewise.
* tests/data/test-read-dwarf/test-PR26568-1.*.abi: Likewise.
* tests/data/test-read-dwarf/test3*.abi: Likewise.
* tests/data/test-read-dwarf/test4*.abi: Likewise.
* doc/api/libabigail.doxy: Add tests/test-read-common.{cc,h} to
doxygen.
Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2021-12-14 06:25:15 +00:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Write the usage message to @p out stream object.
|
|
|
|
///
|
|
|
|
/// @param prog_name the program name.
|
|
|
|
///
|
|
|
|
/// @param out the stream object to which want to write.
|
|
|
|
void
|
|
|
|
display_usage(const string& prog_name, ostream& out)
|
|
|
|
{
|
|
|
|
emit_prefix(prog_name, out)
|
|
|
|
<< "usage: " << prog_name << " [options]\n"
|
|
|
|
<< " where options can be: \n"
|
|
|
|
<< " --help|-h display this message\n"
|
|
|
|
<< " --no-parallel execute testsuite is a sigle thread\n"
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Parse and process test options.
|
|
|
|
///
|
|
|
|
/// @param argc the arguments number.
|
|
|
|
///
|
|
|
|
/// @param argv the pointer to the arguments.
|
|
|
|
///
|
|
|
|
/// @param opts the valid @ref options to be processed/parsed.
|
|
|
|
///
|
|
|
|
/// @return true if options was processed/parsed successfully. It returns
|
|
|
|
/// false when help is requested or an invalid option is supplied.
|
|
|
|
bool
|
|
|
|
parse_command_line(int argc, char* argv[], options& opts)
|
|
|
|
{
|
|
|
|
for (int i = 1; i < argc; ++i)
|
|
|
|
{
|
|
|
|
if (!strcmp(argv[i], "--no-parallel"))
|
|
|
|
opts.parallel = false;
|
|
|
|
else if (!strcmp(argv[i], "--help")
|
|
|
|
|| !strcmp(argv[i], "--h"))
|
|
|
|
return false;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (strlen(argv[i]) >= 2 && argv[i][0] == '-' && argv[i][1] == '-')
|
|
|
|
opts.wrong_option = argv[i];
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// The main entry point to execute the testsuite.
|
|
|
|
///
|
|
|
|
/// @param num_tests the number of tests to be executed.
|
|
|
|
///
|
|
|
|
/// @param specs the @ref abigail::tests::read_common::InOutSpec
|
|
|
|
/// tests container.
|
|
|
|
///
|
|
|
|
/// @param opts the test execution @ref abigail::tests::read_common::options.
|
|
|
|
///
|
|
|
|
/// @param new_test the @ref create_new_test callback function to create
|
|
|
|
/// a new test task object.
|
|
|
|
///
|
|
|
|
/// @return true if `all` tests were performed successfully. Otherwise
|
|
|
|
/// false is returned.
|
|
|
|
bool
|
|
|
|
run_tests(const size_t num_tests, const InOutSpec* specs,
|
|
|
|
const options& opts, create_new_test new_test)
|
|
|
|
{
|
|
|
|
size_t num_workers = (opts.parallel
|
|
|
|
? std::min(abigail::workers::get_number_of_threads(),
|
|
|
|
num_tests)
|
|
|
|
: 1);
|
|
|
|
|
|
|
|
// Create a task queue. The max number of worker threads of the
|
|
|
|
// queue is the number of the concurrent threads supported by the
|
|
|
|
// processor of the machine this code runs on. But if
|
|
|
|
// --no-parallel was provided then the number of worker threads
|
|
|
|
// equals 1.
|
|
|
|
abigail::workers::queue task_queue(num_workers);
|
|
|
|
bool is_ok = true;
|
|
|
|
|
|
|
|
string out_abi_base = string(get_build_dir()) + "/tests/";
|
|
|
|
string in_elf_base = string(abigail::tests::get_src_dir()) + "/tests/";
|
|
|
|
string in_abi_base = in_elf_base;
|
|
|
|
|
|
|
|
for (const InOutSpec *s = specs; s->in_elf_path; ++s)
|
|
|
|
{
|
|
|
|
test_task_sptr t(new_test(s, out_abi_base,
|
|
|
|
in_elf_base,
|
|
|
|
in_abi_base));
|
|
|
|
ABG_ASSERT(task_queue.schedule_task(t));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Wait for all worker threads to finish their job, and wind down.
|
|
|
|
task_queue.wait_for_workers_to_complete();
|
|
|
|
|
|
|
|
// Now walk the results and print whatever error messages need to be
|
|
|
|
// printed.
|
|
|
|
|
|
|
|
const vector<abigail::workers::task_sptr>& completed_tasks =
|
|
|
|
task_queue.get_completed_tasks();
|
|
|
|
|
|
|
|
ABG_ASSERT(completed_tasks.size() == num_tests);
|
|
|
|
|
|
|
|
for (vector<abigail::workers::task_sptr>::const_iterator ti =
|
|
|
|
completed_tasks.begin();
|
|
|
|
ti != completed_tasks.end();
|
|
|
|
++ti)
|
|
|
|
{
|
|
|
|
test_task_sptr t = dynamic_pointer_cast<test_task>(*ti);
|
|
|
|
if (!t->is_ok)
|
|
|
|
{
|
|
|
|
is_ok = false;
|
|
|
|
if (!t->error_message.empty())
|
|
|
|
cerr << t->error_message << '\n';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return !is_ok;
|
|
|
|
}
|
|
|
|
|
|
|
|
}//end namespace read_common
|
|
|
|
}//end namespace tests
|
|
|
|
}//end namespace abigail
|