scripts: add verbose test build option
[dpdk.git] / scripts / test-build.sh
1 #! /bin/sh -e
2
3 # BSD LICENSE
4 #
5 # Copyright 2015 6WIND S.A.
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 #   * Neither the name of 6WIND S.A. nor the names of its
18 #     contributors may be used to endorse or promote products derived
19 #     from this software without specific prior written permission.
20 #
21 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
33 default_path=$PATH
34
35 # Load config options:
36 # - AESNI_MULTI_BUFFER_LIB_PATH
37 # - DPDK_BUILD_TEST_CONFIGS (defconfig1+option1+option2 defconfig2)
38 # - DPDK_DEP_CFLAGS
39 # - DPDK_DEP_LDFLAGS
40 # - DPDK_DEP_MOFED (y/[n])
41 # - DPDK_DEP_PCAP (y/[n])
42 # - DPDK_DEP_SSL (y/[n])
43 # - DPDK_DEP_SZE (y/[n])
44 # - DPDK_DEP_ZLIB (y/[n])
45 # - DPDK_MAKE_JOBS (int)
46 # - DPDK_NOTIFY (notify-send)
47 . $(dirname $(readlink -e $0))/load-devel-config.sh
48
49 print_usage () {
50         echo "usage: $(basename $0) [-h] [-jX] [-s] [config1 [config2] ...]]"
51 }
52
53 print_help () {
54         echo 'Test building several targets with different options'
55         echo
56         print_usage
57         cat <<- END_OF_HELP
58
59         options:
60                 -h    this help
61                 -jX   use X parallel jobs in "make"
62                 -s    short test with only first config without examples/doc
63
64         config: defconfig[[~][+]option1[[~][+]option2...]]
65                 Example: x86_64-native-linuxapp-gcc+debug~RXTX_CALLBACKS
66                 The lowercase options are defined inside $(basename $0).
67                 The uppercase options can be the end of a defconfig option
68                 to enable if prefixed with '+' or to disable if prefixed with '~'.
69                 Default is to automatically enable most of the options.
70                 The external dependencies are setup with DPDK_DEP_* variables.
71                 If no config on command line, DPDK_BUILD_TEST_CONFIGS is used.
72         END_OF_HELP
73 }
74
75 J=$DPDK_MAKE_JOBS
76 short=false
77 unset verbose
78 maxerr=-Wfatal-errors
79 while getopts hj:sv ARG ; do
80         case $ARG in
81                 j ) J=$OPTARG ;;
82                 s ) short=true ;;
83                 v ) verbose='V=1' ;;
84                 h ) print_help ; exit 0 ;;
85                 ? ) print_usage ; exit 1 ;;
86         esac
87 done
88 shift $(($OPTIND - 1))
89 configs=${*:-$DPDK_BUILD_TEST_CONFIGS}
90
91 success=false
92 on_exit ()
93 {
94         if [ "$DPDK_NOTIFY" = notify-send ] ; then
95                 if $success ; then
96                         notify-send -u low --icon=dialog-information 'DPDK build' 'finished'
97                 elif [ -z "$signal" ] ; then
98                         notify-send -u low --icon=dialog-error 'DPDK build' 'failed'
99                 fi
100         fi
101 }
102 # catch manual interrupt to ignore notification
103 trap "signal=INT ; trap - INT ; kill -INT $$" INT
104 # notify result on exit
105 trap on_exit EXIT
106
107 cd $(dirname $(readlink -m $0))/..
108
109 reset_env ()
110 {
111         export PATH=$default_path
112         unset CROSS
113         unset DPDK_DEP_CFLAGS
114         unset DPDK_DEP_LDFLAGS
115         unset DPDK_DEP_MOFED
116         unset DPDK_DEP_PCAP
117         unset DPDK_DEP_SSL
118         unset DPDK_DEP_SZE
119         unset DPDK_DEP_ZLIB
120         unset AESNI_MULTI_BUFFER_LIB_PATH
121         unset PQOS_INSTALL_PATH
122 }
123
124 config () # <directory> <target> <options>
125 {
126         if [ ! -e $1/.config ] ; then
127                 echo "================== Configure $1"
128                 make T=$2 O=$1 config
129
130                 echo 'Customize configuration'
131                 # Built-in options (lowercase)
132                 ! echo $3 | grep -q '+default' || \
133                 sed -ri 's,(RTE_MACHINE=")native,\1default,' $1/.config
134                 echo $3 | grep -q '+next' || \
135                 sed -ri           's,(NEXT_ABI=)y,\1n,' $1/.config
136                 ! echo $3 | grep -q '+shared' || \
137                 sed -ri         's,(SHARED_LIB=)n,\1y,' $1/.config
138                 ! echo $3 | grep -q '+debug' || \
139                 sed -ri            's,(DEBUG.*=)n,\1y,' $1/.config
140
141                 # Automatic configuration
142                 ! echo $2 | grep -q '^x86_64' || \
143                 sed -ri               's,(NUMA=)n,\1y,' $1/.config
144                 sed -ri         's,(PCI_CONFIG=)n,\1y,' $1/.config
145                 sed -ri    's,(LIBRTE_IEEE1588=)n,\1y,' $1/.config
146                 sed -ri             's,(BYPASS=)n,\1y,' $1/.config
147                 test "$DPDK_DEP_MOFED" != y || \
148                 sed -ri           's,(MLX._PMD=)n,\1y,' $1/.config
149                 test "$DPDK_DEP_SZE" != y || \
150                 sed -ri       's,(PMD_SZEDATA2=)n,\1y,' $1/.config
151                 test "$DPDK_DEP_ZLIB" != y || \
152                 sed -ri          's,(BNX2X_PMD=)n,\1y,' $1/.config
153                 sed -ri            's,(NFP_PMD=)n,\1y,' $1/.config
154                 test "$DPDK_DEP_PCAP" != y || \
155                 sed -ri               's,(PCAP=)n,\1y,' $1/.config
156                 test -z "$AESNI_MULTI_BUFFER_LIB_PATH" || \
157                 sed -ri       's,(PMD_AESNI_MB=)n,\1y,' $1/.config
158                 test -z "$AESNI_MULTI_BUFFER_LIB_PATH" || \
159                 sed -ri      's,(PMD_AESNI_GCM=)n,\1y,' $1/.config
160                 test "$DPDK_DEP_SSL" != y || \
161                 sed -ri            's,(PMD_QAT=)n,\1y,' $1/.config
162                 sed -ri        's,(KNI_VHOST.*=)n,\1y,' $1/.config
163                 sed -ri           's,(SCHED_.*=)n,\1y,' $1/.config
164                 sed -ri 's,(TEST_PMD_RECORD_.*=)n,\1y,' $1/.config
165                 build_config_hook $1 $2 $3
166
167                 # Explicit enabler/disabler (uppercase)
168                 for option in $(echo $3 | sed 's,[~+], &,g') ; do
169                         pattern=$(echo $option | cut -c2-)
170                         if echo $option | grep -q '^~' ; then
171                                 sed -ri "s,($pattern=)y,\1n," $1/.config
172                         elif echo $option | grep -q '^+' ; then
173                                 sed -ri "s,($pattern=)n,\1y," $1/.config
174                         fi
175                 done
176         fi
177 }
178
179 # default empty hook to override in devel config
180 build_config_hook () # <directory> <target> <options>
181 {
182         :
183 }
184
185 for conf in $configs ; do
186         target=$(echo $conf | sed 's,[~+].*,,')
187         # reload config with DPDK_TARGET set
188         DPDK_TARGET=$target
189         reset_env
190         . $(dirname $(readlink -e $0))/load-devel-config.sh
191
192         options=$(echo $conf | sed 's,[^~+]*,,')
193         dir=$conf
194         config $dir $target $options
195
196         echo "================== Build $dir"
197         make -j$J EXTRA_CFLAGS="$maxerr $DPDK_DEP_CFLAGS" \
198                 EXTRA_LDFLAGS="$DPDK_DEP_LDFLAGS" $verbose O=$dir
199         ! $short || break
200         echo "================== Build examples for $dir"
201         export RTE_SDK=$(pwd)
202         export RTE_TARGET=$dir
203         make -j$J -sC examples \
204                 EXTRA_LDFLAGS="$DPDK_DEP_LDFLAGS" $verbose \
205                 O=$(readlink -m $dir/examples)
206         ! echo $target | grep -q '^x86_64' || \
207         make -j$J -sC examples/performance-thread \
208                 EXTRA_LDFLAGS="$DPDK_DEP_LDFLAGS" $verbose \
209                 O=$(readlink -m $dir/examples/performance-thread)
210         unset RTE_TARGET
211         echo "################## $dir done."
212 done
213
214 if ! $short ; then
215         mkdir -p .check
216         echo "================== Build doxygen HTML API"
217         make doc-api-html >/dev/null 2>.check/doc.txt
218         echo "================== Build sphinx HTML guides"
219         make doc-guides-html >/dev/null 2>>.check/doc.txt
220         echo "================== Check docs"
221         diff -u /dev/null .check/doc.txt
222 fi
223
224 success=true