libabigail/tests/runtestfedabipkgdiff.py.in
Dodji Seketeli cac0cbb6d5 fedabipkgdiff refuses to compare packages with the same release number
I tried to run:

    fedabipkgdiff vte291-0.39.1-1.fc22.x86_64 vte291-0.39.90-1.fc22.x86_64

And it wouldn't work :-(

The program considers the two packages as not being "peers".  This has
to do with the RPM.is_peer method which considers the two package as
not being "peers", just because they have the same release number
(1.fc22).

They should be considered peers, though, because they have the same
name but different {version, release} pairs.

This patch fixes the RPM.is_peer method and adds the aforementioned
packages to the regression test suite for good measure.

	* tools/fedabipkgdiff (RPM.is_peer): Update comment.  Fix logic.
	* tests/data/test-fedabipkgdiff/packages/vte291/0.39.1/1.fc22/x86_64/vte291-0.39.1-1.fc22.x86_64.rpm:
	New test input file.
	* tests/data/test-fedabipkgdiff/packages/vte291/0.39.1/1.fc22/x86_64/vte291-debuginfo-0.39.1-1.fc22.x86_64.rpm: Likewise.
	* tests/data/test-fedabipkgdiff/packages/vte291/0.39.1/1.fc22/x86_64/vte291-devel-0.39.1-1.fc22.x86_64.rpm: Likewise.
	* tests/data/test-fedabipkgdiff/packages/vte291/0.39.90/1.fc22/x86_64/vte291-0.39.90-1.fc22.x86_64.rpm: Likewise.
	* tests/data/test-fedabipkgdiff/packages/vte291/0.39.90/1.fc22/x86_64/vte291-debuginfo-0.39.90-1.fc22.x86_64.rpm: Likewise.
	* tests/data/test-fedabipkgdiff/packages/vte291/0.39.90/1.fc22/x86_64/vte291-devel-0.39.90-1.fc22.x86_64.rpm:
	Likewise.
	* tests/data/test-fedabipkgdiff/vte291-0.39.1-1.fc22.x86_64--vte291-0.39.90-1.fc22.x86_64-report-0.txt: Likewise.
	* tests/data/Makefile.am: Add the new test input data to source
	distribution.
	* tests/mockfedabipkgdiff.in: Update the package and build
	information to add the new vte291-0.39.1-1.fc22.x86_64.rpm and
	vte291-0.39.90-1.fc22.x86_64.rpm packages (as well as their devel
	and debuginfo packages) into the "mock" Koji build database.
	* tests/runtestfedabipkgdiff.py.in:  Make this test harness run
	over the two aforementioned packages.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-15 16:06:32 +01:00

168 lines
6.8 KiB
Python
Executable File

#!/usr/bin/python
# -*- coding: utf-8 -*-
# -*- Mode: Python
#
# 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 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 Public License for more details.
#
# You should have received a copy of the GNU General Public
# License along with this program; see the file COPYING-GPLV3. If
# not, see <http:#www.gnu.org/licenses/>.
#
# Author: Chenxiong Qi
'''Runs tests for the fedabipkgdiff program
This program runs the fedabipkgdiff tool (via the mockfedabipkgdiff
tool) repeatedly and compares its output against a set of reference
output files.
'''
import sys
import os
import subprocess
FEDABIPKGDIFF = '@abs_top_builddir@/tests/mockfedabipkgdiff'
TEST_SRC_DIR = '@abs_top_srcdir@/tests'
TEST_BUILD_DIR = '@abs_top_builddir@/tests'
INPUT_DIR = '@abs_top_srcdir@/tests/data/test-fedabipkgdiff'
OUTPUT_DIR = '@abs_top_builddir@/tests/output/test-fedabipkgdiff'
# This variable is a list of 3-uples. Here is the meaning of
# the elements of each 3-uples:
#
# (arguments to pass to fedabipkgdiff,
# reference output file,
# where to store the result of the comparison)
#
# Note that after fedabipkgdiff is run (using the arguments that are
# the first element of the tuple) the result of the comparison is
# going to be compared against the reference output file, and both
# must be equal.
#
# If a user wants to add a new test, she must add a new tuple to the
# variable below, and also add a new reference output to the source
# distribution.
#
FEDABIPKGDIFF_TEST_SPECS = [
(['--from', 'fc20', '--to', 'fc23', 'dbus-glib'],
'data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt',
'output/test-fedabipkgdiff/test0-type-suppr-report-0.txt'),
(['--from', 'fc20', os.path.join(INPUT_DIR,
'packages/dbus-glib/0.106/1.fc23/x86_64/'
'dbus-glib-0.106-1.fc23.x86_64.rpm')],
'data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt',
'output/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt'),
(['dbus-glib-0.100.2-2.fc20', 'dbus-glib-0.106-1.fc23'],
'data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt',
'output/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt'),
(['dbus-glib-0.100.2-2.fc20.i686', 'dbus-glib-0.106-1.fc23.i686'],
'data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt',
'output/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt'),
(['vte291-0.39.1-1.fc22.x86_64', 'vte291-0.39.90-1.fc22.x86_64'],
'data/test-fedabipkgdiff/vte291-0.39.1-1.fc22.x86_64--vte291-0.39.90-1.fc22.x86_64-report-0.txt',
'output/test-fedabipkgdiff/vte291-0.39.1-1.fc22.x86_64--vte291-0.39.90-1.fc22.x86_64-report-0.txt'),
([os.path.join(INPUT_DIR, 'packages/dbus-glib/0.100.2/2.fc20/x86_64/dbus-glib-0.100.2-2.fc20.x86_64.rpm'),
os.path.join(INPUT_DIR, 'packages/dbus-glib/0.106/1.fc23/x86_64/dbus-glib-0.106-1.fc23.x86_64.rpm')],
'data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt',
'output/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt'),
([os.path.join(INPUT_DIR, 'dbus-glib/dbus-glib-0.100.2-2.fc20.x86_64.rpm'),
os.path.join(INPUT_DIR, 'dbus-glib/dbus-glib-0.106-1.fc23.x86_64.rpm')],
'data/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',
'output/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'),
([os.path.join(INPUT_DIR, 'nss-util/nss-util-3.12.6-1.fc14.x86_64.rpm'),
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'),
]
def ensure_output_dir_created():
'''Create output dir if it's not already created.'''
try:
os.makedirs(OUTPUT_DIR)
except:
pass
if not os.path.exists(OUTPUT_DIR):
sys.exit(1)
def run_fedabipkgdiff_tests():
"""Run the fedabipkgdiff tests
Loop through the test inputs in the FEDABIPKGDIFF_TEST_SPECS global
variable and for each of the test input, launch a comparison using
mockfedabipkgdiff, which calls fedabipkgdiff by making sure it
doesn't use the network.
The result of the comparison is stored in an output file, and that
output file is compared (using GNU diff) against the reference
output file specified in the FEDABIPKGDIFF_TEST_SPECS global
variable.
This function returns True iff all comparison specified by
FEDABIPKGDIFF_TEST_SPECS succeed.
"""
result = True
for args, reference_report_path, output_path in FEDABIPKGDIFF_TEST_SPECS:
reference_report_path = os.path.join(TEST_SRC_DIR, reference_report_path)
output_path = os.path.join(TEST_BUILD_DIR, output_path)
cmd = [FEDABIPKGDIFF,
'--no-default-suppression',
'--show-identical-binaries'] + args
with open(output_path, 'w') as out_file:
subprocess.call(cmd, stdout=out_file)
if not os.path.exists(reference_report_path):
sys.stderr.write('file not found: ' + reference_report_path + '\n')
return_code = -1
else:
diffcmd = ['diff', '-u', reference_report_path, output_path]
return_code = subprocess.call(diffcmd)
if return_code:
sys.stderr.write('fedabipkgdiff test failed for ' +
reference_report_path + '\n')
result &= not return_code
return result
def main():
"""The main entry point of this program.
This creates the output directory and launches the tests for the
fedabipkgdiff program.
:return: 0 upon success, 1 otherwise.
"""
ensure_output_dir_created()
result = 0
result = run_fedabipkgdiff_tests()
return not result
if __name__ == '__main__':
exit_code = main()
sys.exit(exit_code)