• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env bash
2# SPDX-License-Identifier: BSD-3-Clause
3
4set -e
5
6source $TRAVIS_BUILD_DIR/.ci/docker-prelude.sh
7
8export CONFIGURE_OPTIONS=
9
10if [ -d build ]; then
11  rm -rf build
12fi
13
14if [ -d ./build-no-tests ]; then
15  rm -rf build-no-tests
16fi
17
18# Do not run tests when building on coverity_scan branch
19if [ "$COVERITY_SCAN_BRANCH" == 1 ]; then
20    echo "Coverity scan branch detected, not running build nor tests...exiting!"
21    exit 0
22fi
23
24if [ -z "$WITH_CRYPTO" ]; then
25    echo "variable WITH_CRYPTO not set, defaulting to ossl"
26    export WITH_CRYPTO="ossl"
27fi
28
29if [ "$WITH_CRYPTO" != "ossl" ]; then
30    export CONFIGURE_OPTIONS="$CONFIGURE_OPTIONS --disable-fapi"
31fi
32
33./bootstrap
34
35# Is it a fuzz run, if so build the fuzz test and exit.
36if [ "$GEN_FUZZ" == "1" ]; then
37    ./configure --with-fuzzing=libfuzzer --enable-tcti-fuzzing --disable-tcti-device --disable-tcti-mssim --disable-shared --with-crypto="$WITH_CRYPTO"
38    make -j$(nproc) check
39    exit 0
40fi
41
42#
43# General build runs
44#
45
46# build with no tests enabled
47mkdir ./build-no-tests
48pushd ./build-no-tests
49
50echo "PWD: $(pwd)"
51echo "ls -la ../ $(ls -la ../)"
52
53../configure --enable-tcti-partial-reads=$WITH_TCTI_PARTIAL --enable-tcti-device-async=$WITH_TCTI_ASYNC --with-crypto=$WITH_CRYPTO $CONFIGURE_OPTIONS
54make -j$(nproc)
55popd
56
57# build with all tests enabled
58mkdir ./build
59pushd ./build
60
61if [ "$CC" == "gcc" ]; then
62  export CONFIGURE_OPTIONS="$CONFIGURE_OPTIONS --enable-code-coverage";
63fi
64
65if [ "$SCANBUILD" == "yes" ]; then
66  scan-build --status-bugs ../configure --enable-tcti-partial-reads=$WITH_TCTI_PARTIAL --enable-tcti-device-async=$WITH_TCTI_ASYNC --enable-unit --enable-integration --with-crypto=$WITH_CRYPTO $CONFIGURE_OPTIONS
67elif [ "$CC" == "clang" ]; then
68  ../configure --enable-tcti-partial-reads=$WITH_TCTI_PARTIAL --enable-tcti-device-async=$WITH_TCTI_ASYNC --enable-unit --enable-integration --with-crypto=$WITH_CRYPTO $CONFIGURE_OPTIONS
69else
70  ../configure --with-sanitizer=undefined --enable-tcti-partial-reads=$WITH_TCTI_PARTIAL --enable-tcti-device-async=$WITH_TCTI_ASYNC --enable-unit --enable-integration --with-crypto=$WITH_CRYPTO $CONFIGURE_OPTIONS
71fi
72
73if [ "$SCANBUILD" == "yes" ]; then
74  scan-build --status-bugs make -j distcheck
75elif [ "$CC" == "clang" ]; then
76  make -j distcheck
77else
78  make -j check
79fi
80
81popd
82
83# back in root git directory, check for whitespace errors. We do this post CI
84# so people can verify the rest of their patch works in CI before dying.
85# git diff --check fails with a non-zero return code causing the shell to die
86# as it has a set -e executed.
87[ -z "$TRAVIS_TAG" ] && git diff --check origin/${TRAVIS_BRANCH:-master}
88
89if [ "$ENABLE_COVERAGE" == "true" ]; then
90    bash <(curl -s https://codecov.io/bash)
91else
92    echo "ENABLE_COVERAGE not true, got \"$ENABLE_COVERAGE\""
93fi
94
95exit 0
96