dd9120e69e151d0de8bc4f933fb7ab7184a40363
[dpdk.git] / devtools / check-abi.sh
1 #!/bin/sh -e
2 # SPDX-License-Identifier: BSD-3-Clause
3 # Copyright (c) 2019 Red Hat, Inc.
4
5 if [ $# != 2 ] && [ $# != 3 ]; then
6         echo "Usage: $0 refdir newdir [warnonly]"
7         exit 1
8 fi
9
10 refdir=$1
11 newdir=$2
12 warnonly=${3:-}
13 ABIDIFF_OPTIONS="--suppr $(dirname $0)/libabigail.abignore --no-added-syms"
14
15 if [ ! -d $refdir ]; then
16         echo "Error: reference directory '$refdir' does not exist."
17         exit 1
18 fi
19 incdir=$(find $refdir -type d -a -name include)
20 if [ -z "$incdir" ] || [ ! -e "$incdir" ]; then
21         echo "WARNING: could not identify a include directory for $refdir, expect false positives..."
22 else
23         ABIDIFF_OPTIONS="$ABIDIFF_OPTIONS --headers-dir1 $incdir"
24 fi
25
26 if [ ! -d $newdir ]; then
27         echo "Error: directory to check '$newdir' does not exist."
28         exit 1
29 fi
30 incdir2=$(find $newdir -type d -a -name include)
31 if [ -z "$incdir2" ] || [ ! -e "$incdir2" ]; then
32         echo "WARNING: could not identify a include directory for $newdir, expect false positives..."
33 else
34         ABIDIFF_OPTIONS="$ABIDIFF_OPTIONS --headers-dir2 $incdir2"
35 fi
36
37 error=
38 for dump in $(find $refdir -name "*.dump"); do
39         name=$(basename $dump)
40         # skip glue drivers, example librte_pmd_mlx5_glue.dump
41         # We can't rely on a suppression rule for now:
42         # https://sourceware.org/bugzilla/show_bug.cgi?id=25480
43         if grep -qE "\<soname='[^']*_glue\.so\.[^']*'" $dump; then
44                 echo "Skipped glue library $name."
45                 continue
46         fi
47         # skip experimental libraries, with a sover starting with 0.
48         if grep -qE "\<soname='[^']*\.so\.0\.[^']*'" $dump; then
49                 echo "Skipped experimental library $name."
50                 continue
51         fi
52         dump2=$(find $newdir -name $name)
53         if [ -z "$dump2" ] || [ ! -e "$dump2" ]; then
54                 echo "Error: can't find $name in $newdir"
55                 error=1
56                 continue
57         fi
58         if ! abidiff $ABIDIFF_OPTIONS $dump $dump2; then
59                 echo "Error: ABI issue reported for 'abidiff $ABIDIFF_OPTIONS $dump $dump2'"
60                 error=1
61         fi
62 done
63
64 [ -z "$error" ] || [ -n "$warnonly" ]