]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Add API Checker
authorMichal Nowak <mnowak@isc.org>
Wed, 26 Feb 2020 10:24:45 +0000 (11:24 +0100)
committerMichal Nowak <mnowak@isc.org>
Tue, 10 Mar 2020 08:59:22 +0000 (09:59 +0100)
ABI checker tools generate HTML and TXT API compatibility reports of
BIND libraries. Comparison is being done between two bind source trees
which hold built BIND.

In the CI one version is the reference version defined by
BIND_BASELINE_VERSION variable, the latter one is the HEAD of branch
under test.

(cherry picked from commit 49bc08e612c47e988e3a6c04d1439d55057555bc)

.gitlab-ci.yml
util/api-checker.sh [new file with mode: 0755]
util/copyrights

index 797ef5b16ed31ad7c3a6e457760114ca28a77bab..2dc3f2460c70799ac586082b6657380c879cc159 100644 (file)
@@ -1201,3 +1201,34 @@ respdiff:sid:amd64:
     untracked: true
     expire_in: "1 day"
     when: on_failure
+
+# ABI check
+
+abi-check:sid:amd64:
+  <<: *debian_sid_amd64_image
+  stage: build
+  dependencies:
+    - autoreconf:sid:amd64
+  needs:
+    - autoreconf:sid:amd64
+  variables:
+    CC: gcc
+    CFLAGS: "${CFLAGS_COMMON} -Og"
+    BIND_BASELINE_VERSION: v9_11_16
+  script:
+    - *configure
+    - ${MAKE} -j${BUILD_PARALLEL_JOBS:-1} V=1
+    - git clone --branch "${BIND_BASELINE_VERSION}" --depth 1 https://gitlab.isc.org/isc-projects/bind9.git refbind
+    - cd refbind/
+    - *configure
+    - ${MAKE} -j${BUILD_PARALLEL_JOBS:-1} V=1
+    - cd ..
+    - util/api-checker.sh . refbind
+  artifacts:
+    paths:
+      - "*.html"
+      - "abi-*.dump"
+    expire_in: "1 week"
+  only:
+    - master@isc-projects/bind9
+    - /^v9_[1-9][0-9]$/@isc-projects/bind9
diff --git a/util/api-checker.sh b/util/api-checker.sh
new file mode 100755 (executable)
index 0000000..a424234
--- /dev/null
@@ -0,0 +1,83 @@
+#!/bin/bash
+#
+# Copyright (C) Internet Systems Consortium, Inc. ("ISC")
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+# See the COPYRIGHT file distributed with this work for additional
+# information regarding copyright ownership.
+
+set -e
+
+# Exit if program $1 is not found in PATH.
+check_program() {
+       if ! command -v "${1}" > /dev/null 2>&1; then
+               echo "'${1}' not found in PATH" >&2
+               exit 1
+       fi
+}
+
+# Check that we were spawned with two arguments and that these arguments are two
+# different directories.
+check_args() {
+       if [ ${#} -ne 2 ] || [ ! -d "${1}" ] || [ ! -d "${2}" ] || [ "${1}" = "${2}" ]; then
+               echo "Usage:"
+               echo ""
+               echo "  ${0} <TESTDIR> <REFDIR>"
+               echo ""
+               echo "Generate API compatibility reports for BIND libraries."
+               echo ""
+               echo "  <TESTDIR> is a directory with current (new) BIND version"
+               echo "  <REFDIR> is a directory with reference (old) BIND version"
+               exit 1
+       fi
+}
+
+check_args "${@}"
+TESTBIND="${1}"
+REFBIND="${2}"
+
+# Ensure the required tools are available in PATH.
+check_program abi-dumper
+check_program abi-compliance-checker
+check_program git
+check_program w3m
+
+# Find all libraries which have designated 'api' file and
+# generate ABI dump file for them.
+while read -r SO; do
+       APIFILE="$(dirname "${SO}")/../api"
+       pushd "$(dirname "${APIFILE}")"
+       GIT_REVISION=$(git rev-parse HEAD | cut -c 1-10)
+       popd
+       # Get LIBINTERFACE, LIBREVISION, LIBAGE from the 'api' file.
+       eval "$(grep -v "^#" "${APIFILE}" | tr -d " ")"
+       VERSION="${LIBINTERFACE}.${LIBREVISION}.${LIBAGE}-${GIT_REVISION}"
+       abi-dumper "${SO}" -o abi-"$(basename "${SO}" .so)-${VERSION}".dump -lver "${VERSION}"
+done < <(find "${TESTBIND}"/lib/*/.libs/ "${REFBIND}"/lib/*/.libs/ -name '*.so')
+
+# Generate HTML API compatibility reports for all libraries.
+find . -maxdepth 1 -name 'abi-*.dump' | sort | while read -r OLD; read -r NEW; do
+       SONAME=${OLD/.\/abi-/}
+       SONAME=${SONAME/-*/}
+       if abi-compliance-checker -l "${SONAME}" -old "${OLD}" -new "${NEW}"; then
+               REPORT_PREFIX="PASS"
+       else
+               echo "***** Compatibility problems detected"
+               REPORT_PREFIX="WARN"
+       fi
+       OLD_REPORT_PATH="$(find "compat_reports/${SONAME}" -name '*.html')"
+       NEW_REPORT_PATH="${REPORT_PREFIX}-${SONAME}.html"
+       mv "${OLD_REPORT_PATH}" "${NEW_REPORT_PATH}"
+       echo
+done
+
+# Generate TXT API compatibility reports from HTML reports for all BIND libraries.
+echo "Generate TXT API compatibility reports from HTML reports for all BIND libraries:"
+while read -r HTMLREPORT; do
+       TXTREPORT="${HTMLREPORT/.html/.txt}"
+       echo "  w3m: ${HTMLREPORT} -> ${TXTREPORT}"
+       w3m -dump -cols 75 -O ascii -T text/html "${HTMLREPORT}" > "${TXTREPORT}"
+done < <(find . -maxdepth 1 -name '*.html')
index 8b610b632b6e02ca1c24a1985f029526054be99f..6007f8b9ef4989aee6415802fb8ec9b9a30ee5b3 100644 (file)
 ./util/COPYRIGHT.PORTION                       X       1996,1997,1998,1999,2000,2001,2004,2007,2016,2018,2019,2020
 ./util/COPYRIGHT.TOP                           X       2018,2019,2020
 ./util/altbuild.sh                             SH      2000,2001,2002,2004,2007,2008,2012,2016,2018,2019,2020
+./util/api-checker.sh                          SH      2020
 ./util/bindkeys.pl                             PERL    2009,2010,2011,2012,2014,2016,2017,2018,2019,2020
 ./util/branchsync.sh                           SH      2013,2016,2018,2019,2020
 ./util/check-ans-prereq.sh                     SH      2019,2020