1#!/bin/bash
2#***************************************************************************
3#                                  _   _ ____  _
4#  Project                     ___| | | |  _ \| |
5#                             / __| | | | |_) | |
6#                            | (__| |_| |  _ <| |___
7#                             \___|\___/|_| \_\_____|
8#
9# Copyright (C) 1998 - 2021, Daniel Stenberg, <daniel@haxx.se>, et al.
10#
11# This software is licensed as described in the file COPYING, which
12# you should have received as part of this distribution. The terms
13# are also available at https://curl.se/docs/copyright.html.
14#
15# You may opt to use, copy, modify, merge, publish, distribute and/or sell
16# copies of the Software, and permit persons to whom the Software is
17# furnished to do so, under the terms of the COPYING file.
18#
19# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20# KIND, either express or implied.
21#
22###########################################################################
23set -eo pipefail
24
25./buildconf
26
27if [ "$T" = "coverage" ]; then
28  ./configure --enable-debug --disable-shared --disable-threaded-resolver --enable-code-coverage --enable-werror --with-libssh2
29  make
30  make TFLAGS=-n test-nonflaky
31  make "TFLAGS=-n -e" test-nonflaky
32  tests="1 200 300 500 700 800 900 1000 1100 1200 1302 1400 1502 3000"
33  make "TFLAGS=-n -t $tests" test-nonflaky
34  coveralls --gcov /usr/bin/gcov-8 --gcov-options '\-lp' -i src -e lib -e tests -e docs -b $PWD/src
35  coveralls --gcov /usr/bin/gcov-8 --gcov-options '\-lp' -e src -i lib -e tests -e docs -b $PWD/lib
36fi
37
38if [ "$T" = "torture" ]; then
39  ./configure --enable-debug --disable-shared --disable-threaded-resolver --enable-code-coverage --enable-werror --with-libssh2 --with-openssl
40  make
41  tests="!TLS-SRP !FTP"
42  make "TFLAGS=-n --shallow=20 -t $tests" test-nonflaky
43fi
44
45if [ "$T" = "events" ]; then
46  ./configure --enable-debug --disable-shared --disable-threaded-resolver --enable-code-coverage --enable-werror --with-libssh2 --with-openssl
47  make
48  tests="!TLS-SRP"
49  make "TFLAGS=-n -e $tests" test-nonflaky
50fi
51
52if [ "$T" = "debug" ]; then
53  ./configure --enable-debug --enable-werror $C
54  make
55  make examples
56  if [ -z $NOTESTS ]; then
57    make test-nonflaky
58  fi
59fi
60
61if [ "$T" = "debug-wolfssl" ]; then
62  ./configure --enable-debug --enable-werror $C
63  make
64  make "TFLAGS=-n !313" test-nonflaky
65fi
66
67if [ "$T" = "debug-mesalink" ]; then
68  ./configure --enable-debug --enable-werror $C
69  make
70  make "TFLAGS=-n !313 !410 !3001" test-nonflaky
71fi
72
73if [ "$T" = "debug-rustls" ]; then
74  ./configure --enable-debug --enable-werror $C
75  make
76  make "TFLAGS=HTTPS !313" test-nonflaky
77fi
78
79if [ "$T" = "debug-bearssl" ]; then
80  ./configure --enable-debug --enable-werror $C
81  make
82  make "TFLAGS=-n !313" test-nonflaky
83fi
84
85if [ "$T" = "novalgrind" ]; then
86  ./configure --enable-werror $C
87  make
88  make examples
89  make TFLAGS=-n test-nonflaky
90fi
91
92if [ "$T" = "normal" ]; then
93  if [ $TRAVIS_OS_NAME = linux ]; then
94    # Remove system curl to make sure we don't rely on it.
95    # Only done on Linux since we're not permitted to on mac.
96    sudo rm -f /usr/bin/curl
97  fi
98  ./configure --enable-warnings --enable-werror $C
99  make
100  make examples
101  if [ -z $NOTESTS ]; then
102    make test-nonflaky
103  fi
104  if [ -n "$CHECKSRC" ]; then
105    make checksrc
106  fi
107fi
108
109if [ "$T" = "tidy" ]; then
110  ./configure --enable-warnings --enable-werror $C
111  make
112  make tidy
113fi
114
115if [ "$T" = "iconv" ]; then
116  source scripts/zuul/iconv-env.sh
117  ./configure --enable-debug --enable-werror $C
118  make
119  make examples
120  make test-nonflaky
121fi
122
123if [ "$T" = "cmake" ]; then
124  cmake -H. -Bbuild -DCURL_WERROR=ON $C
125  cmake --build build
126  env TFLAGS="!1139 $TFLAGS" cmake --build build --target test-nonflaky
127fi
128
129if [ "$T" = "distcheck" ]; then
130  # find BOM markers and exit if we do
131  ! git grep `printf '\xef\xbb\xbf'`
132  ./configure --without-ssl
133  make
134  ./maketgz 99.98.97
135  # verify in-tree build - and install it
136  tar xf curl-99.98.97.tar.gz
137  cd curl-99.98.97
138  ./configure --prefix=$HOME/temp --without-ssl
139  make
140  make TFLAGS=1 test
141  make install
142  # basic check of the installed files
143  cd ..
144  bash scripts/installcheck.sh $HOME/temp
145  rm -rf curl-99.98.97
146  # verify out-of-tree build
147  tar xf curl-99.98.97.tar.gz
148  touch curl-99.98.97/docs/{cmdline-opts,libcurl}/Makefile.inc
149  mkdir build
150  cd build
151  ../curl-99.98.97/configure --without-ssl
152  make
153  make TFLAGS='-p 1 1139' test
154  # verify cmake build
155  cd ..
156  rm -rf curl-99.98.97
157  tar xf curl-99.98.97.tar.gz
158  cd curl-99.98.97
159  mkdir build
160  cd build
161  cmake ..
162  make
163  cd ../..
164fi
165
166if [ "$T" = "fuzzer" ]; then
167  # Download the fuzzer to a temporary folder
168  ./tests/fuzz/download_fuzzer.sh /tmp/curl_fuzzer
169
170  export CURLSRC=$PWD
171
172  # Run the mainline fuzzer test
173  pushd /tmp/curl_fuzzer
174  ./mainline.sh ${CURLSRC}
175  popd
176fi
177
178if [ "$T" = "scan-build" ]; then
179  scan-build ./configure --enable-debug --enable-werror $C
180  scan-build --status-bugs make
181  scan-build --status-bugs make examples
182fi
183