From 9d954275940c40ddee8b612d259f341bb2b01987 Mon Sep 17 00:00:00 2001 From: Kamil Godzwon Date: Tue, 23 Aug 2022 11:18:34 -0400 Subject: [PATCH] test/check_so_deps: compare xml representations of the so files Right now for ABI tests, the abidiff tool requires a reference .so files matching the SPDK version that is being compared to. For example patches on master are compared to .so files build from last SPDK release. This requires continuous maintenance and backports to the prior release branches, to keep new VM images buildable. Since ABI tests should be done only against specific release (git tags) rather than tip of the branches, this would mean to address it properly the VM image and point releases would need to be synchronized. To avoid that, we can switch from using the .so files to their text (XML) representation generated at the time of the release. The XML representation of the SO files will be kept in the separate repository "spdk-abi" and cloning during "confirm_abi_deps()" test. Signed-off-by: Kamil Godzwon Change-Id: I37b4c556e8f8ffb5ffd67e16df9f186ef9c52294 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/14160 Tested-by: SPDK CI Jenkins Reviewed-by: Tomasz Zawadzki Reviewed-by: Pawel Piatek Reviewed-by: Konrad Sztyber --- test/make/check_so_deps.sh | 50 +++++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 20 deletions(-) diff --git a/test/make/check_so_deps.sh b/test/make/check_so_deps.sh index 18413e46d..ab70a12df 100755 --- a/test/make/check_so_deps.sh +++ b/test/make/check_so_deps.sh @@ -1,8 +1,25 @@ #!/usr/bin/env bash shopt -s extglob +git_repo_abi="https://github.com/spdk/spdk-abi.git" -function get_git_tag() { - git -C "${1:-$rootdir}" describe --tags --abbrev=0 --exclude=LTS +function get_spdk_abi() { + local dest=$1 + mkdir -p $dest + if [[ -d $SPDK_ABI_DIR ]]; then + echo "spdk-abi found at $SPDK_ABI_DIR" + cp -r "$SPDK_ABI_DIR"/* "$dest/" + else + # In case that someone run test manually and did not set existing + # spdk-abi directory via SPDK_ABI_DIR + echo "spdk-abi has not been found at $SPDK_ABI_DIR, cloning" + git clone $git_repo_abi "$dest" + fi +} + +function get_release_branch() { + tag=$(git describe --tags --abbrev=0 --exclude=LTS --exclude=*-pre) + branch="${tag:0:6}.x" + echo "$branch" } if [ "$(uname -s)" = "FreeBSD" ]; then @@ -24,14 +41,6 @@ libdir="$rootdir/build/lib" libdeps_file="$rootdir/mk/spdk.lib_deps.mk" suppression_file="$HOME/abigail_suppressions.ini" -spdk_tag=$(get_git_tag) -spdk_lts_tag=$(get_git_tag "$HOME/spdk_abi_lts") -repo="spdk_abi_latest" -if [[ "$spdk_tag" == "$spdk_lts_tag" ]]; then - repo="spdk_abi_lts" -fi -source_abi_dir="$HOME/$repo/build/lib" - function check_header_filenames() { local dups_found=0 @@ -60,19 +69,19 @@ function check_header_filenames() { function confirm_abi_deps() { local processed_so=0 local abidiff_output + local release + local source_abi_dir="$rootdir/test/make/abi" - echo "* Running ${FUNCNAME[0]} against $repo" >&2 + release=$(get_release_branch) + + get_spdk_abi "$source_abi_dir" + echo "* Running ${FUNCNAME[0]} against the latest (${release%.*}) release" >&2 if ! hash abidiff; then echo "Unable to check ABI compatibility. Please install abidiff." return 1 fi - if [ ! -d $source_abi_dir ]; then - echo "No source ABI available, failing this test." - return 1 - fi - cat << EOF > ${suppression_file} [suppress_type] name = spdk_nvme_power_state @@ -92,14 +101,14 @@ EOF abidiff_output=0 so_file=$(basename $object) - if [ ! -f "$source_abi_dir/$so_file" ]; then + if [ ! -f "$source_abi_dir/$release/$so_file" ]; then echo "No corresponding object for $so_file in canonical directory. Skipping." continue fi cmd_args=('abidiff' - $source_abi_dir/$so_file $libdir/$so_file - '--headers-dir1' $source_abi_dir/../../include + $source_abi_dir/$release/$so_file "$libdir/$so_file" + '--headers-dir1' $source_abi_dir/$release/include '--headers-dir2' $rootdir/include '--leaf-changes-only' '--suppressions' $suppression_file) @@ -108,7 +117,7 @@ EOF output=$(sed "s/ [()][^)]*[)]//g" <<< "$output") IFS="." read -r _ _ new_so_maj new_so_min < <(readlink "$libdir/$so_file") - IFS="." read -r _ _ old_so_maj old_so_min < <(readlink "$source_abi_dir/$so_file") + IFS="." read -r _ _ old_so_maj old_so_min < <(readlink "$source_abi_dir/$release/$so_file") found_abi_change=false so_name_changed=no @@ -200,6 +209,7 @@ EOF done rm -f $suppression_file echo "Processed $processed_so objects." + rm -rf "$source_abi_dir" } function get_lib_shortname() {