app/testpmd: add description of queue info command
[dpdk.git] / scripts / validate-abi.sh
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
30 TAG1=$1
31 TAG2=$2
32 TARGET=$3
33 ABI_DIR=`mktemp -d -p /tmp ABI.XXXXXX`
34
35 usage() {
36         echo "$0 <TAG1> <TAG2> <TARGET>"
37 }
38
39 log() {
40         local level=$1
41         shift
42         echo "$*"
43 }
44
45 validate_tags() {
46         git tag -l | grep -q "$TAG1"
47         if [ $? -ne 0 ]
48         then
49                 echo "$TAG1 is invalid"
50                 return
51         fi
52         git tag -l | grep -q "$TAG2"
53         if [ $? -ne 0 ]
54         then
55                 echo "$TAG2 is invalid"
56                 return
57         fi
58 }
59
60 validate_args() {
61         if [ -z "$TAG1" ]
62         then
63                 echo "Must Specify TAG1"
64                 return
65         fi
66         if [ -z "$TAG2" ]
67         then
68                 echo "Must Specify TAG2"
69                 return
70         fi
71         if [ -z "$TARGET" ]
72         then
73                 echo "Must Specify a build target"
74         fi
75 }
76
77
78 cleanup_and_exit() {
79         rm -rf $ABI_DIR
80         git checkout $CURRENT_BRANCH
81         exit $1
82 }
83
84 # Make sure we configure SHARED libraries
85 # Also turn off IGB and KNI as those require kernel headers to build
86 fixup_config() {
87         sed -i -e"$ a\CONFIG_RTE_BUILD_SHARED_LIB=y" config/defconfig_$TARGET
88         sed -i -e"$ a\CONFIG_RTE_NEXT_ABI=n" config/defconfig_$TARGET
89         sed -i -e"$ a\CONFIG_RTE_EAL_IGB_UIO=n" config/defconfig_$TARGET
90         sed -i -e"$ a\CONFIG_RTE_LIBRTE_KNI=n" config/defconfig_$TARGET
91         sed -i -e"$ a\CONFIG_RTE_KNI_KMOD=n" config/defconfig_$TARGET
92 }
93
94 ###########################################
95 #START
96 ############################################
97
98 #trap on ctrl-c to clean up
99 trap cleanup_and_exit SIGINT
100
101 #Save the current branch
102 CURRENT_BRANCH=`git branch | grep \* | cut -d' ' -f2`
103
104 if [ -z "$CURRENT_BRANCH" ]
105 then
106         CURRENT_BRANCH=`git log --pretty=format:%H HEAD~1..HEAD`
107 fi
108
109 if [ -n "$VERBOSE" ]
110 then
111         export VERBOSE=/dev/stdout
112 else
113         export VERBOSE=/dev/null
114 fi
115
116 # Validate that we have all the arguments we need
117 res=$(validate_args)
118 if [ -n "$res" ]
119 then
120         echo $res
121         usage
122         cleanup_and_exit 1
123 fi
124
125 # Make sure our tags exist
126 res=$(validate_tags)
127 if [ -n "$res" ]
128 then
129         echo $res
130         cleanup_and_exit 1
131 fi
132
133 ABICHECK=`which abi-compliance-checker 2>/dev/null`
134 if [ $? -ne 0 ]
135 then
136         log "INFO" "Cant find abi-compliance-checker utility"
137         cleanup_and_exit 1
138 fi
139
140 ABIDUMP=`which abi-dumper 2>/dev/null`
141 if [ $? -ne 0 ]
142 then
143         log "INFO" "Cant find abi-dumper utility"
144         cleanup_and_exit 1
145 fi
146
147 log "INFO" "We're going to check and make sure that applications built"
148 log "INFO" "against DPDK DSOs from tag $TAG1 will still run when executed"
149 log "INFO" "against DPDK DSOs built from tag $TAG2."
150 log "INFO" ""
151
152 # Check to make sure we have a clean tree
153 git status | grep -q clean
154 if [ $? -ne 0 ]
155 then
156         log "WARN" "Working directory not clean, aborting"
157         cleanup_and_exit 1
158 fi
159
160 # Move to the root of the git tree
161 cd $(dirname $0)/..
162
163 log "INFO" "Checking out version $TAG1 of the dpdk"
164 # Move to the old version of the tree
165 git checkout $TAG1
166
167 fixup_config
168
169 # Checking abi compliance relies on using the dwarf information in
170 # The shared objects.  Thats only included in the DSO's if we build
171 # with -g
172 export EXTRA_CFLAGS="$EXTRA_CFLAGS -g"
173 export EXTRA_LDFLAGS="$EXTRA_LDFLAGS -g"
174
175 # Now configure the build
176 log "INFO" "Configuring DPDK $TAG1"
177 make config T=$TARGET O=$TARGET > $VERBOSE 2>&1
178
179 log "INFO" "Building DPDK $TAG1. This might take a moment"
180 make O=$TARGET > $VERBOSE 2>&1
181
182 if [ $? -ne 0 ]
183 then
184         log "INFO" "THE BUILD FAILED.  ABORTING"
185         cleanup_and_exit 1
186 fi
187
188 # Move to the lib directory
189 cd $TARGET/lib
190 log "INFO" "COLLECTING ABI INFORMATION FOR $TAG1"
191 for i in `ls *.so`
192 do
193         $ABIDUMP $i -o $ABI_DIR/$i-ABI-0.dump -lver $TAG1
194 done
195 cd ../..
196
197 # Now clean the tree, checkout the second tag, and rebuild
198 git clean -f -d
199 git reset --hard
200 # Move to the new version of the tree
201 log "INFO" "Checking out version $TAG2 of the dpdk"
202 git checkout $TAG2
203
204 fixup_config
205
206 # Now configure the build
207 log "INFO" "Configuring DPDK $TAG2"
208 make config T=$TARGET O=$TARGET > $VERBOSE 2>&1
209
210 log "INFO" "Building DPDK $TAG2. This might take a moment"
211 make O=$TARGET > $VERBOSE 2>&1
212
213 if [ $? -ne 0 ]
214 then
215         log "INFO" "THE BUILD FAILED.  ABORTING"
216         cleanup_and_exit 1
217 fi
218
219 cd $TARGET/lib
220 log "INFO" "COLLECTING ABI INFORMATION FOR $TAG2"
221 for i in `ls *.so`
222 do
223         $ABIDUMP $i -o $ABI_DIR/$i-ABI-1.dump -lver $TAG2
224 done
225 cd ../..
226
227 # Start comparison of ABI dumps
228 for i in `ls $ABI_DIR/*-1.dump`
229 do
230         NEWNAME=`basename $i`
231         OLDNAME=`basename $i | sed -e"s/1.dump/0.dump/"`
232         LIBNAME=`basename $i | sed -e"s/-ABI-1.dump//"`
233
234         if [ ! -f $ABI_DIR/$OLDNAME ]
235         then
236                 log "INFO" "$OLDNAME DOES NOT EXIST IN $TAG1. SKIPPING..."
237         fi
238
239         #compare the abi dumps
240         $ABICHECK -l $LIBNAME -old $ABI_DIR/$OLDNAME -new $ABI_DIR/$NEWNAME
241 done
242
243 git reset --hard
244 log "INFO" "ABI CHECK COMPLETE.  REPORTS ARE IN compat_report directory"
245 cleanup_and_exit 0