mirror of
git://sourceware.org/git/libabigail.git
synced 2024-12-25 19:22:07 +00:00
1a00cad493
In the libabigail project, almost all the tests for the tools follow a similar pattern. The test contains a set of input files to compare. The result of the comparison is thus compared to a set of reference comparison result. This approach is already documented in the CONTRIBUTING file. There are several interesting properties with this scheme. First, it capture the behaviour of the tools, including what is shown to the user. Second, it eases the job of a hacker who wants to add a new test for a new behaviour of a given tool. The user just has to provide: 1/ A new reference output of the new use case of the tool (that is easily constructed by using the tool itself and saving its output) and add an entry to array of entries that describe what to compare 2/ A new set of inputs to the tool And voila. Unfortunately, fedabipkgdiff tests don't follow this scheme. That make them surprising to hackers who read the source code of the existing tests, at very least. Also, the fedabipkgdiff tests were only unit tests. They were not testing the tool as used by users in general. This patch makes the fedabipkgdiff tests follow the general approach of the tests of the other Libabigail tools. The patch first craetes a program names tests/mockfedabipkgdiff. It's a wrapper around tools/fedabipkgdiff. It overloads the Koji client of fedabipkgdiff with a fake Koji client that gets the Fedora packages locally, from tests/data/test-fedabipkgdiff/packages. In other words, mockfedabipkgdiff is fedabipkgdiff without going to the network. I believe that in the future, tests/mockfedabipkgdiff should be killed when fedabipkgdiff is able to cache a local description of a local partial view of a Koji repository, along with the build packages that were already downloaded. That way, calling fedabipkgdiff twice with the same set of option should make the tool perform correctly without going to the netword on the second invocation. We should be able to save the local partial view of the Koji repository under e.g, tests/data/test-fedabipkgdiff/local-koji and tell fedabipkgdiff to use that, instead of using the network. But we are not there yet. So for now, I am using mockfedabipkgdiff. Then, tests/runtestfedabipkdiff.py.in has been re-written to use tests/mockfedabipkgdiff and to look like what is described in CONTRIBUTING as far as how Libabigail tools' tests are organized: mockfedabipkgdiff is called to perform a comparison. The result of the comparison is then compared (using GNU diff) to a reference comparison result file. Please note that tests/runtestfedabipkdiff.py is relatively fast for the moment. But when it contains much more tests and start becoming slow, then we'll need to change the code to run several comparisons in parallel, just like we do today in tests/test-diff-filter.cc. At that point, I believe I'll just re-write this in C++, just like tests/test-diff-filter.cc because that will allow us to have true concurrent code based on the abigail:workers API. For now, I am keeping this in Python also because I think that keeps Chenxiong happy ;-) To be sure that fedabipkgdiff (and its underlying abipkgdiff) are really comparing all the packages they are supposed to compare and also all the binaries in those packages, I have added a new --show-identical-binaries to abipkgdiff and fedabipkgdiff. That option shows the name of the binaries (and packages) that are compared, *even if* the ABI of those binaries are identical. Because otherwise, today, if two binaries (or packages) have the same ABI, nothing is displayed. For instance, here is the result of comparing a package against itself, using this new --show-identical-binaries options: dodji@adjoa:patches$ ./tools/fedabipkgdiff --abipkgdiff ./build/tools/abipkgdiff --show-identical-binaries dbus-glib-0.80-3.fc12.x86_64.rpm dbus-glib-0.80-3.fc12.x86_64.rpm Comparing the ABI of binaries between dbus-glib-0.80-3.fc12.x86_64.rpm and dbus-glib-0.80-3.fc12.x86_64.rpm: ================ changes of 'dbus-binding-tool'=============== No ABI change detected ================ end of changes of 'dbus-binding-tool'=============== ================ changes of 'libdbus-glib-1.so.2.1.0'=============== No ABI change detected ================ end of changes of 'libdbus-glib-1.so.2.1.0'=============== dodji@adjoa:patches$ And here is what this command before that patch would do: dodji@adjoa:patches$ ./tools/fedabipkgdiff --abipkgdiff ../master/build/tools/abipkgdiff dbus-glib-0.80-3.fc12.x86_64.rpm dbus-glib-0.80-3.fc12.x86_64.rpm Comparing the ABI of binaries between dbus-glib-0.80-3.fc12.x86_64.rpm and dbus-glib-0.80-3.fc12.x86_64.rpm: dodji@adjoa:patches$ The rest of the patch is mostly new test inputs material and the necessary adjustments following all the changes above. * configure.ac: Do not require Python dependencies itertools, unittest and StringIO anymore as they are not used anymore. Require new module tempfile now. Generate new executable script tests/mockfedabipkgdiff from tests/mockfedabipkgdiff.in. * doc/manuals/abipkgdiff.rst: Add doc for new option --show-identical-binaries to abipkgdiff * doc/manuals/fedabipkgdiff.rst: Add doc for new options --show-identical-binaries to fedabipkgdiff. * tools/abipkgdiff.cc (options::show_identical_binaries): New data member. (options::options): Initialize new data member. (display_usage): Add a new help string for the new --show-identical-binaries option. (parse_command_line): Parse the newq --show-identical-binaries command line switch. (pthread_routine_compare): When the comparison of two binaries is empty, if --show-identical-binaries was provided, then emit some output saying the comparison did yield the empty set. * tools/fedabipkgdiff (DEFAULT_ABIPKGDIFF): Store the default path to abipkgdiff in this new global variable. Naming this default path is useful because it can then be cleanly overloaded when using mock.patch. (build_path_to_abipkgdiff): Return the new DEFAULT_ABIPKGDIFF global variable. (cmd): Parse the new --show-identical-binaries command line switch. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: New reference output. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/mockfedabipkgdiff.in: New uninstalled script template. * tests/runtestfedabipkgdiff.py.in (counter) (temp_file_or_dir_prefix, UtilsTest, RPMTest, LocalRPMTest) (RunAbipkgdiffTest, GetPackageLatestBuildTest, DownloadRPMTest) (BrewListRPMsTest, AssertionHelper, MockGlobalConfig) (BUILT_ABIPKGDIFF, CompareABIFromCommandLineTest): Remove these classes, global variables and functions. (FEDABIPKGDIFF, TEST_SRC_DIR, TEST_BUILD_DIR, INPUT_DIR) (OUTPUT_DIR, FEDABIPKGDIFF_TEST_SPECS): New global variables. (ensure_output_dir_created, run_fedabipkgdiff_tests, main): New functions. * tests/test-diff-pkg.cc (in_out_specs): Add tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt to the set of reference outputs to consider. * tests/Makefile.am: Add non-installed script mockfedabipkgdiff to source distribution. Also added tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt, tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt, tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt, tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt and tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt to source distribution. Signed-off-by: Chenxiong Qi <cqi@redhat.com> Signed-off-by: Dodji Seketeli <dodji@redhat.com>
608 lines
19 KiB
C++
608 lines
19 KiB
C++
// -*- Mode: C++ -*-
|
|
//
|
|
// Copyright (C) 2013-2016 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 computes the ABI changes between ELF
|
|
/// binaries present inside input packages. Some of the input
|
|
/// packages have debuginfo, some don't. The resulting ABI change
|
|
/// report is then compared with a reference one.
|
|
///
|
|
/// The set of input files and reference reports to consider should be
|
|
/// present in the source distribution, which means they must be
|
|
/// referenced in tests/data/Makefile.am by the EXTRA_DIST variable.
|
|
|
|
// For package configuration macros.
|
|
#include "config.h"
|
|
#include <sys/wait.h>
|
|
#include <cassert>
|
|
#include <cstring>
|
|
#include <string>
|
|
#include <cstdlib>
|
|
#include <iostream>
|
|
#include "abg-workers.h"
|
|
#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* first_in_devel_package_path;
|
|
const char* second_in_devel_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-default-suppression --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-default-suppression --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-default-suppression --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-default-suppression --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-default-suppression --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-default-suppression --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-default-suppression --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"
|
|
},
|
|
{
|
|
"data/test-diff-pkg/symlink-dir-test1/dir1/symlinks",
|
|
"data/test-diff-pkg/symlink-dir-test1/dir2/symlinks",
|
|
"--no-default-suppression ",
|
|
"",
|
|
"",
|
|
"",
|
|
"",
|
|
"",
|
|
"data/test-diff-pkg/symlink-dir-test1-report0.txt ",
|
|
"output/test-diff-pkg/symlink-dir-test1-report0.txt "
|
|
},
|
|
#if WITH_TAR
|
|
{
|
|
"data/test-diff-pkg/tarpkg-0-dir1.tar",
|
|
"data/test-diff-pkg/tarpkg-0-dir2.tar",
|
|
"--no-default-suppression --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-default-suppression --no-show-locs",
|
|
"",
|
|
"",
|
|
"",
|
|
"",
|
|
"",
|
|
"data/test-diff-pkg/tarpkg-0-report-0.txt",
|
|
"output/test-diff-pkg/tarpkg-0-report-01.txt"
|
|
},
|
|
{
|
|
"data/test-diff-pkg/tarpkg-0-dir1.tar.gz",
|
|
"data/test-diff-pkg/tarpkg-0-dir2.tar.gz",
|
|
"--no-default-suppression --no-show-locs",
|
|
"",
|
|
"",
|
|
"",
|
|
"",
|
|
"",
|
|
"data/test-diff-pkg/tarpkg-0-report-0.txt",
|
|
"output/test-diff-pkg/tarpkg-0-report-02.txt"
|
|
},
|
|
{
|
|
"data/test-diff-pkg/tarpkg-0-dir1.tar.bz2",
|
|
"data/test-diff-pkg/tarpkg-0-dir2.tar.bz2",
|
|
"--no-default-suppression --no-show-locs",
|
|
"",
|
|
"",
|
|
"",
|
|
"",
|
|
"",
|
|
"data/test-diff-pkg/tarpkg-0-report-0.txt",
|
|
"output/test-diff-pkg/tarpkg-0-report-03.txt"
|
|
},
|
|
{
|
|
"data/test-diff-pkg/tarpkg-1-dir1.tar.gz",
|
|
"data/test-diff-pkg/tarpkg-1-dir2.tar.gz",
|
|
"--no-default-suppression --dso-only",
|
|
"",
|
|
"",
|
|
"",
|
|
"",
|
|
"",
|
|
"data/test-diff-pkg/tarpkg-1-report-0.txt",
|
|
"output/test-diff-pkg/tarpkg-1-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-default-suppression --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-default-suppression --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-default-suppression --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-default-suppression --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-default-suppression --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-default-suppression --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-default-suppression --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",
|
|
"--no-default-suppression",
|
|
"",
|
|
"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"
|
|
},
|
|
{
|
|
"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",
|
|
"--no-default-suppression",
|
|
"",
|
|
"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-devel-4.1-9.20130314.fc22.x86_64.rpm",
|
|
"data/test-diff-pkg/tbb-devel-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-1.txt",
|
|
"output/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-1.txt"
|
|
},
|
|
{
|
|
"data/test-diff-pkg/libICE-1.0.6-1.el6.x86_64.rpm",
|
|
"data/test-diff-pkg/libICE-1.0.9-2.el7.x86_64.rpm",
|
|
"--no-default-suppression",
|
|
"",
|
|
"data/test-diff-pkg/libICE-debuginfo-1.0.6-1.el6.x86_64.rpm",
|
|
"data/test-diff-pkg/libICE-debuginfo-1.0.9-2.el7.x86_64.rpm",
|
|
"",
|
|
"",
|
|
"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",
|
|
"output/test-diff-pkg/libICE-1.0.6-1.el6.x86_64.rpm--libICE-1.0.9-2.el7.x86_64.rpm-report-0.txt"
|
|
},
|
|
{
|
|
"data/test-diff-pkg/gtk2-immodule-xim-2.24.22-5.el7.i686.rpm",
|
|
"data/test-diff-pkg/gtk2-immodule-xim-2.24.28-8.el7.i686.rpm",
|
|
"--no-default-suppression",
|
|
"",
|
|
"data/test-diff-pkg/gtk2-debuginfo-2.24.22-5.el7.i686.rpm",
|
|
"data/test-diff-pkg/gtk2-debuginfo-2.24.28-8.el7.i686.rpm",
|
|
"",
|
|
"",
|
|
"data/test-diff-pkg/gtk2-immodule-xim-2.24.22-5.el7.i686--gtk2-immodule-xim-2.24.28-8.el7.i686-report-0.txt",
|
|
"output/test-diff-pkg/gtk2-immodule-xim-2.24.22-5.el7.i686--gtk2-immodule-xim-2.24.28-8.el7.i686-report-0.txt"
|
|
},
|
|
{
|
|
"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-default-suppression --show-identical-binaries",
|
|
"",
|
|
"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-dbus-glib-0.80-3.fc12.x86_64-report-0.txt",
|
|
"output/test-diff-pkg/test-dbus-glib-0.80-3.fc12.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-default-suppression --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, 0, 0}
|
|
};
|
|
|
|
/// A task which launches abipkgdiff on the binaries passed to the
|
|
/// constructor of the task. The test also launches gnu diff on the
|
|
/// result of abipkdiff to compare it against a reference abipkgdiff
|
|
/// result.
|
|
struct test_task : public abigail::workers::task
|
|
{
|
|
InOutSpec spec;
|
|
bool is_ok;
|
|
string diff_cmd;
|
|
string error_message;
|
|
|
|
test_task(const InOutSpec& s)
|
|
: spec(s),
|
|
is_ok(true)
|
|
{}
|
|
|
|
/// This virtual function overload actually performs the job of the
|
|
/// task.
|
|
///
|
|
/// It actually launches abipkgdiff on the binaries passed to the
|
|
/// constructor of the task. It also launches gnu diff on the
|
|
/// result of the abidiff to compare it against a reference abidiff
|
|
/// result.
|
|
virtual void
|
|
perform()
|
|
{
|
|
using abigail::tests::get_build_dir;
|
|
using abigail::tools_utils::ensure_parent_dir_created;
|
|
|
|
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,
|
|
first_in_devel_package_path, second_in_devel_package_path,
|
|
suppression_path;
|
|
|
|
first_in_package_path =
|
|
string(get_src_dir()) + "/tests/" + spec.first_in_package_path;
|
|
second_in_package_path =
|
|
string(get_src_dir()) + "/tests/" + spec.second_in_package_path;
|
|
|
|
prog_options = spec.prog_options;
|
|
|
|
if (spec.first_in_debug_package_path
|
|
&& strcmp(spec.first_in_debug_package_path, ""))
|
|
first_in_debug_package_path =
|
|
string(get_src_dir()) + "/tests/" + spec.first_in_debug_package_path;
|
|
else
|
|
first_in_debug_package_path.clear();
|
|
|
|
if (spec.second_in_debug_package_path
|
|
&& strcmp(spec.second_in_debug_package_path, ""))
|
|
second_in_debug_package_path =
|
|
string(get_src_dir()) + "/tests/" + spec.second_in_debug_package_path;
|
|
else
|
|
second_in_debug_package_path.clear();
|
|
|
|
if (spec.first_in_devel_package_path
|
|
&& strcmp(spec.first_in_devel_package_path, ""))
|
|
first_in_devel_package_path =
|
|
string(get_src_dir()) + "/tests/" + spec.first_in_devel_package_path;
|
|
|
|
if (spec.second_in_devel_package_path
|
|
&& strcmp(spec.second_in_devel_package_path, ""))
|
|
second_in_devel_package_path =
|
|
string(get_src_dir()) + "/tests/" + spec.second_in_devel_package_path;
|
|
|
|
if (spec.suppression_path
|
|
&& strcmp(spec.suppression_path, ""))
|
|
suppression_path =
|
|
string(get_src_dir()) + "/tests/" + spec.suppression_path;
|
|
else
|
|
suppression_path.clear();
|
|
|
|
ref_abi_diff_report_path =
|
|
string(get_src_dir()) + "/tests/" + spec.ref_report_path;
|
|
out_abi_diff_report_path =
|
|
string(get_build_dir()) + "/tests/" + spec.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;
|
|
return;
|
|
}
|
|
|
|
abipkgdiff = string(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 (!first_in_devel_package_path.empty())
|
|
abipkgdiff += " --devel1 " + first_in_devel_package_path;
|
|
|
|
if (!second_in_devel_package_path.empty())
|
|
abipkgdiff += " --devel2 " + second_in_devel_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;
|
|
int code = system(cmd.c_str());
|
|
if (!WIFEXITED(code))
|
|
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;
|
|
}
|
|
}; // end struct test_task
|
|
|
|
/// A convenience typedef for shared
|
|
typedef shared_ptr<test_task> test_task_sptr;
|
|
|
|
int
|
|
main()
|
|
{
|
|
using std::vector;
|
|
using std::tr1::dynamic_pointer_cast;
|
|
using abigail::workers::queue;
|
|
using abigail::workers::task;
|
|
using abigail::workers::task_sptr;
|
|
using abigail::workers::get_number_of_threads;
|
|
|
|
/// 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.
|
|
const size_t num_tests = sizeof(in_out_specs) / sizeof (InOutSpec) - 1;
|
|
size_t num_workers = std::min(get_number_of_threads(), num_tests);
|
|
queue task_queue(num_workers);
|
|
|
|
bool is_ok = true;
|
|
|
|
for (InOutSpec *s = in_out_specs; s->first_in_package_path; ++s)
|
|
{
|
|
test_task_sptr t(new test_task(*s));
|
|
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<task_sptr>& completed_tasks =
|
|
task_queue.get_completed_tasks();
|
|
assert(completed_tasks.size() == num_tests);
|
|
|
|
for (vector<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->diff_cmd.empty())
|
|
system(t->diff_cmd.c_str());
|
|
if (!t->error_message.empty())
|
|
cerr << t->error_message << '\n';
|
|
}
|
|
}
|
|
|
|
return !is_ok;
|
|
}
|