From 5c318c70d09a530a7bd89f973e931def0ba191a4 Mon Sep 17 00:00:00 2001 From: Ole Troan Date: Tue, 5 May 2020 12:23:47 +0200 Subject: vppapigen: api crc checker crcchecker is a tool for enforcement of the binary API. 1. Production APIs should never change. 2. An API can be deprecated across three release cycles. Release 1: API is marked as deprecated. option deprecated="vyy.mm"; option replaced_by="new_api_2"; Release 2: both old and new APIs are supported Release 3: the deprecated API is deleted. 3. APIs that are experimental / not released are not checked. An API message can be individually marked as in progress, by: option status="in_progress"; In the API definition. The definition of a "production API" is if the major version in the API file is > 0. extras/scripts/crcchecker.py --check-patchset # returns -1 if backwards incompatible extras/scripts/crcchecker.py --dump-manifest extras/scripts/crcchecker.py --git-revision v20.01 extras/scripts/crcchecker.py -- diff This patch integrates the tool in "make checkstyle-api". A future patch is required to integrate the tool in the verify job. I.e. this patch does not enable enforcement through Jenkins. Change-Id: I5f13c0976d8a12a58131b3e270f2dc9c00dc7d8c Type: feature Signed-off-by: Ole Troan --- extras/scripts/tests/test_crcchecker.sh | 140 ++++++++++++++++++++++++++++++++ 1 file changed, 140 insertions(+) create mode 100755 extras/scripts/tests/test_crcchecker.sh (limited to 'extras/scripts/tests') diff --git a/extras/scripts/tests/test_crcchecker.sh b/extras/scripts/tests/test_crcchecker.sh new file mode 100755 index 00000000000..7cfda086483 --- /dev/null +++ b/extras/scripts/tests/test_crcchecker.sh @@ -0,0 +1,140 @@ +#!/bin/sh +set -eux + +TMPDIR=$(mktemp -d /tmp/vpp-crccheck-test-XXXXX) + +CURR_ROOT=$(git rev-parse --show-toplevel) +CURR_DIR=$(pwd) + +verify_check_patchset_fails() { + if (extras/scripts/crcchecker.py --check-patchset); then + echo "ERROR - check succeeded, it should have failed!" + exit 1; + fi +} + +finish() { + if [ -e "$TMPDIR" ]; then + echo "Temporary directory is: $TMPDIR" + fi +} +trap finish EXIT + + +# make a copy of the current repo that we can play with +cd ${TMPDIR} +mkdir misc-files +git clone ${CURR_ROOT} vpp-uut +cd vpp-uut + +# maybe grab the CRC checker +# git fetch "https://gerrit.fd.io/r/vpp" refs/changes/81/26881/14 && git cherry-pick FETCH_HEAD || echo "Already there" + + +echo "TEST 1: Check the current patchset..." +extras/scripts/crcchecker.py --check-patchset + +echo "TEST 2: Dumping the current manifest..." +extras/scripts/crcchecker.py --dump-manifest >${TMPDIR}/misc-files/manifest.txt + +echo "TEST 3: Checking the 20.01 version of acl.api...." +extras/scripts/crcchecker.py --git-revision v20.01 src/plugins/acl/acl.api + +echo "TEST 4: Add a new field into a message in acl.api, and check patchset - must fail..." +sed -i -e 's#vpe_pid;#vpe_pid; u32 sneaky_new_field;#' src/plugins/acl/acl.api +verify_check_patchset_fails + +echo "TEST 5: Rename the changed acl.api file and not add it to git... must fail (due to deletion of the APIs)..." +mv src/plugins/acl/acl.api src/plugins/acl/acl_new.api +verify_check_patchset_fails + +echo "TEST 6: Add the renamed file to git commit... must fail (due to addition of the fields)..." +git add src/plugins/acl/acl_new.api +git commit -m "added acl_new.api" +verify_check_patchset_fails + +echo "TEST 7: Verify we can delete deprecated message" +git commit -a -m "reset" +cat >crccheck.api <crccheck.api <>crccheck.api <crccheck2.api <