tests: Add an option to build with code coverage
[mech_eap.git] / tests / hwsim / build.sh
1 #!/bin/sh
2
3 set -e
4
5 cd $(dirname $0)
6
7 use_lcov=0
8 while [ "$1" != "" ]; do
9         case $1 in
10                 -c | --codecov ) shift
11                         echo "$0: use code coverage specified"
12                         use_lcov=1
13                         ;;
14                 * ) exit 1
15         esac
16 done
17
18 cd ../../wpa_supplicant
19 if [ ! -e .config ]; then
20     cp ../tests/hwsim/example-wpa_supplicant.config .config
21 else
22     echo "wpa_supplicant config file exists"
23 fi
24
25 if [ $use_lcov -eq 1 ]; then
26     if ! grep -q CONFIG_CODE_COVERAGE .config; then
27             echo CONFIG_CODE_COVERAGE=y >> .config
28     else
29             echo "CONFIG_CODE_COVERAGE already exists in wpa_supplicant/.config. Ignore"
30     fi
31 fi
32
33 make clean
34 make -j8
35
36 cd ../hostapd
37 if [ ! -e .config ]; then
38     cp ../tests/hwsim/example-hostapd.config .config
39 else
40     echo "hostapd config file exists"
41 fi
42
43 if [ $use_lcov -eq 1 ]; then
44     if ! grep -q CONFIG_CODE_COVERAGE .config; then
45             echo CONFIG_CODE_COVERAGE=y >> .config
46     else
47             echo "CONFIG_CODE_COVERAGE already exists in hostapd/.config. Ignore"
48     fi
49 fi
50
51 make clean
52 make -j8 hostapd hlr_auc_gw
53 cd ../wlantest
54 make clean
55 make -j8
56 cd ../mac80211_hwsim/tools
57 make clean
58 make -j8
59 cd ../../tests/hwsim/tnc
60 make clean
61 make -j8
62 cd ..