mirror of
git://sourceware.org/git/libabigail.git
synced 2024-12-16 23:14:36 +00:00
6f00afe353
My commit "5a8c000 Bug 19355 - Libabigail slow on r300_dri.so" introduced a faster way of getting the logical parent of a DIE, when one of its ancestor DIEs has been imported into a the current translation unit. But then that commit broke the support for alternate debug info files. Oops. This commit brings back the support for alternate debug info files. * src/abg-dwarf-reader.cc (imported_unit_point::imported_unit_from_alt_di): New data member. (imported_unit_point::imported_unit_point): Adjust. (read_context::alt_tu_die_imported_unit_points_map_): New data member. (read_context::alt_tu_die_imported_unit_points_map): New accessor. (die_die_attribute): Remove the overload which doesn't say if the resulting DIE comes from alternate debug info. (build_die_parent_relations_under): Take a new flag which says if we are building the relations about DIEs in the alternate debug info section or not. Use that flag to know if the imported unit trace we are building is for an alternate debug info file or not. (build_die_parent_maps): Build two different imported unit point trace vectors: one for the main debug info file, and another one for the alternate debug info file. (find_import_unit_point_between_dies): Take a flag that says if the beginning of the search is a DIE in the alternate debug info file or not. Use it to know if we should use the import point trace vectors from alternate debug info or from the main debug info file. When the import point trace vector is empty, return immediatly. (get_parent_die): If the parent DIE is a DW_TAG_partial_unit which hasn't been imported into this TU, then assume the logical parent is the DIE for the current translation unit. * tests/data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-0.txt: Reference test output. * tests/data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64.rpm: New input test rpm. * tests/data/test-diff-pkg/tbb-4.3-3.20141204.fc23.x86_64.rpm: Likewise. * tests/data/test-diff-pkg/tbb-debuginfo-4.1-9.20130314.fc22.x86_64.rpm: Likewise. * tests/data/test-diff-pkg/tbb-debuginfo-4.3-3.20141204.fc23.x86_64.rpm: Likewise. * tests/data/Makefile.am: Add the new test materials to the source distribution. * tests/test-diff-pkg.cc (int_out_specs): Add the new rpms to the list of rpms to test against. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
392 lines
12 KiB
C++
392 lines
12 KiB
C++
// -*- Mode: C++ -*-
|
|
//
|
|
// Copyright (C) 2013-2015 Red Hat, Inc.
|
|
//
|
|
// This file is part of the GNU Application Binary Interface Generic
|
|
// Analysis and Instrumentation Library (libabigail). This library is
|
|
// free software; you can redistribute it and/or modify it under the
|
|
// terms of the GNU Lesser General Public License as published by the
|
|
// Free Software Foundation; either version 3, or (at your option) any
|
|
// later version.
|
|
|
|
// This library is distributed in the hope that it will be useful, but
|
|
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
// General Lesser Public License for more details.
|
|
|
|
// You should have received a copy of the GNU Lesser General Public
|
|
// License along with this program; see the file COPYING-LGPLV3. If
|
|
// not, see <http://www.gnu.org/licenses/>.
|
|
|
|
// Author: Sinny Kumari
|
|
|
|
/// @file
|
|
///
|
|
/// This test harness program fetch ABI diff between ELF binaries present inside
|
|
/// input packages with optional debuginfo packages.
|
|
/// Resulting ABI diff report is compared with reference one.
|
|
///
|
|
/// The set of input files and reference reports to consider should be
|
|
/// present in the source distribution.
|
|
|
|
// For package configuration macros.
|
|
#include "config.h"
|
|
#include <cstring>
|
|
#include <string>
|
|
#include <cstdlib>
|
|
#include <iostream>
|
|
#include "test-utils.h"
|
|
#include "abg-tools-utils.h"
|
|
|
|
using std::string;
|
|
using std::cerr;
|
|
using abigail::tests::get_src_dir;
|
|
|
|
struct InOutSpec
|
|
{
|
|
const char* first_in_package_path;
|
|
const char* second_in_package_path;
|
|
const char* prog_options;
|
|
const char* suppression_path;
|
|
const char* first_in_debug_package_path;
|
|
const char* second_in_debug_package_path;
|
|
const char* ref_report_path;
|
|
const char* out_report_path;
|
|
};// end struct InOutSpec
|
|
|
|
static InOutSpec in_out_specs[] =
|
|
{
|
|
// dir1 contains a suppr spec - it should be ignored.
|
|
{
|
|
"data/test-diff-pkg/dirpkg-0-dir1",
|
|
"data/test-diff-pkg/dirpkg-0-dir2",
|
|
"--no-show-locs",
|
|
"",
|
|
"",
|
|
"",
|
|
"data/test-diff-pkg/dirpkg-0-report-0.txt",
|
|
"output/test-diff-pkg/dirpkg-0-report-0.txt"
|
|
},
|
|
// dir2 contains a suppr spec - it should be recognized.
|
|
{
|
|
"data/test-diff-pkg/dirpkg-1-dir1",
|
|
"data/test-diff-pkg/dirpkg-1-dir2",
|
|
"--no-show-locs",
|
|
"",
|
|
"",
|
|
"",
|
|
"data/test-diff-pkg/dirpkg-1-report-0.txt",
|
|
"output/test-diff-pkg/dirpkg-1-report-0.txt"
|
|
},
|
|
// dir2 contains a suppr spec but --no-abignore is specified,
|
|
// the file should be ignored.
|
|
{
|
|
"data/test-diff-pkg/dirpkg-1-dir1",
|
|
"data/test-diff-pkg/dirpkg-1-dir2",
|
|
"--no-abignore --no-show-locs",
|
|
"",
|
|
"",
|
|
"",
|
|
"data/test-diff-pkg/dirpkg-1-report-1.txt",
|
|
"output/test-diff-pkg/dirpkg-1-report-1.txt"
|
|
},
|
|
// dir2 contains several suppr spec files, ".abignore" and
|
|
// "dir.abignore", so the specs should be merged.
|
|
{
|
|
"data/test-diff-pkg/dirpkg-2-dir1",
|
|
"data/test-diff-pkg/dirpkg-2-dir2",
|
|
"--no-show-locs",
|
|
"",
|
|
"",
|
|
"",
|
|
"data/test-diff-pkg/dirpkg-2-report-0.txt",
|
|
"output/test-diff-pkg/dirpkg-2-report-0.txt"
|
|
},
|
|
// dir2 contains a suppr spec file, ".abignore" and
|
|
// an additional suppr file is specified on the command line,
|
|
// so the specs should be merged.
|
|
{
|
|
"data/test-diff-pkg/dirpkg-3-dir1",
|
|
"data/test-diff-pkg/dirpkg-3-dir2",
|
|
"--no-show-locs",
|
|
"data/test-diff-pkg/dirpkg-3.suppr",
|
|
"",
|
|
"",
|
|
"data/test-diff-pkg/dirpkg-3-report-0.txt",
|
|
"output/test-diff-pkg/dirpkg-3-report-0.txt"
|
|
},
|
|
// dir2 contains a suppr spec file, ".abignore", which should
|
|
// be ignored because of the program options and
|
|
// an additional suppr file is specified on the command line,
|
|
// which should be recognized.
|
|
{
|
|
"data/test-diff-pkg/dirpkg-3-dir1",
|
|
"data/test-diff-pkg/dirpkg-3-dir2",
|
|
"--no-show-locs --no-abignore",
|
|
"data/test-diff-pkg/dirpkg-3.suppr",
|
|
"",
|
|
"",
|
|
"data/test-diff-pkg/dirpkg-3-report-1.txt",
|
|
"output/test-diff-pkg/dirpkg-3-report-1.txt"
|
|
},
|
|
{ // Just like the previous tests, but loc info is emitted.
|
|
"data/test-diff-pkg/dirpkg-3-dir1",
|
|
"data/test-diff-pkg/dirpkg-3-dir2",
|
|
"--no-abignore",
|
|
"data/test-diff-pkg/dirpkg-3.suppr",
|
|
"",
|
|
"",
|
|
"data/test-diff-pkg/dirpkg-3-report-2.txt",
|
|
"output/test-diff-pkg/dirpkg-3-report-2.txt"
|
|
},
|
|
#if WITH_TAR
|
|
{
|
|
"data/test-diff-pkg/tarpkg-0-dir1.tar",
|
|
"data/test-diff-pkg/tarpkg-0-dir2.tar",
|
|
"--no-show-locs",
|
|
"",
|
|
"",
|
|
"",
|
|
"data/test-diff-pkg/tarpkg-0-report-0.txt",
|
|
"output/test-diff-pkg/tarpkg-0-report-0.txt"
|
|
},
|
|
{
|
|
"data/test-diff-pkg/tarpkg-0-dir1.ta",
|
|
"data/test-diff-pkg/tarpkg-0-dir2.ta",
|
|
"--no-show-locs",
|
|
"",
|
|
"",
|
|
"",
|
|
"data/test-diff-pkg/tarpkg-0-report-0.txt",
|
|
"output/test-diff-pkg/tarpkg-0-report-0.txt"
|
|
},
|
|
{
|
|
"data/test-diff-pkg/tarpkg-0-dir1.tar.gz",
|
|
"data/test-diff-pkg/tarpkg-0-dir2.tar.gz",
|
|
"--no-show-locs",
|
|
"",
|
|
"",
|
|
"",
|
|
"data/test-diff-pkg/tarpkg-0-report-0.txt",
|
|
"output/test-diff-pkg/tarpkg-0-report-0.txt"
|
|
},
|
|
{
|
|
"data/test-diff-pkg/tarpkg-0-dir1.tar.bz2",
|
|
"data/test-diff-pkg/tarpkg-0-dir2.tar.bz2",
|
|
"--no-show-locs",
|
|
"",
|
|
"",
|
|
"",
|
|
"data/test-diff-pkg/tarpkg-0-report-0.txt",
|
|
"output/test-diff-pkg/tarpkg-0-report-0.txt"
|
|
},
|
|
#endif //WITH_TAR
|
|
|
|
#ifdef WITH_RPM
|
|
// Two RPM packages with debuginfo available and have ABI changes
|
|
{
|
|
"data/test-diff-pkg/dbus-glib-0.80-3.fc12.x86_64.rpm",
|
|
"data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64.rpm",
|
|
"--no-show-locs",
|
|
"",
|
|
"data/test-diff-pkg/dbus-glib-debuginfo-0.80-3.fc12.x86_64.rpm",
|
|
"data/test-diff-pkg/dbus-glib-debuginfo-0.104-3.fc23.x86_64.rpm",
|
|
"data/test-diff-pkg/test-rpm-report-0.txt",
|
|
"output/test-diff-pkg/test-rpm-report-0.txt"
|
|
},
|
|
// Two RPM packages with 2nd package debuginfo missing
|
|
{
|
|
"data/test-diff-pkg/dbus-glib-0.80-3.fc12.x86_64.rpm",
|
|
"data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64.rpm",
|
|
"--no-show-locs",
|
|
"",
|
|
"data/test-diff-pkg/dbus-glib-debuginfo-0.80-3.fc12.x86_64.rpm",
|
|
"",
|
|
"data/test-diff-pkg/test-rpm-report-1.txt",
|
|
"output/test-diff-pkg/test-rpm-report-1.txt"
|
|
},
|
|
|
|
// Two RPM packages with first package debuginfo missing
|
|
{
|
|
"data/test-diff-pkg/dbus-glib-0.80-3.fc12.x86_64.rpm",
|
|
"data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64.rpm",
|
|
"--no-show-locs",
|
|
"",
|
|
"",
|
|
"data/test-diff-pkg/dbus-glib-debuginfo-0.104-3.fc23.x86_64.rpm",
|
|
"data/test-diff-pkg/test-rpm-report-2.txt",
|
|
"output/test-diff-pkg/test-rpm-report-2.txt"
|
|
},
|
|
|
|
// Two RPM packages with missing debuginfo
|
|
{
|
|
"data/test-diff-pkg/dbus-glib-0.80-3.fc12.x86_64.rpm",
|
|
"data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64.rpm",
|
|
"--no-show-locs",
|
|
"",
|
|
"",
|
|
"",
|
|
"data/test-diff-pkg/test-rpm-report-3.txt",
|
|
"output/test-diff-pkg/test-rpm-report-3.txt"
|
|
},
|
|
|
|
// Two RPM packages with no ABI change
|
|
{
|
|
"data/test-diff-pkg/dbus-glib-0.80-3.fc12.x86_64.rpm",
|
|
"data/test-diff-pkg/dbus-glib-0.80-3.fc12.x86_64.rpm",
|
|
"--no-show-locs",
|
|
"",
|
|
"data/test-diff-pkg/dbus-glib-debuginfo-0.80-3.fc12.x86_64.rpm",
|
|
"data/test-diff-pkg/dbus-glib-debuginfo-0.80-3.fc12.x86_64.rpm",
|
|
"data/test-diff-pkg/test-rpm-report-4.txt",
|
|
"output/test-diff-pkg/test-rpm-report-4.txt"
|
|
},
|
|
// Two RPM packages with debuginfo available and we don't want to
|
|
// see added symbols.
|
|
{
|
|
"data/test-diff-pkg/dbus-glib-0.80-3.fc12.x86_64.rpm",
|
|
"data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64.rpm",
|
|
"--no-show-locs --no-added-syms",
|
|
"",
|
|
"data/test-diff-pkg/dbus-glib-debuginfo-0.80-3.fc12.x86_64.rpm",
|
|
"data/test-diff-pkg/dbus-glib-debuginfo-0.104-3.fc23.x86_64.rpm",
|
|
"data/test-diff-pkg/test-rpm-report-5.txt",
|
|
"output/test-diff-pkg/test-rpm-report-5.txt"
|
|
},
|
|
{
|
|
"data/test-diff-pkg/qemu-img-rhev-2.3.0-7.el7.ppc64.rpm",
|
|
"data/test-diff-pkg/qemu-img-rhev-2.3.0-20.el7.ppc64.rpm",
|
|
"--no-show-locs --no-added-syms",
|
|
"",
|
|
"data/test-diff-pkg/qemu-kvm-rhev-debuginfo-2.3.0-7.el7.ppc64.rpm",
|
|
"data/test-diff-pkg/qemu-kvm-rhev-debuginfo-2.3.0-20.el7.ppc64.rpm",
|
|
"data/test-diff-pkg/qemu-img-rhev-2.3.0-7.el7.ppc64--qemu-img-rhev-2.3.0-20.el7.ppc64-report-0.txt",
|
|
"output/test-diff-pkg/qemu-img-rhev-2.3.0-7.el7.ppc64--qemu-img-rhev-2.3.0-20.el7.ppc64-report-0.txt"
|
|
},
|
|
{"data/test-diff-pkg/empty-pkg-libvirt-0.9.11.3-1.el7.ppc64.rpm",
|
|
"data/test-diff-pkg/empty-pkg-libvirt-1.2.17-13.el7_2.2.ppc64.rpm",
|
|
"",
|
|
"",
|
|
"",
|
|
"",
|
|
"data/test-diff-pkg/empty-pkg-report-0.txt",
|
|
"output/test-diff-pkg/empty-pkg-report-0.txt"
|
|
},
|
|
{
|
|
"data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64.rpm",
|
|
"data/test-diff-pkg/tbb-4.3-3.20141204.fc23.x86_64.rpm",
|
|
"",
|
|
"",
|
|
"data/test-diff-pkg/tbb-debuginfo-4.1-9.20130314.fc22.x86_64.rpm",
|
|
"data/test-diff-pkg/tbb-debuginfo-4.3-3.20141204.fc23.x86_64.rpm",
|
|
"data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-0.txt",
|
|
"output/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-0.txt"
|
|
},
|
|
#endif //WITH_RPM
|
|
|
|
#ifdef WITH_DEB
|
|
// Two debian packages.
|
|
{
|
|
"data/test-diff-pkg/libsigc++-2.0-0c2a_2.4.0-1_amd64.deb",
|
|
"data/test-diff-pkg/libsigc++-2.0-0v5_2.4.1-1ubuntu2_amd64.deb",
|
|
"--no-show-locs --fail-no-dbg",
|
|
"",
|
|
"data/test-diff-pkg/libsigc++-2.0-0c2a-dbgsym_2.4.0-1_amd64.ddeb",
|
|
"data/test-diff-pkg/libsigc++-2.0-0v5-dbgsym_2.4.1-1ubuntu2_amd64.ddeb",
|
|
"data/test-diff-pkg/libsigc++-2.0-0c2a_2.4.0-1_amd64--libsigc++-2.0-0v5_2.4.1-1ubuntu2_amd64-report-0.txt",
|
|
"output/test-diff-pkg/libsigc++-2.0-0c2a_2.4.0-1_amd64--libsigc++-2.0-0v5_2.4.1-1ubuntu2_amd64-report-0.txt"
|
|
},
|
|
#endif // WITH_DEB
|
|
// This should be the last entry.
|
|
{0, 0, 0, 0, 0, 0, 0, 0}
|
|
};
|
|
|
|
int
|
|
main()
|
|
{
|
|
using abigail::tests::get_build_dir;
|
|
using abigail::tools_utils::ensure_parent_dir_created;
|
|
|
|
bool is_ok = true;
|
|
string first_in_package_path, second_in_package_path,
|
|
prog_options,
|
|
ref_abi_diff_report_path, out_abi_diff_report_path, cmd, abipkgdiff,
|
|
first_in_debug_package_path, second_in_debug_package_path,
|
|
suppression_path;
|
|
for (InOutSpec *s = in_out_specs; s->first_in_package_path; ++s)
|
|
{
|
|
first_in_package_path =
|
|
get_src_dir() + "/tests/" + s->first_in_package_path;
|
|
second_in_package_path =
|
|
get_src_dir() + "/tests/" + s->second_in_package_path;
|
|
|
|
prog_options = s->prog_options;
|
|
|
|
if (s->first_in_debug_package_path
|
|
&& strcmp(s->first_in_debug_package_path, ""))
|
|
first_in_debug_package_path =
|
|
get_src_dir() + "/tests/" + s->first_in_debug_package_path;
|
|
else
|
|
first_in_debug_package_path.clear();
|
|
|
|
if (s->second_in_debug_package_path
|
|
&& strcmp(s->second_in_debug_package_path, ""))
|
|
second_in_debug_package_path =
|
|
get_src_dir() + "/tests/" + s->second_in_debug_package_path;
|
|
else
|
|
second_in_debug_package_path.clear();
|
|
|
|
if (s->suppression_path
|
|
&& strcmp(s->suppression_path, ""))
|
|
suppression_path =
|
|
get_src_dir() + "/tests/" + s->suppression_path;
|
|
else
|
|
suppression_path.clear();
|
|
|
|
ref_abi_diff_report_path = get_src_dir() + "/tests/" + s->ref_report_path;
|
|
out_abi_diff_report_path =
|
|
get_build_dir() + "/tests/" + s->out_report_path;
|
|
|
|
if (!ensure_parent_dir_created(out_abi_diff_report_path))
|
|
{
|
|
cerr << "could not create parent directory for "
|
|
<< out_abi_diff_report_path;
|
|
is_ok = false;
|
|
continue;
|
|
}
|
|
|
|
abipkgdiff = get_build_dir() + "/tools/abipkgdiff";
|
|
|
|
if (!prog_options.empty())
|
|
abipkgdiff += " " + prog_options;
|
|
|
|
if (!first_in_debug_package_path.empty())
|
|
abipkgdiff += " --d1 " + first_in_debug_package_path;
|
|
if (!second_in_debug_package_path.empty())
|
|
abipkgdiff += " --d2 " + second_in_debug_package_path;
|
|
|
|
if (!suppression_path.empty())
|
|
abipkgdiff += " --suppressions " + suppression_path;
|
|
|
|
cmd =
|
|
abipkgdiff + " " + first_in_package_path + " " + second_in_package_path;
|
|
cmd += " > " + out_abi_diff_report_path;
|
|
|
|
bool abipkgdiff_ok = true;
|
|
if (system(cmd.c_str()) & 255)
|
|
abipkgdiff_ok = false;
|
|
|
|
if (abipkgdiff_ok)
|
|
{
|
|
cmd = "diff -u " + ref_abi_diff_report_path + " "
|
|
+ out_abi_diff_report_path;
|
|
if (system(cmd.c_str()))
|
|
is_ok = false;
|
|
}
|
|
else
|
|
is_ok = false;
|
|
|
|
}
|
|
return !is_ok;
|
|
}
|