Commit Graph

7 Commits

Author SHA1 Message Date
Chenxiong Qi
95b12167fa Fix package NVR comparison in fedabipkgdiff
When sorting two packages by their {Name Value Release} triplet to
select the latest one, just doing a string comparison of the NVRs is
wrong.  Take for example the packages foo-0.10-1.fc25 and
foo-0.2-1.fc25.  A basic string comparison will result in the string
"foo-0.10-1.fc25" being less than "foo-0.2-1.fc25", and thus
foo-0.2-1.fc25 will be selected as the latest package.  And that is
wrong, because the latest one is obviously foo-0.10-1.fc25.

So, after some research on this, I figured rpm.labelCompare is a
better choice to appropriately compare two NVRs.

Another reason why I chose rpm.labelCompare is because the latest
build in fedabipkgdiff means a build with the latest version.release
within a specific Fedora distribution such as fc23 or fc25.

	* configure.ac: Add new dependency.
	* tests/runtestfedabipkgdiff.py.in (builds): Add new builds for
	running tests to test selecting latest build from a package.
	(packages): Add new package gnutls.
	(GetPackageLatestBuildTest.{test_get_latest_one,
	test_cannot_find_a_latest_build_with_invalid_distro}): Use new
	builds of package gnutls to run tests.
	* tools/fedabipkgdiff (cmp_nvr): New function used to compare nvrs
	by Python built-in function sorted.
	(Brew.listBuilds): Use the new cmp_nvr function.

Signed-off-by: Chenxiong Qi <cqi@redhat.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-06-11 09:10:10 +02:00
Chenxiong Qi
69d2dcd163 Bug 20135 - Make fedabipkgdiff compare ABIs using devel packages
This patch makes fedabipkgdiff compare the ABI of two packages by
taking into account their associated devel packages, along with their
debug info packages.  Taking devel packages into account makes the
tool report changes about types that are defined in public header
files only.  This helps decrease the amount of change reports about
types not defined in public headers.

This is now the default behaviour.

However, if the user provides the new --no-devel-pkg command line
option, then the devel package is not taken into account during the
ABI comparison.

	* doc/manuals/fedabipkgdiff.rst: Add documentation for the new
	--no-devel-pkg command line option, as well as for the new default
	behaviour of taking devel packages into account during ABI
	comparison.
	* tools/fedabipkgdiff (PkgInfo): Add new attribute
	devel_package.
	(RPM.is_devel): New property to determine if rpm is a
	development package.
	(LocalRPM._find_rpm): New method to find a specific rpm.
	(LocalRPM.find_debuginfo): Use new method _find_rpm to find
	debuginfo package.
	(LocalRPM.find_devel): New method to find an associated
	development package.
	(Brew.select_rpms_from_a_build): RPMs selector method is
	changed to select development package also.
	(abipkgdiff): Construct and run abipkgdiff with and without
	--devel-pkg[12] options.
	(magic_construct): Construct PkgInfo with development package.
	(run_abipkgdiff): Run abipkgdiff against rpms with development
	packages.
	(diff_local_rpm_with_latest_rpm_from_koji): Find development
	package, and call method abipkgdiff with development package.
	(build_commandline_args_parser): add new option --no-devel-pkg.
	* tests/runtestfedabipkgdiff.py.in (packages): Add new package
	nss-util.
	(builds): Add new builds of nss-utils, nss-util-3.12.6-1.fc14
	and nss-util-3.24.0-2.0.fc25.
	(rpms): Add new associated rpms of the two new builds.
	(AssertionHelper.assert_functions_changes_summary): New method
	to match and assert functions changes summary.
	(AssertionHelper.assert_abi_comparison_result): Changed to
	support to help assert functions changes summary.
	(MockGlobalConfig.{no_devel_pkg, check_all_subpackages}): New
	fake options with default value for running tests.
	(RPMTest.setUp): add new development package for running test
	case.
	(RPMTest.test_is_devel): New test to test is_devel property.
	(RunAbipkgdiffTest.setUp): Add new development packages for
	running test case.
	(RunAbipkgdiffTest.{test_all_success, test_all_failure,
	test_partial_failure}): Mock global config.
	(RunAbipkgdiffWithDSOOnlyOptionTest): Removed.
	(CompareABIFromCommandLineTest.test_compare_with_no_devel_pkg):
	New test to test fedabipkgdiff with or without --no-devel-pkg
	option.
	* tests/data/Makefile.am: Add new rpms.
	* tests/data/test-fedabipkgdiff/packages/nss-util/3.12.6/1.fc14/
	x86_64/nss-util-3.12.6-1.fc14.x86_64.rpm: New rpm for running
	tests.
	* tests/data/test-fedabipkgdiff/packages/nss-util/3.12.6/1.fc14/
	x86_64/nss-util-debuginfo-3.12.6-1.fc14.x86_64.rpm: New rpm for
	running tests.
	* tests/data/test-fedabipkgdiff/packages/nss-util/3.12.6/1.fc14/
	x86_64/nss-util-devel-3.12.6-1.fc14.x86_64.rpm: New rpm for
	running tests.
	* tests/data/test-fedabipkgdiff/packages/nss-util/3.24.0/2.0.fc25/
	x86_64/nss-util-3.24.0-2.0.fc25.x86_64.rpm: New rpm for running
	tests.
	* tests/data/test-fedabipkgdiff/packages/nss-util/3.24.0/2.0.fc25/
	x86_64/nss-util-debuginfo-3.24.0-2.0.fc25.x86_64.rpm: New rpm
	for running tests.
	* tests/data/test-fedabipkgdiff/packages/nss-util/3.24.0/2.0.fc25/
	x86_64/nss-util-devel-3.24.0-2.0.fc25.x86_64.rpm: New rpm for
	running tests.

Signed-off-by: Chenxiong Qi <cqi@redhat.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-06-09 11:11:33 +02:00
Chenxiong Qi
70614e18f1 Add integration tests for fedabipkgdiff
A new test case class is introduced as integration tests, that is able to
test fedabipkgdiff ability against supported use cases and with other
command line options. Currently, integration tests only aim to ensure
whether expected comparison against rpms and binaries really happen.

	* configure.ac: do not detect shutil module.
	* tests/runtestfedabipkgdiff.py.in: do not import shutil
	anymore.
	(BUILT_ABIPKGDIFF): new global variable to reference the
	abipkgdiff built from source code, as the new test case' tests
	require this command directly rather than mocking the
	global_config.
	(test_data_dir): convert variable name to uppercase,
	reference to the test data directory by absolute path instead of
	relative path.
	(TEST_TOPDIR): new global variable to use data directory as the
	topdir passed to fedabpkgdiff to download rpms.
	(TEST_DOWNLOAD_CACHE_DIR): new global variable referencing a
	fake download cache directory for tests only.
	(packages, builds, rpms): new global variables as a fake
	storage holding packages, builds and rpms.
	(AssertionHelper): new class helping to assert abipkgdiff
	result easily.
	(MockClientSession): new class to mock koji.ClientSession.
	(MockGlobalConfig.abipkgdiff): set this option to global
	variable BUILT_ABIPKGDIFF.
	(MockKojiClientSessin): removed.
	(mock_get_session): removed.
	(GetPackageLatestBuildTest.{test_get_latest_one,
	test_cannot_find_a_latest_build_with_invalid_distro,
	test_cannot_find_a_latest_build_with_invalid_distro}): mock
	koji.ClientSession with new class MockClientSession. Remove
	invalid documentation from docstring. Use new package rather
	than httpd.
	(DownloadRPMTest.setUp): remove self.download_dir and use global
	TEST_DOWNLOAD_CACHE_DIR.
	(DownloadRPMTest.tearDown): do not remove download cache
	directory.
	(DownloadRPMTest.make_remote_file_url): do not omit positional
	argument specifiers in string format.
	(DownloadRPMTest.{test_succeed_to_download_a_rpm,
	test_failed_to_download_a_rpm}): set fake download cache
	directory to mocked get_download_dir in mock.patch decorator.
	(BrewListRPMsTest.test_select_specific_rpms): use new
	MockClientSession to mock koji.ClientSession. Rewrite test by
	using the new package listed in global variable packages.
	(RunAbipkgdiffWithDSOOnlyOptionTest.{test_abipkgdiff_with_dso_only,
	test_abipkgdiff_without_dso_only}): set fake download cache
	directory to mocked get_download_dir in mock.patch decorator.
	(CompareABIFromCommandLineTest): new integration test case.
	* tests/data/test-fedabipkgdiff/packages/dbus-glib/0.100.2/2.fc20/
	i686/dbus-glib-0.100.2-2.fc20.i686.rpm: new rpm for running tests.
	* tests/data/test-fedabipkgdiff/packages/dbus-glib/0.100.2/2.fc20/
	i686/dbus-glib-debuginfo-0.100.2-2.fc20.i686.rpm: new rpm for
	running tests.
	* tests/data/test-fedabipkgdiff/packages/dbus-glib/0.100.2/2.fc20/
	i686/dbus-glib-devel-0.100.2-2.fc20.i686.rpm: new rpm for
	running tests.
	* tests/data/test-fedabipkgdiff/packages/dbus-glib/0.100.2/2.fc20/
	x86_64/dbus-glib-0.100.2-2.fc20.x86_64.rpm: new rpm for running
	tests.
	* tests/data/test-fedabipkgdiff/packages/dbus-glib/0.100.2/2.fc20/
	x86_64/dbus-glib-debuginfo-0.100.2-2.fc20.x86_64.rpm: new rpm
	for running tests.
	* tests/data/test-fedabipkgdiff/packages/dbus-glib/0.100.2/2.fc20/
	x86_64/dbus-glib-devel-0.100.2-2.fc20.x86_64.rpm: new rpm for
	running tests.
	* tests/data/test-fedabipkgdiff/packages/dbus-glib/0.106/1.fc23/
	i686/dbus-glib-0.106-1.fc23.i686.rpm: new rpm for running tests.
	* tests/data/test-fedabipkgdiff/packages/dbus-glib/0.106/1.fc23/
	i686/dbus-glib-debuginfo-0.106-1.fc23.i686.rpm: new rpm for
	running tests.
	* tests/data/test-fedabipkgdiff/packages/dbus-glib/0.106/1.fc23/
	i686/dbus-glib-devel-0.106-1.fc23.i686.rpm: new rpm for running
	tests.
	* tests/data/test-fedabipkgdiff/packages/dbus-glib/0.106/1.fc23/
	x86_64/dbus-glib-0.106-1.fc23.x86_64.rpm: new rpm for running
	tests.
	* tests/data/test-fedabipkgdiff/packages/dbus-glib/0.106/1.fc23/
	x86_64/dbus-glib-debuginfo-0.106-1.fc23.x86_64.rpm: new rpm for
	running tests.
	* tests/data/test-fedabipkgdiff/packages/dbus-glib/0.106/1.fc23/
	x86_64/dbus-glib-devel-0.106-1.fc23.x86_64.rpm: new rpm for
	running tests.
	* tests/data/Makefile.am: add new rpms.

Signed-off-by: Chenxiong Qi <cqi@redhat.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-06-01 11:41:55 +02:00
Dodji Seketeli
b36ca1501e Bug 20180 - Support system-wide suppression specifications
This patch adds support for loading system and user level suppression
specifications for libabigail tools.

At launch time, relevant libabigail tools (abidiff, abipkgdiff
fedabipkgdiff for now) read the default system suppression
specification file, if it's present, from a file which path is the
value of the environment variable
LIBABIGAIL_DEFAULT_SYSTEM_SUPPRESSION_FILE, if set, or from the file
$libdir/libabigail/default.abignore.

Then it reads the user system suppression specification file, if it's
present, from a file which path is the value of the environment
variable LIBABIGAIL_DEFAULT_USER_SUPPRESSION_FILE, if set, or from the
file $HOME/.abignore.

The content of the user system suppression file is merged with the
content of default system suppression file.

That content is also merged with the content of the suppression
specification files that might be provided by the --suppressions
command line option of the invoked tools.

The resulting set of all these suppression specifications is thus used
to filter the ABI change reports that are emitted.

abidiff, abipkgdiff and abipkgdiff gain a --no-default-suppression
option to avoid loading any of these default suppression specification
files.

The patch also installs a default.abignore file into $(pkglibdir).
Note that on x86_64, that directory is /usr/lib64/libabigail.  Now we
just need to think about the content of that default.abignore file.

	* doc/manuals/abidiff.rst: Document the default suppression
	scheme, its interaction with the --supprs option and the new
	--no-default option.
	* doc/manuals/abipkgdiff.rst: Likewise.
	* doc/manuals/fedabipkgdiff.rst: Likewise.
	* configure.ac: Generate the tests/runtestdefaultsupprs.py file
	from the new tests/runtestdefaultsupprs.py.in template.
	* default.abignore: New file.
	* Makefile.am: Add it to source distribution.
	* src/Makefile.am: Define the ABIGAIL_ROOT_SYSTEM_LIBDIR
	preprocessor macro that is set the value of the $libdir autotools
	macro.
	* include/abg-tools-utils.h: Update copyright years.
	(get_system_libdir, get_default_system_suppression_file_path)
	(get_default_user_suppression_file_path)
	(load_default_system_suppressions)
	(load_default_user_suppressions): Declare new functions
	* src/abg-tools-utils.cc (get_system_libdir)
	(get_default_system_suppression_file_path)
	(get_default_user_suppression_file_path)
	(load_default_system_suppressions)
	(load_default_user_suppressions): Define new functions.
	(is_regular_file): Amend this so that it return true for symlinks
	to regular files too.
	(is_dir): Amend this so that it returns true for symlinks to
	directories too.
	* tools/abidiff.cc (options::no_default_supprs): New data member.
	(options::options): Initialize the new data member.
	(display_usage): Display a new help string for the new
	--no-default-suppression command line option.
	(parse_command_line): Parse this new command line option.
	(set_diff_context_from_opts): Load the default suppression
	specifications, unless --no-default-suppression or --supprs was
	provided.
	* tools/abipkgdiff.cc (options::no_default_supprs): New data
	member.
	(options::options): Initialize the new data member.
	(parse_command_line): Parse the new --no-default-suppression
	command line option.
	(main): Load the default suppression specifications, unless
	--no-default-suppression or --supprs was provided.
	* tools/fedabipkgdiff (abipkgdiff): Add --no-default-suppression
	to the invocation of abipkgdiff if it was provided on the command
	line.
	(build_commandline_args_parser): Parse the new
	--no-default-suppression command line option.
	* tests/runtestdefaultsupprs.py.in: New test harness template.
	* tests/Makefile.am: Add the new runtestdefaultsupprs.py to the
	set of tests.
	* tests/data/test-default-supprs/test0-type-suppr-0.suppr: New
	test input.
	* tests/data/test-default-supprs/test0-type-suppr-report-0.txt: Likewise.
	* tests/data/test-default-supprs/test0-type-suppr-v0.o: Likewise.
	* tests/data/test-default-supprs/test0-type-suppr-v1.o: Likewise.
	* tests/data/test-default-supprs/dirpkg-1-dir-report-0.txt:
	Likewise.
	* tests/data/test-default-supprs/dirpkg-1-dir1: Likewise.
	* tests/data/test-default-supprs/dirpkg-1-dir2: Likewise.
	* tests/data/Makefile.am: Add new the new tests input above to
	Makefile.am.
	* tests/runtestcanonicalizetypes.sh.in: Pass
	--no-default-suppression to abidiff invocations.
	* tests/runtestdefaultsupprs.py.in: Likewise.
	* tests/test-abidiff-exit.cc: Likewise.
	* tests/test-diff-dwarf-abixml.cc: Likewise.
	* tests/test-diff-filter.cc: Likewise.
	* tests/test-diff-suppr.cc: Likewise.
	* tools/abidiff.cc: Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-05-30 18:39:49 +02:00
Dodji Seketeli
af3e2fd570 Add --abipkgdiff option to fedabipkgdiff
When running the 'fedabipkgdiff' tool that is in the build directory,
before "make install", we want to use the 'abipkgdiff' command line
tool that is in the build directory, not the one that might be
at $PATH/bin/abipkgdiff.

To do so, this patch adds a --abipkgdiff <path/to/a/given/abipkgdiff>
option so that the user can chose where to find the 'abipkgdiff'
binary to use.

Note that there is no regression test for this option yet because for
that, we'd this bug to be fixed first:
https://sourceware.org/bugzilla/show_bug.cgi?id=20147.

	* tools/fedabipkgdiff (build_path_to_abipkgdiff): Define new
	function.
	(abipkgdiff): Invoke the new build_path_to_abipkgdiff() here.
	(build_commandline_args_parser): Parse the new --abipkgdiff
	option.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-05-30 16:24:53 +02:00
Chenxiong Qi
59917a8118 Bug 20085 - Add --dso-only option to fedabipkgdiff
abipkgdiff supports --dso-only to compare only ABI of shared libraries
instead of all binaries. So, with adding this option to fedabipkgdiff,
its user is also able to let fedabipkgdiff compare ABI of shared
libraries, or not.

	* tools/fedabipkgdiff: Do not import shlex anymore.
	(ABIDIFF_OK, ABIDIFF_ERROR, ABIDIFF_USAGE_ERROR)
	(ABIDIFF_ABI_CHANGE): New global constant variables.
	(abipkgdiff): Pass the --dso-only option to the abipkgdiff command
	line tool, if that option was passed to fedabipkgdiff. Build this
	abipkgdiff command invocation from an array of strings, rather
	than from formatting a string.  This makes us get rid of the shlex
	module.  Fix typo in dry-run logged string.  If there was an
	internal error reported by abipkgdiff, report it to stderr.
	(build_commandline_args_parser): Parse the --dso-only command line
	option.
	* tests/runtestfedabipkgdiff.py.in (fedabipkgdiff_mod): Fix a typo
	in initializing this global variable.
	(test_data_dir): New global variable, that is used to reference
	tests/data/test-fedabipkgdiff/.
	(RunAbipkgdiffTest.{test_all_success, test_partial_failure}): Fix
	typo.
	(Mockglobalconfig.{koji_topdir, dso_only}): New data members.
	(GetPackageLatestBuildTest.{test_get_latest_one,
	test_cannot_find_a_latest_build_with_invalid_distro,
	test_succeed_to_download_a_rpm, test_failed_to_download_a_rpm}):
	Fix typo.
	(BrewListRPMsTest.test_select_specific_rpms): Fix typo.
	(RunAbipkgdiffWithDSOOnlyOptionTest): New test case class.
	* doc/manuals/fedabipkgdiff.rst: update document for this new
	--dso-only option.
	* tests/data/test-fedabipkgdiff/dbus-glib-0.104-3.fc23.x86_64.rpm:
	New symbolic link to
	test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64.rpm.
	* tests/data/test-fedabipkgdiff/dbus-glib-0.80-3.fc12.x86_64.rpm:
	New symbolic link to
	test-diff-pkg/dbus-glib-0.80-3.fc12.x86_64.rpm.
	* tests/data/test-fedabipkgdiff/dbus-glib-debuginfo-0.104-3.fc23.x86_64.rpm:
	New symbolic link to
	test-diff-pkg/dbus-glib-debuginfo-0.104-3.fc23.x86_64.rpm.
	* tests/data/test-fedabipkgdiff/dbus-glib-debuginfo-0.80-3.fc12.x86_64.rpm:
	New symbolic link to
	test-diff-pkg/dbus-glib-debuginfo-0.80-3.fc12.x86_64.rpm.
	* tests/data/Makefile.am: add tests/data/test-fedabipkgdiff so
	that this data directory and all things within it can be included
	in tarball.

Signed-off-by: Chenxiong Qi <cqi@redhat.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-05-25 09:42:21 +02:00
Chenxiong Qi
57dcfb18f5 Bug 19428 - New fedabipkgdiff utility
fedabipkgdiff is a convenient way to compare the ABI of Fedora
packages easily.

The first version of fedabipkgdiff introduced by this patch lets users
perform operations like:

    fedabipkgdiff --from fc23 foo-0.1-1.fc23.x86_64.rpm
    fedabipkgdiff --from fc23 --to fc24 foo
    fedabipkgdiff foo-0.1-1.fc23 foo-0.1-1.fc24
    fedabipkgdiff foo-0.1-1.fc23.i686 foo-0.1-1.fc24.i686
    fedabipkgdiff --all-subpackages foo-0.1-1.fc23 foo-0.1-1.fc24

	* autoconf-archive/ax_compare_version.m4: New file copied from the
	autoconf-archive project.
	* autoconf-archive/ax_prog_python_version.m4: Likewise.
	* autoconf-archive/ax_python_module.m4: Likewise.
	* Makefile.am: Add the new files above to the source distribution.
	* configure.ac: Include the new m4 macros from the autoconf
	archive. Add a new --enable-fedabipkgdiff option. Update the
	report at the end of the configure process to show the status of
	the fedabipkgdiff feature. Add check for prerequisite python
	modules argparse, glob, logging, os, re, shlex, subprocess, sys,
	itertools, urlparse, itertools, shutil, unittest, xdg, koji and
	mock.  These are necessary for the unit test of
	fedabipkgdiff. Generate tests/runtestfedabipkgdiff.py into the
	build directory, from the tests/runtestfedabipkgdiff.py.in input
	file.
	* tools/Makefile.am: Include the fedabipkgdiff to the source
	distribution and install it if the "fedabipkgdiff" feature is
	enabled.
	* tests/Makefile.am: Rename runtestfedabipkgdiff.sh into
	runtestfedabipkgdiff.py.  Add the new runtestfedabipkgdiff.py.in
	autoconf template file in here.
	* tests/runtestfedabipkgdiff.py.in: New unit test file.
	* tools/fedabipkgdiff: New fedabipkgdiff tool.
	* doc/manuals/fedabipkgdiff.rst: New manual.

Signed-off-by: Chenxiong Qi <cqi@redhat.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-05-13 00:42:36 +02:00