Add --self-compare option in fedabipkgdiff
authorSinny Kumari <sinny@redhat.com>
Sun, 21 May 2017 09:40:12 +0000 (15:10 +0530)
committerSinny Kumari <sinny@redhat.com>
Wed, 31 May 2017 10:51:14 +0000 (16:21 +0530)
fedabipkgdiff tool can communicate with Fedora koji and has
capability to download and perform ABI comparison between
specified NVRs.

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

* bash-completion/fedabipkgdiff: Add new option --self-compare
* tests/data/Makefile.am: Add new test file
* tests/data/test-fedabipkgdiff/test7-self-compare-from-fc23-dbus-glib-report-0.txt:
New reference output for testing ABI comparison on same package
* tests/runtestfedabipkgdiff.py.in (FEDABIPKGDIFF_TEST_SPECS):
Add test case for --self-compare
* tools/fedabipkgdiff (build_commandline_args_parser()): Add
new option --self-compare
(generate_comparison_halves()): Find second comparision half in same
package list while doing self-compare
(self_compare_rpms_from_distro()): New function to perform ABI
comparision on same pacakge
(main()): Add if condition when --self-compare option is enabled

bash-completion/fedabipkgdiff
tests/data/Makefile.am
tests/data/test-fedabipkgdiff/test7-self-compare-from-fc23-dbus-glib-report-0.txt [new file with mode: 0644]
tests/runtestfedabipkgdiff.py.in
tools/fedabipkgdiff

index 789d9901af963532a32067f09893b186efe8ad85..d074419f397f2e118aa81656eaa9bcec220dd7da 100644 (file)
@@ -19,7 +19,8 @@ _fedabipkgdiff_module()
                     --abipkgdiff
                     --clean-cache
                     --clean-cache-before
-                    --clean-cache-after"
+                    --clean-cache-after
+                    --self-compare"
            COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
            return 0
            ;;
index 47c91a6abc11f11e3c3345ecc66ed65dc444b311..3be5ab789ee17bcdaa8a4c5e5b0caeb59aa4cd60 100644 (file)
@@ -1294,6 +1294,7 @@ test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i
 test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt \
 test-fedabipkgdiff/test5-same-dir-dbus-glib-0.100.2-2.fc20.x86_64--dbus-glib-0.106-1.fc23.x86_64-report-0.txt \
 test-fedabipkgdiff/test6-nss-util-3.12.6-1.fc14.x86_64--nss-util-3.24.0-2.0.fc25.x86_64-report-0.txt \
+test-fedabipkgdiff/test7-self-compare-from-fc23-dbus-glib-report-0.txt \
 test-fedabipkgdiff/packages/dbus-glib/0.100.2/2.fc20/i686/dbus-glib-0.100.2-2.fc20.i686.rpm \
 test-fedabipkgdiff/packages/dbus-glib/0.100.2/2.fc20/i686/dbus-glib-debuginfo-0.100.2-2.fc20.i686.rpm \
 test-fedabipkgdiff/packages/dbus-glib/0.100.2/2.fc20/i686/dbus-glib-devel-0.100.2-2.fc20.i686.rpm \
diff --git a/tests/data/test-fedabipkgdiff/test7-self-compare-from-fc23-dbus-glib-report-0.txt b/tests/data/test-fedabipkgdiff/test7-self-compare-from-fc23-dbus-glib-report-0.txt
new file mode 100644 (file)
index 0000000..63a6dca
--- /dev/null
@@ -0,0 +1,12 @@
+Comparing the ABI of binaries between dbus-glib-0.106-1.fc23.i686.rpm and dbus-glib-0.106-1.fc23.i686.rpm:
+
+
+Comparing the ABI of binaries between dbus-glib-devel-0.106-1.fc23.i686.rpm and dbus-glib-devel-0.106-1.fc23.i686.rpm:
+
+
+Comparing the ABI of binaries between dbus-glib-0.106-1.fc23.x86_64.rpm and dbus-glib-0.106-1.fc23.x86_64.rpm:
+
+
+Comparing the ABI of binaries between dbus-glib-devel-0.106-1.fc23.x86_64.rpm and dbus-glib-devel-0.106-1.fc23.x86_64.rpm:
+
+
index 0ac054a99845918d82a2f189e8c7ae344386f0b2..78898f3cae9f51de6916b85fc9878436d92d4919 100755 (executable)
@@ -91,6 +91,10 @@ FEDABIPKGDIFF_TEST_SPECS = [
       os.path.join(INPUT_DIR, 'nss-util/nss-util-3.24.0-2.0.fc25.x86_64.rpm')],
      'data/test-fedabipkgdiff/test6-nss-util-3.12.6-1.fc14.x86_64--nss-util-3.24.0-2.0.fc25.x86_64-report-0.txt',
      'output/test-fedabipkgdiff/test6-nss-util-3.12.6-1.fc14.x86_64--nss-util-3.24.0-2.0.fc25.x86_64-report-0.txt'),
+
+    (['--self-compare', '-a', '--from', 'fc23', 'dbus-glib'],
+     'data/test-fedabipkgdiff/test7-self-compare-from-fc23-dbus-glib-report-0.txt',
+     'output/test-fedabipkgdiff/test7-self-compare-from-fc23-dbus-glib-report-0.txt'),
 ]
 
 
index 15145d352db574aa46de86e2c1618b868a6ac508..a8329d45763f16c8d4bf93b875040866bc2404f4 100755 (executable)
@@ -528,16 +528,23 @@ def generate_comparison_halves(rpm_col1, rpm_col2):
         if _rpm.is_devel and not global_config.check_all_subpackages:
             continue
 
-        rpm2 = rpm_col2.get_peer_rpm(_rpm)
-        if rpm2 is None:
-            logger.warning('Peer RPM of {0} is not found.'.format(_rpm.filename))
-            continue
+        if global_config.self_compare:
+            rpm2 = _rpm
+        else:
+            rpm2 = rpm_col2.get_peer_rpm(_rpm)
+            if rpm2 is None:
+                logger.warning('Peer RPM of {0} is not found.'.format(_rpm.filename))
+                continue
 
         debuginfo1 = rpm_col1.get_sibling_debuginfo(_rpm)
         devel1 = rpm_col1.get_sibling_devel(_rpm)
 
-        debuginfo2 = rpm_col2.get_sibling_debuginfo(rpm2)
-        devel2 = rpm_col2.get_sibling_devel(rpm2)
+        if global_config.self_compare:
+            debuginfo2 = debuginfo1
+            devel2 = devel1
+        else:
+            debuginfo2 = rpm_col2.get_sibling_debuginfo(rpm2)
+            devel2 = rpm_col2.get_sibling_devel(rpm2)
 
         yield (ComparisonHalf(subject=_rpm,
                               ancillary_debug=debuginfo1,
@@ -1205,6 +1212,40 @@ def diff_two_nvras_from_koji():
     return result
 
 
+@log_call
+def self_compare_rpms_from_distro():
+    """Compare ABI between same package from a distro
+
+    Doing ABI comparison on self package should return no
+    ABI change and hence return code should be 0. This is useful
+    to ensure that functionality of libabigail itself
+    didn't break. This utility can be invoked like this:
+
+    fedabipkgdiff --self-compare -a --from fc25 foo
+    """
+
+    from_distro = global_config.from_distro
+
+    if not is_distro_valid(from_distro):
+        raise InvalidDistroError('Invalid distro {0}'.format(from_distro))
+
+    package_name = global_config.NVR[0]
+
+    rpm_col1 = session.get_latest_built_rpms(package_name,
+                                             distro=global_config.from_distro)
+
+    if global_config.clean_cache_before:
+        delete_download_cache()
+
+    download_rpms(rpm_col1.rpms_iter())
+    result = run_abipkgdiff(rpm_col1, rpm_col1)
+
+    if global_config.clean_cache_after:
+        delete_download_cache()
+
+    return result
+
+
 @log_call
 def diff_from_two_rpm_files(from_rpm_file, to_rpm_file):
     """Diff two RPM files"""
@@ -1345,6 +1386,13 @@ def build_commandline_args_parser():
         dest='clean_cache_after',
         default=None,
         help='Clean cache after ABI comparison')
+    parser.add_argument(
+        '--self-compare',
+        required=False,
+        action='store_true',
+        dest='self_compare',
+        default=None,
+        help='ABI comparison on same package')
     return parser
 
 
@@ -1367,6 +1415,10 @@ def main():
 
     logger.debug(args)
 
+    if global_config.from_distro and global_config.self_compare and \
+            global_config.NVR:
+        return self_compare_rpms_from_distro()
+
     if global_config.from_distro and global_config.to_distro is None and \
             global_config.NVR:
         return diff_local_rpm_with_latest_rpm_from_koji()