libabigail/tests/runtestfedabipkgdiff.py.in

168 lines
6.8 KiB
Python
Raw Normal View History

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-02-09 10:05:33 +00:00
#!/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
Make fedabipkgdiff consistent with Libabigail's other tests 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>
2016-07-06 09:51:13 +00:00
'''Runs tests for the fedabipkgdiff program
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-02-09 10:05:33 +00:00
Make fedabipkgdiff consistent with Libabigail's other tests 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>
2016-07-06 09:51:13 +00:00
This program runs the fedabipkgdiff tool (via the mockfedabipkgdiff
tool) repeatedly and compares its output against a set of reference
output files.
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-05-30 14:11:31 +00:00
Make fedabipkgdiff consistent with Libabigail's other tests 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>
2016-07-06 09:51:13 +00:00
'''
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-05-30 14:11:31 +00:00
Make fedabipkgdiff consistent with Libabigail's other tests 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>
2016-07-06 09:51:13 +00:00
import sys
import os
import subprocess
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-05-30 14:11:31 +00:00
Make fedabipkgdiff consistent with Libabigail's other tests 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>
2016-07-06 09:51:13 +00:00
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'
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-05-30 14:11:31 +00:00
Make fedabipkgdiff consistent with Libabigail's other tests 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>
2016-07-06 09:51:13 +00:00
# This variable is a list of 3-uples. Here is the meaning of
# the elements of each 3-uples:
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-05-30 14:11:31 +00:00
#
Make fedabipkgdiff consistent with Libabigail's other tests 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>
2016-07-06 09:51:13 +00:00
# (arguments to pass to fedabipkgdiff,
# reference output file,
# where to store the result of the comparison)
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-05-30 14:11:31 +00:00
#
Make fedabipkgdiff consistent with Libabigail's other tests 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>
2016-07-06 09:51:13 +00:00
# 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.
Bug 20380 - Compare two local RPMs Bug 20270 is also fixed. This patch allows developer to compare two local RPMs in form fedabipkgdiff some/place/foo.rpm another/place/bar.rpm But, network is still needed to talk with Koji. This patch also introduces new terms for libabigail, that is the subject, ancillary package, and comparison half. Subject represents a package that is subject of the ABI comparison, a subject could be a RPM and maybe it would be a DEB or some other kind of "package". A subject may have several ancillary packages that are used to compare the subject. Generally, a subject may have devel, debuginfo, or both. * configure.ac: add dependent mimetype module. * doc/manuals/fedabipkgdiff.rst: Update to add document for the new use case of comparing two local RPMs. * tests/data/Makefile.am: Include new RPMs for tests. * tests/data/test-fedabipkgdiff/dbus-glib/dbus-glib-0.100.2-2.fc20.x86_64.rpm: New RPM for running test. * tests/data/test-fedabipkgdiff/dbus-glib/dbus-glib-0.106-1.fc23.x86_64.rpm: Likewise. * tests/data/test-fedabipkgdiff/nss-util/nss-util-3.12.6-1.fc14.x86_64.rpm: Likewise. * tests/data/test-fedabipkgdiff/nss-util/nss-util-3.24.0-2.0.fc25.x86_64.rpm: Likewise. * tests/data/test-fedabipkgdiff/nss-util/nss-util-devel-3.24.0-2.0.fc25.x86_64.rpm: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Rename filename by adding .rpm extension. * tests/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: New reference output for testing comparing local RPMs. * tests/data/test-fedabipkgdiff/test6-missing-devel-debuginfo-nss-util-3.12.6-1.fc14.x86_64--nss-util-3.24.0-2.0.fc25.x86_64-report-0.txt: New reference output for testing comparison without non-existent debuginfo or development package. * tests/runtestfedabipkgdiff.py.in (FEDABIPKGDIFF_TEST_SPECS): Rename filename for test4. Add two new test cases. (run_fedabipkgdiff_tests): Remove semicolon and trailing whitespaces. (main): Likewise. (ensure_output_dir_created): Likewise. * tools/fedabipkgdiff: Require some new modules. Fix of return code. (PkgInfo): Renamed to ComparisonHalf. (match_nvr): New method to determine if a string matches format of N-V-R. (match_nvra): New method to determine if a string matches format of N-V-R.A. (is_rpm_file): New method to guess if a file is a RPM file. (RPM.is_peer): New method to determine if current RPM is a peer of another. (RPM.filename): Use Koji module API to construct the filename. (RPM.nvra): Get nvra from filename instead of constructing manually that is duplicated with Koji module API. (RPMCollection): New class to represent a set of RPMs. (generate_pkg_info_pair_for_abipkgdiff): New method working as a generator to yeild comparison halves for running abipkgdiff. (Brew.getRPM): Fix string format with incorrect argument. (Brew.select_rpms_from_a_build): Return instance of RPMCollection. (abipkgdiff): If there is no debuginfo or development package, just ignore it and leave a warning. If --error-on-warning is specified, raise an exception instead. Arguments are modified to represent the new name ComparisonHalf, and relative docstring is also updated. (magic_construct): Removed. (run_abipkgdiff): Rewrite. (make_rpms_usable_for_abipkgdiff): Removed. (diff_local_rpm_with_latest_rpm_from_koji): Rewrite by using RPMCollection. (diff_latest_rpms_based_on_distros): Likewise. (diff_two_nvras_from_koji): Likewise. (diff_from_two_rpm_files): New method to compare two local RPMs. (build_commandline_args_parser): Add new option --error-on-warning. (main): Add support to compare local RPMs. Signed-off-by: Chenxiong Qi <cqi@redhat.com> Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-08-11 13:48:00 +00:00
#
Make fedabipkgdiff consistent with Libabigail's other tests 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>
2016-07-06 09:51:13 +00:00
# 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.
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-05-30 14:11:31 +00:00
#
Make fedabipkgdiff consistent with Libabigail's other tests 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>
2016-07-06 09:51:13 +00:00
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'),
Bug 20380 - Compare two local RPMs Bug 20270 is also fixed. This patch allows developer to compare two local RPMs in form fedabipkgdiff some/place/foo.rpm another/place/bar.rpm But, network is still needed to talk with Koji. This patch also introduces new terms for libabigail, that is the subject, ancillary package, and comparison half. Subject represents a package that is subject of the ABI comparison, a subject could be a RPM and maybe it would be a DEB or some other kind of "package". A subject may have several ancillary packages that are used to compare the subject. Generally, a subject may have devel, debuginfo, or both. * configure.ac: add dependent mimetype module. * doc/manuals/fedabipkgdiff.rst: Update to add document for the new use case of comparing two local RPMs. * tests/data/Makefile.am: Include new RPMs for tests. * tests/data/test-fedabipkgdiff/dbus-glib/dbus-glib-0.100.2-2.fc20.x86_64.rpm: New RPM for running test. * tests/data/test-fedabipkgdiff/dbus-glib/dbus-glib-0.106-1.fc23.x86_64.rpm: Likewise. * tests/data/test-fedabipkgdiff/nss-util/nss-util-3.12.6-1.fc14.x86_64.rpm: Likewise. * tests/data/test-fedabipkgdiff/nss-util/nss-util-3.24.0-2.0.fc25.x86_64.rpm: Likewise. * tests/data/test-fedabipkgdiff/nss-util/nss-util-devel-3.24.0-2.0.fc25.x86_64.rpm: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Rename filename by adding .rpm extension. * tests/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: New reference output for testing comparing local RPMs. * tests/data/test-fedabipkgdiff/test6-missing-devel-debuginfo-nss-util-3.12.6-1.fc14.x86_64--nss-util-3.24.0-2.0.fc25.x86_64-report-0.txt: New reference output for testing comparison without non-existent debuginfo or development package. * tests/runtestfedabipkgdiff.py.in (FEDABIPKGDIFF_TEST_SPECS): Rename filename for test4. Add two new test cases. (run_fedabipkgdiff_tests): Remove semicolon and trailing whitespaces. (main): Likewise. (ensure_output_dir_created): Likewise. * tools/fedabipkgdiff: Require some new modules. Fix of return code. (PkgInfo): Renamed to ComparisonHalf. (match_nvr): New method to determine if a string matches format of N-V-R. (match_nvra): New method to determine if a string matches format of N-V-R.A. (is_rpm_file): New method to guess if a file is a RPM file. (RPM.is_peer): New method to determine if current RPM is a peer of another. (RPM.filename): Use Koji module API to construct the filename. (RPM.nvra): Get nvra from filename instead of constructing manually that is duplicated with Koji module API. (RPMCollection): New class to represent a set of RPMs. (generate_pkg_info_pair_for_abipkgdiff): New method working as a generator to yeild comparison halves for running abipkgdiff. (Brew.getRPM): Fix string format with incorrect argument. (Brew.select_rpms_from_a_build): Return instance of RPMCollection. (abipkgdiff): If there is no debuginfo or development package, just ignore it and leave a warning. If --error-on-warning is specified, raise an exception instead. Arguments are modified to represent the new name ComparisonHalf, and relative docstring is also updated. (magic_construct): Removed. (run_abipkgdiff): Rewrite. (make_rpms_usable_for_abipkgdiff): Removed. (diff_local_rpm_with_latest_rpm_from_koji): Rewrite by using RPMCollection. (diff_latest_rpms_based_on_distros): Likewise. (diff_two_nvras_from_koji): Likewise. (diff_from_two_rpm_files): New method to compare two local RPMs. (build_commandline_args_parser): Add new option --error-on-warning. (main): Add support to compare local RPMs. Signed-off-by: Chenxiong Qi <cqi@redhat.com> Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-08-11 13:48:00 +00:00
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-01-23 22:28:12 +00:00
(['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'),
Bug 20380 - Compare two local RPMs Bug 20270 is also fixed. This patch allows developer to compare two local RPMs in form fedabipkgdiff some/place/foo.rpm another/place/bar.rpm But, network is still needed to talk with Koji. This patch also introduces new terms for libabigail, that is the subject, ancillary package, and comparison half. Subject represents a package that is subject of the ABI comparison, a subject could be a RPM and maybe it would be a DEB or some other kind of "package". A subject may have several ancillary packages that are used to compare the subject. Generally, a subject may have devel, debuginfo, or both. * configure.ac: add dependent mimetype module. * doc/manuals/fedabipkgdiff.rst: Update to add document for the new use case of comparing two local RPMs. * tests/data/Makefile.am: Include new RPMs for tests. * tests/data/test-fedabipkgdiff/dbus-glib/dbus-glib-0.100.2-2.fc20.x86_64.rpm: New RPM for running test. * tests/data/test-fedabipkgdiff/dbus-glib/dbus-glib-0.106-1.fc23.x86_64.rpm: Likewise. * tests/data/test-fedabipkgdiff/nss-util/nss-util-3.12.6-1.fc14.x86_64.rpm: Likewise. * tests/data/test-fedabipkgdiff/nss-util/nss-util-3.24.0-2.0.fc25.x86_64.rpm: Likewise. * tests/data/test-fedabipkgdiff/nss-util/nss-util-devel-3.24.0-2.0.fc25.x86_64.rpm: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Rename filename by adding .rpm extension. * tests/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: New reference output for testing comparing local RPMs. * tests/data/test-fedabipkgdiff/test6-missing-devel-debuginfo-nss-util-3.12.6-1.fc14.x86_64--nss-util-3.24.0-2.0.fc25.x86_64-report-0.txt: New reference output for testing comparison without non-existent debuginfo or development package. * tests/runtestfedabipkgdiff.py.in (FEDABIPKGDIFF_TEST_SPECS): Rename filename for test4. Add two new test cases. (run_fedabipkgdiff_tests): Remove semicolon and trailing whitespaces. (main): Likewise. (ensure_output_dir_created): Likewise. * tools/fedabipkgdiff: Require some new modules. Fix of return code. (PkgInfo): Renamed to ComparisonHalf. (match_nvr): New method to determine if a string matches format of N-V-R. (match_nvra): New method to determine if a string matches format of N-V-R.A. (is_rpm_file): New method to guess if a file is a RPM file. (RPM.is_peer): New method to determine if current RPM is a peer of another. (RPM.filename): Use Koji module API to construct the filename. (RPM.nvra): Get nvra from filename instead of constructing manually that is duplicated with Koji module API. (RPMCollection): New class to represent a set of RPMs. (generate_pkg_info_pair_for_abipkgdiff): New method working as a generator to yeild comparison halves for running abipkgdiff. (Brew.getRPM): Fix string format with incorrect argument. (Brew.select_rpms_from_a_build): Return instance of RPMCollection. (abipkgdiff): If there is no debuginfo or development package, just ignore it and leave a warning. If --error-on-warning is specified, raise an exception instead. Arguments are modified to represent the new name ComparisonHalf, and relative docstring is also updated. (magic_construct): Removed. (run_abipkgdiff): Rewrite. (make_rpms_usable_for_abipkgdiff): Removed. (diff_local_rpm_with_latest_rpm_from_koji): Rewrite by using RPMCollection. (diff_latest_rpms_based_on_distros): Likewise. (diff_two_nvras_from_koji): Likewise. (diff_from_two_rpm_files): New method to compare two local RPMs. (build_commandline_args_parser): Add new option --error-on-warning. (main): Add support to compare local RPMs. Signed-off-by: Chenxiong Qi <cqi@redhat.com> Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-08-11 13:48:00 +00:00
([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'),
Make fedabipkgdiff consistent with Libabigail's other tests 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>
2016-07-06 09:51:13 +00:00
]
Bug 20380 - Compare two local RPMs Bug 20270 is also fixed. This patch allows developer to compare two local RPMs in form fedabipkgdiff some/place/foo.rpm another/place/bar.rpm But, network is still needed to talk with Koji. This patch also introduces new terms for libabigail, that is the subject, ancillary package, and comparison half. Subject represents a package that is subject of the ABI comparison, a subject could be a RPM and maybe it would be a DEB or some other kind of "package". A subject may have several ancillary packages that are used to compare the subject. Generally, a subject may have devel, debuginfo, or both. * configure.ac: add dependent mimetype module. * doc/manuals/fedabipkgdiff.rst: Update to add document for the new use case of comparing two local RPMs. * tests/data/Makefile.am: Include new RPMs for tests. * tests/data/test-fedabipkgdiff/dbus-glib/dbus-glib-0.100.2-2.fc20.x86_64.rpm: New RPM for running test. * tests/data/test-fedabipkgdiff/dbus-glib/dbus-glib-0.106-1.fc23.x86_64.rpm: Likewise. * tests/data/test-fedabipkgdiff/nss-util/nss-util-3.12.6-1.fc14.x86_64.rpm: Likewise. * tests/data/test-fedabipkgdiff/nss-util/nss-util-3.24.0-2.0.fc25.x86_64.rpm: Likewise. * tests/data/test-fedabipkgdiff/nss-util/nss-util-devel-3.24.0-2.0.fc25.x86_64.rpm: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Rename filename by adding .rpm extension. * tests/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: New reference output for testing comparing local RPMs. * tests/data/test-fedabipkgdiff/test6-missing-devel-debuginfo-nss-util-3.12.6-1.fc14.x86_64--nss-util-3.24.0-2.0.fc25.x86_64-report-0.txt: New reference output for testing comparison without non-existent debuginfo or development package. * tests/runtestfedabipkgdiff.py.in (FEDABIPKGDIFF_TEST_SPECS): Rename filename for test4. Add two new test cases. (run_fedabipkgdiff_tests): Remove semicolon and trailing whitespaces. (main): Likewise. (ensure_output_dir_created): Likewise. * tools/fedabipkgdiff: Require some new modules. Fix of return code. (PkgInfo): Renamed to ComparisonHalf. (match_nvr): New method to determine if a string matches format of N-V-R. (match_nvra): New method to determine if a string matches format of N-V-R.A. (is_rpm_file): New method to guess if a file is a RPM file. (RPM.is_peer): New method to determine if current RPM is a peer of another. (RPM.filename): Use Koji module API to construct the filename. (RPM.nvra): Get nvra from filename instead of constructing manually that is duplicated with Koji module API. (RPMCollection): New class to represent a set of RPMs. (generate_pkg_info_pair_for_abipkgdiff): New method working as a generator to yeild comparison halves for running abipkgdiff. (Brew.getRPM): Fix string format with incorrect argument. (Brew.select_rpms_from_a_build): Return instance of RPMCollection. (abipkgdiff): If there is no debuginfo or development package, just ignore it and leave a warning. If --error-on-warning is specified, raise an exception instead. Arguments are modified to represent the new name ComparisonHalf, and relative docstring is also updated. (magic_construct): Removed. (run_abipkgdiff): Rewrite. (make_rpms_usable_for_abipkgdiff): Removed. (diff_local_rpm_with_latest_rpm_from_koji): Rewrite by using RPMCollection. (diff_latest_rpms_based_on_distros): Likewise. (diff_two_nvras_from_koji): Likewise. (diff_from_two_rpm_files): New method to compare two local RPMs. (build_commandline_args_parser): Add new option --error-on-warning. (main): Add support to compare local RPMs. Signed-off-by: Chenxiong Qi <cqi@redhat.com> Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-08-11 13:48:00 +00:00
Make fedabipkgdiff consistent with Libabigail's other tests 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>
2016-07-06 09:51:13 +00:00
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):
Bug 20380 - Compare two local RPMs Bug 20270 is also fixed. This patch allows developer to compare two local RPMs in form fedabipkgdiff some/place/foo.rpm another/place/bar.rpm But, network is still needed to talk with Koji. This patch also introduces new terms for libabigail, that is the subject, ancillary package, and comparison half. Subject represents a package that is subject of the ABI comparison, a subject could be a RPM and maybe it would be a DEB or some other kind of "package". A subject may have several ancillary packages that are used to compare the subject. Generally, a subject may have devel, debuginfo, or both. * configure.ac: add dependent mimetype module. * doc/manuals/fedabipkgdiff.rst: Update to add document for the new use case of comparing two local RPMs. * tests/data/Makefile.am: Include new RPMs for tests. * tests/data/test-fedabipkgdiff/dbus-glib/dbus-glib-0.100.2-2.fc20.x86_64.rpm: New RPM for running test. * tests/data/test-fedabipkgdiff/dbus-glib/dbus-glib-0.106-1.fc23.x86_64.rpm: Likewise. * tests/data/test-fedabipkgdiff/nss-util/nss-util-3.12.6-1.fc14.x86_64.rpm: Likewise. * tests/data/test-fedabipkgdiff/nss-util/nss-util-3.24.0-2.0.fc25.x86_64.rpm: Likewise. * tests/data/test-fedabipkgdiff/nss-util/nss-util-devel-3.24.0-2.0.fc25.x86_64.rpm: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Rename filename by adding .rpm extension. * tests/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: New reference output for testing comparing local RPMs. * tests/data/test-fedabipkgdiff/test6-missing-devel-debuginfo-nss-util-3.12.6-1.fc14.x86_64--nss-util-3.24.0-2.0.fc25.x86_64-report-0.txt: New reference output for testing comparison without non-existent debuginfo or development package. * tests/runtestfedabipkgdiff.py.in (FEDABIPKGDIFF_TEST_SPECS): Rename filename for test4. Add two new test cases. (run_fedabipkgdiff_tests): Remove semicolon and trailing whitespaces. (main): Likewise. (ensure_output_dir_created): Likewise. * tools/fedabipkgdiff: Require some new modules. Fix of return code. (PkgInfo): Renamed to ComparisonHalf. (match_nvr): New method to determine if a string matches format of N-V-R. (match_nvra): New method to determine if a string matches format of N-V-R.A. (is_rpm_file): New method to guess if a file is a RPM file. (RPM.is_peer): New method to determine if current RPM is a peer of another. (RPM.filename): Use Koji module API to construct the filename. (RPM.nvra): Get nvra from filename instead of constructing manually that is duplicated with Koji module API. (RPMCollection): New class to represent a set of RPMs. (generate_pkg_info_pair_for_abipkgdiff): New method working as a generator to yeild comparison halves for running abipkgdiff. (Brew.getRPM): Fix string format with incorrect argument. (Brew.select_rpms_from_a_build): Return instance of RPMCollection. (abipkgdiff): If there is no debuginfo or development package, just ignore it and leave a warning. If --error-on-warning is specified, raise an exception instead. Arguments are modified to represent the new name ComparisonHalf, and relative docstring is also updated. (magic_construct): Removed. (run_abipkgdiff): Rewrite. (make_rpms_usable_for_abipkgdiff): Removed. (diff_local_rpm_with_latest_rpm_from_koji): Rewrite by using RPMCollection. (diff_latest_rpms_based_on_distros): Likewise. (diff_two_nvras_from_koji): Likewise. (diff_from_two_rpm_files): New method to compare two local RPMs. (build_commandline_args_parser): Add new option --error-on-warning. (main): Add support to compare local RPMs. Signed-off-by: Chenxiong Qi <cqi@redhat.com> Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-08-11 13:48:00 +00:00
sys.exit(1)
Make fedabipkgdiff consistent with Libabigail's other tests 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>
2016-07-06 09:51:13 +00:00
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.
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-05-30 14:11:31 +00:00
"""
Bug 20380 - Compare two local RPMs Bug 20270 is also fixed. This patch allows developer to compare two local RPMs in form fedabipkgdiff some/place/foo.rpm another/place/bar.rpm But, network is still needed to talk with Koji. This patch also introduces new terms for libabigail, that is the subject, ancillary package, and comparison half. Subject represents a package that is subject of the ABI comparison, a subject could be a RPM and maybe it would be a DEB or some other kind of "package". A subject may have several ancillary packages that are used to compare the subject. Generally, a subject may have devel, debuginfo, or both. * configure.ac: add dependent mimetype module. * doc/manuals/fedabipkgdiff.rst: Update to add document for the new use case of comparing two local RPMs. * tests/data/Makefile.am: Include new RPMs for tests. * tests/data/test-fedabipkgdiff/dbus-glib/dbus-glib-0.100.2-2.fc20.x86_64.rpm: New RPM for running test. * tests/data/test-fedabipkgdiff/dbus-glib/dbus-glib-0.106-1.fc23.x86_64.rpm: Likewise. * tests/data/test-fedabipkgdiff/nss-util/nss-util-3.12.6-1.fc14.x86_64.rpm: Likewise. * tests/data/test-fedabipkgdiff/nss-util/nss-util-3.24.0-2.0.fc25.x86_64.rpm: Likewise. * tests/data/test-fedabipkgdiff/nss-util/nss-util-devel-3.24.0-2.0.fc25.x86_64.rpm: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Rename filename by adding .rpm extension. * tests/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: New reference output for testing comparing local RPMs. * tests/data/test-fedabipkgdiff/test6-missing-devel-debuginfo-nss-util-3.12.6-1.fc14.x86_64--nss-util-3.24.0-2.0.fc25.x86_64-report-0.txt: New reference output for testing comparison without non-existent debuginfo or development package. * tests/runtestfedabipkgdiff.py.in (FEDABIPKGDIFF_TEST_SPECS): Rename filename for test4. Add two new test cases. (run_fedabipkgdiff_tests): Remove semicolon and trailing whitespaces. (main): Likewise. (ensure_output_dir_created): Likewise. * tools/fedabipkgdiff: Require some new modules. Fix of return code. (PkgInfo): Renamed to ComparisonHalf. (match_nvr): New method to determine if a string matches format of N-V-R. (match_nvra): New method to determine if a string matches format of N-V-R.A. (is_rpm_file): New method to guess if a file is a RPM file. (RPM.is_peer): New method to determine if current RPM is a peer of another. (RPM.filename): Use Koji module API to construct the filename. (RPM.nvra): Get nvra from filename instead of constructing manually that is duplicated with Koji module API. (RPMCollection): New class to represent a set of RPMs. (generate_pkg_info_pair_for_abipkgdiff): New method working as a generator to yeild comparison halves for running abipkgdiff. (Brew.getRPM): Fix string format with incorrect argument. (Brew.select_rpms_from_a_build): Return instance of RPMCollection. (abipkgdiff): If there is no debuginfo or development package, just ignore it and leave a warning. If --error-on-warning is specified, raise an exception instead. Arguments are modified to represent the new name ComparisonHalf, and relative docstring is also updated. (magic_construct): Removed. (run_abipkgdiff): Rewrite. (make_rpms_usable_for_abipkgdiff): Removed. (diff_local_rpm_with_latest_rpm_from_koji): Rewrite by using RPMCollection. (diff_latest_rpms_based_on_distros): Likewise. (diff_two_nvras_from_koji): Likewise. (diff_from_two_rpm_files): New method to compare two local RPMs. (build_commandline_args_parser): Add new option --error-on-warning. (main): Add support to compare local RPMs. Signed-off-by: Chenxiong Qi <cqi@redhat.com> Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-08-11 13:48:00 +00:00
result = True
Make fedabipkgdiff consistent with Libabigail's other tests 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>
2016-07-06 09:51:13 +00:00
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
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-05-30 14:11:31 +00:00
Make fedabipkgdiff consistent with Libabigail's other tests 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>
2016-07-06 09:51:13 +00:00
with open(output_path, 'w') as out_file:
subprocess.call(cmd, stdout=out_file)
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-05-30 14:11:31 +00:00
Make fedabipkgdiff consistent with Libabigail's other tests 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>
2016-07-06 09:51:13 +00:00
if not os.path.exists(reference_report_path):
sys.stderr.write('file not found: ' + reference_report_path + '\n')
Make fedabipkgdiff consistent with Libabigail's other tests 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>
2016-07-06 09:51:13 +00:00
return_code = -1
else:
diffcmd = ['diff', '-u', reference_report_path, output_path]
return_code = subprocess.call(diffcmd)
Bug 20380 - Compare two local RPMs Bug 20270 is also fixed. This patch allows developer to compare two local RPMs in form fedabipkgdiff some/place/foo.rpm another/place/bar.rpm But, network is still needed to talk with Koji. This patch also introduces new terms for libabigail, that is the subject, ancillary package, and comparison half. Subject represents a package that is subject of the ABI comparison, a subject could be a RPM and maybe it would be a DEB or some other kind of "package". A subject may have several ancillary packages that are used to compare the subject. Generally, a subject may have devel, debuginfo, or both. * configure.ac: add dependent mimetype module. * doc/manuals/fedabipkgdiff.rst: Update to add document for the new use case of comparing two local RPMs. * tests/data/Makefile.am: Include new RPMs for tests. * tests/data/test-fedabipkgdiff/dbus-glib/dbus-glib-0.100.2-2.fc20.x86_64.rpm: New RPM for running test. * tests/data/test-fedabipkgdiff/dbus-glib/dbus-glib-0.106-1.fc23.x86_64.rpm: Likewise. * tests/data/test-fedabipkgdiff/nss-util/nss-util-3.12.6-1.fc14.x86_64.rpm: Likewise. * tests/data/test-fedabipkgdiff/nss-util/nss-util-3.24.0-2.0.fc25.x86_64.rpm: Likewise. * tests/data/test-fedabipkgdiff/nss-util/nss-util-devel-3.24.0-2.0.fc25.x86_64.rpm: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Rename filename by adding .rpm extension. * tests/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: New reference output for testing comparing local RPMs. * tests/data/test-fedabipkgdiff/test6-missing-devel-debuginfo-nss-util-3.12.6-1.fc14.x86_64--nss-util-3.24.0-2.0.fc25.x86_64-report-0.txt: New reference output for testing comparison without non-existent debuginfo or development package. * tests/runtestfedabipkgdiff.py.in (FEDABIPKGDIFF_TEST_SPECS): Rename filename for test4. Add two new test cases. (run_fedabipkgdiff_tests): Remove semicolon and trailing whitespaces. (main): Likewise. (ensure_output_dir_created): Likewise. * tools/fedabipkgdiff: Require some new modules. Fix of return code. (PkgInfo): Renamed to ComparisonHalf. (match_nvr): New method to determine if a string matches format of N-V-R. (match_nvra): New method to determine if a string matches format of N-V-R.A. (is_rpm_file): New method to guess if a file is a RPM file. (RPM.is_peer): New method to determine if current RPM is a peer of another. (RPM.filename): Use Koji module API to construct the filename. (RPM.nvra): Get nvra from filename instead of constructing manually that is duplicated with Koji module API. (RPMCollection): New class to represent a set of RPMs. (generate_pkg_info_pair_for_abipkgdiff): New method working as a generator to yeild comparison halves for running abipkgdiff. (Brew.getRPM): Fix string format with incorrect argument. (Brew.select_rpms_from_a_build): Return instance of RPMCollection. (abipkgdiff): If there is no debuginfo or development package, just ignore it and leave a warning. If --error-on-warning is specified, raise an exception instead. Arguments are modified to represent the new name ComparisonHalf, and relative docstring is also updated. (magic_construct): Removed. (run_abipkgdiff): Rewrite. (make_rpms_usable_for_abipkgdiff): Removed. (diff_local_rpm_with_latest_rpm_from_koji): Rewrite by using RPMCollection. (diff_latest_rpms_based_on_distros): Likewise. (diff_two_nvras_from_koji): Likewise. (diff_from_two_rpm_files): New method to compare two local RPMs. (build_commandline_args_parser): Add new option --error-on-warning. (main): Add support to compare local RPMs. Signed-off-by: Chenxiong Qi <cqi@redhat.com> Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-08-11 13:48:00 +00:00
if return_code:
Make fedabipkgdiff consistent with Libabigail's other tests 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>
2016-07-06 09:51:13 +00:00
sys.stderr.write('fedabipkgdiff test failed for ' +
reference_report_path + '\n')
result &= not return_code
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-05-30 14:11:31 +00:00
Bug 20380 - Compare two local RPMs Bug 20270 is also fixed. This patch allows developer to compare two local RPMs in form fedabipkgdiff some/place/foo.rpm another/place/bar.rpm But, network is still needed to talk with Koji. This patch also introduces new terms for libabigail, that is the subject, ancillary package, and comparison half. Subject represents a package that is subject of the ABI comparison, a subject could be a RPM and maybe it would be a DEB or some other kind of "package". A subject may have several ancillary packages that are used to compare the subject. Generally, a subject may have devel, debuginfo, or both. * configure.ac: add dependent mimetype module. * doc/manuals/fedabipkgdiff.rst: Update to add document for the new use case of comparing two local RPMs. * tests/data/Makefile.am: Include new RPMs for tests. * tests/data/test-fedabipkgdiff/dbus-glib/dbus-glib-0.100.2-2.fc20.x86_64.rpm: New RPM for running test. * tests/data/test-fedabipkgdiff/dbus-glib/dbus-glib-0.106-1.fc23.x86_64.rpm: Likewise. * tests/data/test-fedabipkgdiff/nss-util/nss-util-3.12.6-1.fc14.x86_64.rpm: Likewise. * tests/data/test-fedabipkgdiff/nss-util/nss-util-3.24.0-2.0.fc25.x86_64.rpm: Likewise. * tests/data/test-fedabipkgdiff/nss-util/nss-util-devel-3.24.0-2.0.fc25.x86_64.rpm: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Rename filename by adding .rpm extension. * tests/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: New reference output for testing comparing local RPMs. * tests/data/test-fedabipkgdiff/test6-missing-devel-debuginfo-nss-util-3.12.6-1.fc14.x86_64--nss-util-3.24.0-2.0.fc25.x86_64-report-0.txt: New reference output for testing comparison without non-existent debuginfo or development package. * tests/runtestfedabipkgdiff.py.in (FEDABIPKGDIFF_TEST_SPECS): Rename filename for test4. Add two new test cases. (run_fedabipkgdiff_tests): Remove semicolon and trailing whitespaces. (main): Likewise. (ensure_output_dir_created): Likewise. * tools/fedabipkgdiff: Require some new modules. Fix of return code. (PkgInfo): Renamed to ComparisonHalf. (match_nvr): New method to determine if a string matches format of N-V-R. (match_nvra): New method to determine if a string matches format of N-V-R.A. (is_rpm_file): New method to guess if a file is a RPM file. (RPM.is_peer): New method to determine if current RPM is a peer of another. (RPM.filename): Use Koji module API to construct the filename. (RPM.nvra): Get nvra from filename instead of constructing manually that is duplicated with Koji module API. (RPMCollection): New class to represent a set of RPMs. (generate_pkg_info_pair_for_abipkgdiff): New method working as a generator to yeild comparison halves for running abipkgdiff. (Brew.getRPM): Fix string format with incorrect argument. (Brew.select_rpms_from_a_build): Return instance of RPMCollection. (abipkgdiff): If there is no debuginfo or development package, just ignore it and leave a warning. If --error-on-warning is specified, raise an exception instead. Arguments are modified to represent the new name ComparisonHalf, and relative docstring is also updated. (magic_construct): Removed. (run_abipkgdiff): Rewrite. (make_rpms_usable_for_abipkgdiff): Removed. (diff_local_rpm_with_latest_rpm_from_koji): Rewrite by using RPMCollection. (diff_latest_rpms_based_on_distros): Likewise. (diff_two_nvras_from_koji): Likewise. (diff_from_two_rpm_files): New method to compare two local RPMs. (build_commandline_args_parser): Add new option --error-on-warning. (main): Add support to compare local RPMs. Signed-off-by: Chenxiong Qi <cqi@redhat.com> Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-08-11 13:48:00 +00:00
return result
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-05-30 14:11:31 +00:00
Make fedabipkgdiff consistent with Libabigail's other tests 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>
2016-07-06 09:51:13 +00:00
def main():
"""The main entry point of this program.
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-05-30 14:11:31 +00:00
Make fedabipkgdiff consistent with Libabigail's other tests 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>
2016-07-06 09:51:13 +00:00
This creates the output directory and launches the tests for the
fedabipkgdiff program.
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-05-30 14:11:31 +00:00
:return: 0 upon success, 1 otherwise.
Make fedabipkgdiff consistent with Libabigail's other tests 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>
2016-07-06 09:51:13 +00:00
"""
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-06 13:38:28 +00:00
Make fedabipkgdiff consistent with Libabigail's other tests 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>
2016-07-06 09:51:13 +00:00
ensure_output_dir_created()
Bug 20380 - Compare two local RPMs Bug 20270 is also fixed. This patch allows developer to compare two local RPMs in form fedabipkgdiff some/place/foo.rpm another/place/bar.rpm But, network is still needed to talk with Koji. This patch also introduces new terms for libabigail, that is the subject, ancillary package, and comparison half. Subject represents a package that is subject of the ABI comparison, a subject could be a RPM and maybe it would be a DEB or some other kind of "package". A subject may have several ancillary packages that are used to compare the subject. Generally, a subject may have devel, debuginfo, or both. * configure.ac: add dependent mimetype module. * doc/manuals/fedabipkgdiff.rst: Update to add document for the new use case of comparing two local RPMs. * tests/data/Makefile.am: Include new RPMs for tests. * tests/data/test-fedabipkgdiff/dbus-glib/dbus-glib-0.100.2-2.fc20.x86_64.rpm: New RPM for running test. * tests/data/test-fedabipkgdiff/dbus-glib/dbus-glib-0.106-1.fc23.x86_64.rpm: Likewise. * tests/data/test-fedabipkgdiff/nss-util/nss-util-3.12.6-1.fc14.x86_64.rpm: Likewise. * tests/data/test-fedabipkgdiff/nss-util/nss-util-3.24.0-2.0.fc25.x86_64.rpm: Likewise. * tests/data/test-fedabipkgdiff/nss-util/nss-util-devel-3.24.0-2.0.fc25.x86_64.rpm: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Rename filename by adding .rpm extension. * tests/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: New reference output for testing comparing local RPMs. * tests/data/test-fedabipkgdiff/test6-missing-devel-debuginfo-nss-util-3.12.6-1.fc14.x86_64--nss-util-3.24.0-2.0.fc25.x86_64-report-0.txt: New reference output for testing comparison without non-existent debuginfo or development package. * tests/runtestfedabipkgdiff.py.in (FEDABIPKGDIFF_TEST_SPECS): Rename filename for test4. Add two new test cases. (run_fedabipkgdiff_tests): Remove semicolon and trailing whitespaces. (main): Likewise. (ensure_output_dir_created): Likewise. * tools/fedabipkgdiff: Require some new modules. Fix of return code. (PkgInfo): Renamed to ComparisonHalf. (match_nvr): New method to determine if a string matches format of N-V-R. (match_nvra): New method to determine if a string matches format of N-V-R.A. (is_rpm_file): New method to guess if a file is a RPM file. (RPM.is_peer): New method to determine if current RPM is a peer of another. (RPM.filename): Use Koji module API to construct the filename. (RPM.nvra): Get nvra from filename instead of constructing manually that is duplicated with Koji module API. (RPMCollection): New class to represent a set of RPMs. (generate_pkg_info_pair_for_abipkgdiff): New method working as a generator to yeild comparison halves for running abipkgdiff. (Brew.getRPM): Fix string format with incorrect argument. (Brew.select_rpms_from_a_build): Return instance of RPMCollection. (abipkgdiff): If there is no debuginfo or development package, just ignore it and leave a warning. If --error-on-warning is specified, raise an exception instead. Arguments are modified to represent the new name ComparisonHalf, and relative docstring is also updated. (magic_construct): Removed. (run_abipkgdiff): Rewrite. (make_rpms_usable_for_abipkgdiff): Removed. (diff_local_rpm_with_latest_rpm_from_koji): Rewrite by using RPMCollection. (diff_latest_rpms_based_on_distros): Likewise. (diff_two_nvras_from_koji): Likewise. (diff_from_two_rpm_files): New method to compare two local RPMs. (build_commandline_args_parser): Add new option --error-on-warning. (main): Add support to compare local RPMs. Signed-off-by: Chenxiong Qi <cqi@redhat.com> Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-08-11 13:48:00 +00:00
result = 0
Make fedabipkgdiff consistent with Libabigail's other tests 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>
2016-07-06 09:51:13 +00:00
result = run_fedabipkgdiff_tests()
return not result
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-05-30 14:11:31 +00:00
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-02-09 10:05:33 +00:00
if __name__ == '__main__':
Make fedabipkgdiff consistent with Libabigail's other tests 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>
2016-07-06 09:51:13 +00:00
exit_code = main()
sys.exit(exit_code)