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 <kamilx.godzwon@intel.com>
Change-Id: I37b4c556e8f8ffb5ffd67e16df9f186ef9c52294
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/14160
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Pawel Piatek <pawelx.piatek@intel.com>
Reviewed-by: Konrad Sztyber <konrad.sztyber@intel.com>
This commit is contained in:
Kamil Godzwon 2022-08-23 11:18:34 -04:00 committed by Tomasz Zawadzki
parent 1d2700d4c1
commit 9d95427594

View File

@ -1,8 +1,25 @@
#!/usr/bin/env bash #!/usr/bin/env bash
shopt -s extglob shopt -s extglob
git_repo_abi="https://github.com/spdk/spdk-abi.git"
function get_git_tag() { function get_spdk_abi() {
git -C "${1:-$rootdir}" describe --tags --abbrev=0 --exclude=LTS 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 if [ "$(uname -s)" = "FreeBSD" ]; then
@ -24,14 +41,6 @@ libdir="$rootdir/build/lib"
libdeps_file="$rootdir/mk/spdk.lib_deps.mk" libdeps_file="$rootdir/mk/spdk.lib_deps.mk"
suppression_file="$HOME/abigail_suppressions.ini" 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() { function check_header_filenames() {
local dups_found=0 local dups_found=0
@ -60,19 +69,19 @@ function check_header_filenames() {
function confirm_abi_deps() { function confirm_abi_deps() {
local processed_so=0 local processed_so=0
local abidiff_output 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 if ! hash abidiff; then
echo "Unable to check ABI compatibility. Please install abidiff." echo "Unable to check ABI compatibility. Please install abidiff."
return 1 return 1
fi fi
if [ ! -d $source_abi_dir ]; then
echo "No source ABI available, failing this test."
return 1
fi
cat << EOF > ${suppression_file} cat << EOF > ${suppression_file}
[suppress_type] [suppress_type]
name = spdk_nvme_power_state name = spdk_nvme_power_state
@ -92,14 +101,14 @@ EOF
abidiff_output=0 abidiff_output=0
so_file=$(basename $object) 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." echo "No corresponding object for $so_file in canonical directory. Skipping."
continue continue
fi fi
cmd_args=('abidiff' cmd_args=('abidiff'
$source_abi_dir/$so_file $libdir/$so_file $source_abi_dir/$release/$so_file "$libdir/$so_file"
'--headers-dir1' $source_abi_dir/../../include '--headers-dir1' $source_abi_dir/$release/include
'--headers-dir2' $rootdir/include '--headers-dir2' $rootdir/include
'--leaf-changes-only' '--suppressions' $suppression_file) '--leaf-changes-only' '--suppressions' $suppression_file)
@ -108,7 +117,7 @@ EOF
output=$(sed "s/ [()][^)]*[)]//g" <<< "$output") output=$(sed "s/ [()][^)]*[)]//g" <<< "$output")
IFS="." read -r _ _ new_so_maj new_so_min < <(readlink "$libdir/$so_file") 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 found_abi_change=false
so_name_changed=no so_name_changed=no
@ -200,6 +209,7 @@ EOF
done done
rm -f $suppression_file rm -f $suppression_file
echo "Processed $processed_so objects." echo "Processed $processed_so objects."
rm -rf "$source_abi_dir"
} }
function get_lib_shortname() { function get_lib_shortname() {