]> git.proxmox.com Git - ceph.git/blame - ceph/src/dpdk/scripts/validate-abi.sh
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / dpdk / scripts / validate-abi.sh
CommitLineData
7c673cae
FG
1#!/bin/sh
2# BSD LICENSE
3#
4# Copyright(c) 2015 Neil Horman. All rights reserved.
5# All rights reserved.
6#
7# Redistribution and use in source and binary forms, with or without
8# modification, are permitted provided that the following conditions
9# are met:
10#
11# * Redistributions of source code must retain the above copyright
12# notice, this list of conditions and the following disclaimer.
13# * Redistributions in binary form must reproduce the above copyright
14# notice, this list of conditions and the following disclaimer in
15# the documentation and/or other materials provided with the
16# distribution.
17#
18# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
30TAG1=$1
31TAG2=$2
32TARGET=$3
33ABI_DIR=`mktemp -d -p /tmp ABI.XXXXXX`
34
35usage() {
36 echo "$0 <REV1> <REV2> <TARGET>"
37}
38
39log() {
40 local level=$1
41 shift
42 echo "$*"
43}
44
45validate_tags() {
46
47 if [ -z "$HASH1" ]
48 then
49 echo "invalid revision: $TAG1"
50 return
51 fi
52 if [ -z "$HASH2" ]
53 then
54 echo "invalid revision: $TAG2"
55 return
56 fi
57}
58
59validate_args() {
60 if [ -z "$TAG1" ]
61 then
62 echo "Must Specify REV1"
63 return
64 fi
65 if [ -z "$TAG2" ]
66 then
67 echo "Must Specify REV2"
68 return
69 fi
70 if [ -z "$TARGET" ]
71 then
72 echo "Must Specify a build target"
73 fi
74}
75
76
77cleanup_and_exit() {
78 rm -rf $ABI_DIR
79 git checkout $CURRENT_BRANCH
80 exit $1
81}
82
83# Make sure we configure SHARED libraries
84# Also turn off IGB and KNI as those require kernel headers to build
85fixup_config() {
86 sed -i -e"$ a\CONFIG_RTE_BUILD_SHARED_LIB=y" config/defconfig_$TARGET
87 sed -i -e"$ a\CONFIG_RTE_NEXT_ABI=n" config/defconfig_$TARGET
88 sed -i -e"$ a\CONFIG_RTE_EAL_IGB_UIO=n" config/defconfig_$TARGET
89 sed -i -e"$ a\CONFIG_RTE_LIBRTE_KNI=n" config/defconfig_$TARGET
90 sed -i -e"$ a\CONFIG_RTE_KNI_KMOD=n" config/defconfig_$TARGET
91}
92
93###########################################
94#START
95############################################
96
97#trap on ctrl-c to clean up
98trap cleanup_and_exit SIGINT
99
100if [ -z "$DPDK_MAKE_JOBS" ]
101then
102 # This counts the number of cpus on the system
103 if [ -e /usr/bin/lscpu ]
104 then
105 DPDK_MAKE_JOBS=`lscpu -p=cpu | grep -v "#" | wc -l`
106 else
107 DPDK_MAKE_JOBS=1
108 fi
109fi
110
111#Save the current branch
112CURRENT_BRANCH=`git branch | grep \* | cut -d' ' -f2`
113
114if [ -z "$CURRENT_BRANCH" ]
115then
116 CURRENT_BRANCH=`git log --pretty=format:%H HEAD~1..HEAD`
117fi
118
119if [ -n "$VERBOSE" ]
120then
121 export VERBOSE=/dev/stdout
122else
123 export VERBOSE=/dev/null
124fi
125
126# Validate that we have all the arguments we need
127res=$(validate_args)
128if [ -n "$res" ]
129then
130 echo $res
131 usage
132 cleanup_and_exit 1
133fi
134
135HASH1=$(git show -s --format=%H "$TAG1" -- 2> /dev/null | tail -1)
136HASH2=$(git show -s --format=%H "$TAG2" -- 2> /dev/null | tail -1)
137
138# Make sure our tags exist
139res=$(validate_tags)
140if [ -n "$res" ]
141then
142 echo $res
143 cleanup_and_exit 1
144fi
145
146# Make hashes available in output for non-local reference
147TAG1="$TAG1 ($HASH1)"
148TAG2="$TAG2 ($HASH2)"
149
150ABICHECK=`which abi-compliance-checker 2>/dev/null`
151if [ $? -ne 0 ]
152then
153 log "INFO" "Cant find abi-compliance-checker utility"
154 cleanup_and_exit 1
155fi
156
157ABIDUMP=`which abi-dumper 2>/dev/null`
158if [ $? -ne 0 ]
159then
160 log "INFO" "Cant find abi-dumper utility"
161 cleanup_and_exit 1
162fi
163
164log "INFO" "We're going to check and make sure that applications built"
165log "INFO" "against DPDK DSOs from version $TAG1 will still run when executed"
166log "INFO" "against DPDK DSOs built from version $TAG2."
167log "INFO" ""
168
169# Check to make sure we have a clean tree
170git status | grep -q clean
171if [ $? -ne 0 ]
172then
173 log "WARN" "Working directory not clean, aborting"
174 cleanup_and_exit 1
175fi
176
177# Move to the root of the git tree
178cd $(dirname $0)/..
179
180log "INFO" "Checking out version $TAG1 of the dpdk"
181# Move to the old version of the tree
182git checkout $HASH1
183
184fixup_config
185
186# Checking abi compliance relies on using the dwarf information in
187# The shared objects. Thats only included in the DSO's if we build
188# with -g
189export EXTRA_CFLAGS="$EXTRA_CFLAGS -g -O0"
190export EXTRA_LDFLAGS="$EXTRA_LDFLAGS -g"
191
192# Now configure the build
193log "INFO" "Configuring DPDK $TAG1"
194make config T=$TARGET O=$TARGET > $VERBOSE 2>&1
195
196log "INFO" "Building DPDK $TAG1. This might take a moment"
197make -j$DPDK_MAKE_JOBS O=$TARGET > $VERBOSE 2>&1
198
199if [ $? -ne 0 ]
200then
201 log "INFO" "THE BUILD FAILED. ABORTING"
202 cleanup_and_exit 1
203fi
204
205# Move to the lib directory
206cd $TARGET/lib
207log "INFO" "COLLECTING ABI INFORMATION FOR $TAG1"
208for i in `ls *.so`
209do
210 $ABIDUMP $i -o $ABI_DIR/$i-ABI-0.dump -lver $HASH1
211done
212cd ../..
213
214# Now clean the tree, checkout the second tag, and rebuild
215git clean -f -d
216git reset --hard
217# Move to the new version of the tree
218log "INFO" "Checking out version $TAG2 of the dpdk"
219git checkout $HASH2
220
221fixup_config
222
223# Now configure the build
224log "INFO" "Configuring DPDK $TAG2"
225make config T=$TARGET O=$TARGET > $VERBOSE 2>&1
226
227log "INFO" "Building DPDK $TAG2. This might take a moment"
228make -j$DPDK_MAKE_JOBS O=$TARGET > $VERBOSE 2>&1
229
230if [ $? -ne 0 ]
231then
232 log "INFO" "THE BUILD FAILED. ABORTING"
233 cleanup_and_exit 1
234fi
235
236cd $TARGET/lib
237log "INFO" "COLLECTING ABI INFORMATION FOR $TAG2"
238for i in `ls *.so`
239do
240 $ABIDUMP $i -o $ABI_DIR/$i-ABI-1.dump -lver $HASH2
241done
242cd ../..
243
244# Start comparison of ABI dumps
245for i in `ls $ABI_DIR/*-1.dump`
246do
247 NEWNAME=`basename $i`
248 OLDNAME=`basename $i | sed -e"s/1.dump/0.dump/"`
249 LIBNAME=`basename $i | sed -e"s/-ABI-1.dump//"`
250
251 if [ ! -f $ABI_DIR/$OLDNAME ]
252 then
253 log "INFO" "$OLDNAME DOES NOT EXIST IN $TAG1. SKIPPING..."
254 fi
255
256 #compare the abi dumps
257 $ABICHECK -l $LIBNAME -old $ABI_DIR/$OLDNAME -new $ABI_DIR/$NEWNAME
258done
259
260git reset --hard
261log "INFO" "ABI CHECK COMPLETE. REPORTS ARE IN compat_report directory"
262cleanup_and_exit 0