Add --self-compare option in fedabipkgdiff

fedabipkgdiff tool can communicate with Fedora koji and has
capability to download and perform ABI comparison between
specified NVRs.

With addition of --self-compare option, it will be possible
to perform ABI comparison on same package. One of the important
usecase of this option is to run automated ABI checks on
packages with known expected result i.e. no ABI change. This usecase
will be useful to ensure that libabigail functionality doesn't
break with new commits made.
This option can be invoked as:
fedabipkgdiff -a --self-compare -fc24 package_name

	* bash-completion/fedabipkgdiff: Add new option --self-compare
	* tests/data/Makefile.am: Add new test file
	* tests/data/test-fedabipkgdiff/test7-self-compare-from-fc23-dbus-glib-report-0.txt:
	New reference output for testing ABI comparison on same package
	* tests/runtestfedabipkgdiff.py.in (FEDABIPKGDIFF_TEST_SPECS):
	Add test case for --self-compare
	* tools/fedabipkgdiff (build_commandline_args_parser()): Add
	new option --self-compare
	(generate_comparison_halves()): Find second comparision half in same
	package list while doing self-compare
	(self_compare_rpms_from_distro()): New function to perform ABI
	comparision on same pacakge
	(main()): Add if condition when --self-compare option is enabled
This commit is contained in:
Sinny Kumari 2017-05-21 15:10:12 +05:30
parent d8f09c9e89
commit 847d96b1d1
5 changed files with 77 additions and 7 deletions

View File

@ -19,7 +19,8 @@ _fedabipkgdiff_module()
--abipkgdiff
--clean-cache
--clean-cache-before
--clean-cache-after"
--clean-cache-after
--self-compare"
COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
return 0
;;

View File

@ -1294,6 +1294,7 @@ test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i
test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt \
test-fedabipkgdiff/test5-same-dir-dbus-glib-0.100.2-2.fc20.x86_64--dbus-glib-0.106-1.fc23.x86_64-report-0.txt \
test-fedabipkgdiff/test6-nss-util-3.12.6-1.fc14.x86_64--nss-util-3.24.0-2.0.fc25.x86_64-report-0.txt \
test-fedabipkgdiff/test7-self-compare-from-fc23-dbus-glib-report-0.txt \
test-fedabipkgdiff/packages/dbus-glib/0.100.2/2.fc20/i686/dbus-glib-0.100.2-2.fc20.i686.rpm \
test-fedabipkgdiff/packages/dbus-glib/0.100.2/2.fc20/i686/dbus-glib-debuginfo-0.100.2-2.fc20.i686.rpm \
test-fedabipkgdiff/packages/dbus-glib/0.100.2/2.fc20/i686/dbus-glib-devel-0.100.2-2.fc20.i686.rpm \

View File

@ -0,0 +1,12 @@
Comparing the ABI of binaries between dbus-glib-0.106-1.fc23.i686.rpm and dbus-glib-0.106-1.fc23.i686.rpm:
Comparing the ABI of binaries between dbus-glib-devel-0.106-1.fc23.i686.rpm and dbus-glib-devel-0.106-1.fc23.i686.rpm:
Comparing the ABI of binaries between dbus-glib-0.106-1.fc23.x86_64.rpm and dbus-glib-0.106-1.fc23.x86_64.rpm:
Comparing the ABI of binaries between dbus-glib-devel-0.106-1.fc23.x86_64.rpm and dbus-glib-devel-0.106-1.fc23.x86_64.rpm:

View File

@ -91,6 +91,10 @@ FEDABIPKGDIFF_TEST_SPECS = [
os.path.join(INPUT_DIR, 'nss-util/nss-util-3.24.0-2.0.fc25.x86_64.rpm')],
'data/test-fedabipkgdiff/test6-nss-util-3.12.6-1.fc14.x86_64--nss-util-3.24.0-2.0.fc25.x86_64-report-0.txt',
'output/test-fedabipkgdiff/test6-nss-util-3.12.6-1.fc14.x86_64--nss-util-3.24.0-2.0.fc25.x86_64-report-0.txt'),
(['--self-compare', '-a', '--from', 'fc23', 'dbus-glib'],
'data/test-fedabipkgdiff/test7-self-compare-from-fc23-dbus-glib-report-0.txt',
'output/test-fedabipkgdiff/test7-self-compare-from-fc23-dbus-glib-report-0.txt'),
]

View File

@ -528,16 +528,23 @@ def generate_comparison_halves(rpm_col1, rpm_col2):
if _rpm.is_devel and not global_config.check_all_subpackages:
continue
rpm2 = rpm_col2.get_peer_rpm(_rpm)
if rpm2 is None:
logger.warning('Peer RPM of {0} is not found.'.format(_rpm.filename))
continue
if global_config.self_compare:
rpm2 = _rpm
else:
rpm2 = rpm_col2.get_peer_rpm(_rpm)
if rpm2 is None:
logger.warning('Peer RPM of {0} is not found.'.format(_rpm.filename))
continue
debuginfo1 = rpm_col1.get_sibling_debuginfo(_rpm)
devel1 = rpm_col1.get_sibling_devel(_rpm)
debuginfo2 = rpm_col2.get_sibling_debuginfo(rpm2)
devel2 = rpm_col2.get_sibling_devel(rpm2)
if global_config.self_compare:
debuginfo2 = debuginfo1
devel2 = devel1
else:
debuginfo2 = rpm_col2.get_sibling_debuginfo(rpm2)
devel2 = rpm_col2.get_sibling_devel(rpm2)
yield (ComparisonHalf(subject=_rpm,
ancillary_debug=debuginfo1,
@ -1205,6 +1212,40 @@ def diff_two_nvras_from_koji():
return result
@log_call
def self_compare_rpms_from_distro():
"""Compare ABI between same package from a distro
Doing ABI comparison on self package should return no
ABI change and hence return code should be 0. This is useful
to ensure that functionality of libabigail itself
didn't break. This utility can be invoked like this:
fedabipkgdiff --self-compare -a --from fc25 foo
"""
from_distro = global_config.from_distro
if not is_distro_valid(from_distro):
raise InvalidDistroError('Invalid distro {0}'.format(from_distro))
package_name = global_config.NVR[0]
rpm_col1 = session.get_latest_built_rpms(package_name,
distro=global_config.from_distro)
if global_config.clean_cache_before:
delete_download_cache()
download_rpms(rpm_col1.rpms_iter())
result = run_abipkgdiff(rpm_col1, rpm_col1)
if global_config.clean_cache_after:
delete_download_cache()
return result
@log_call
def diff_from_two_rpm_files(from_rpm_file, to_rpm_file):
"""Diff two RPM files"""
@ -1345,6 +1386,13 @@ def build_commandline_args_parser():
dest='clean_cache_after',
default=None,
help='Clean cache after ABI comparison')
parser.add_argument(
'--self-compare',
required=False,
action='store_true',
dest='self_compare',
default=None,
help='ABI comparison on same package')
return parser
@ -1367,6 +1415,10 @@ def main():
logger.debug(args)
if global_config.from_distro and global_config.self_compare and \
global_config.NVR:
return self_compare_rpms_from_distro()
if global_config.from_distro and global_config.to_distro is None and \
global_config.NVR:
return diff_local_rpm_with_latest_rpm_from_koji()