]> git.proxmox.com Git - ceph.git/blame - ceph/src/spdk/autobuild.sh
import 15.2.0 Octopus source
[ceph.git] / ceph / src / spdk / autobuild.sh
CommitLineData
7c673cae
FG
1#!/usr/bin/env bash
2
3set -e
4
9f95a23c
TL
5# If the configuration of tests is not provided, no tests will be carried out.
6if [[ ! -f $1 ]]; then
7 echo "ERROR: SPDK test configuration not specified"
8 exit 1
9fi
10
11source "$1"
12
7c673cae 13rootdir=$(readlink -f $(dirname $0))
11fdf7f2 14source "$rootdir/test/common/autotest_common.sh"
7c673cae
FG
15
16out=$PWD
17
18umask 022
19
20cd $rootdir
21
22date -u
23git describe --tags
24
9f95a23c
TL
25if [ "$SPDK_TEST_OCF" -eq 1 ]; then
26 # We compile OCF sources ourselves
27 # They don't need to be checked with scanbuild and code coverage is not applicable
28 # So we precompile OCF now for further use as standalone static library
29 ./configure $(echo $config_params | sed 's/--enable-coverage//g')
30 $MAKE $MAKEFLAGS include/spdk/config.h
31 CC=gcc CCAR=ar $MAKE $MAKEFLAGS -C lib/bdev/ocf/env exportlib O=$rootdir/build/ocf.a
32 # Set config to use precompiled library
33 config_params="$config_params --with-ocf=/$rootdir/build/ocf.a"
34fi
35
7c673cae
FG
36./configure $config_params
37
11fdf7f2
TL
38# Print some test system info out for the log
39echo "** START ** Info for Hostname: $HOSTNAME"
40uname -a
41$MAKE cc_version
42$MAKE cxx_version
43echo "** END ** Info for Hostname: $HOSTNAME"
44
45timing_enter autobuild
46
7c673cae 47timing_enter check_format
11fdf7f2
TL
48if [ $SPDK_RUN_CHECK_FORMAT -eq 1 ]; then
49 ./scripts/check_format.sh
50fi
7c673cae
FG
51timing_exit check_format
52
7c673cae 53scanbuild=''
11fdf7f2
TL
54make_timing_label='make'
55if [ $SPDK_RUN_SCANBUILD -eq 1 ] && hash scan-build; then
7c673cae 56 scanbuild="scan-build -o $out/scan-build-tmp --status-bugs"
11fdf7f2
TL
57 make_timing_label='scanbuild_make'
58 report_test_completion "scanbuild"
59
7c673cae
FG
60fi
61
11fdf7f2
TL
62if [ $SPDK_RUN_VALGRIND -eq 1 ]; then
63 report_test_completion "valgrind"
64fi
65
66if [ $SPDK_RUN_ASAN -eq 1 ]; then
67 report_test_completion "asan"
68fi
69
70if [ $SPDK_RUN_UBSAN -eq 1 ]; then
71 report_test_completion "ubsan"
72fi
7c673cae 73
11fdf7f2
TL
74echo $scanbuild
75
76timing_enter "$make_timing_label"
9f95a23c
TL
77
78$MAKE $MAKEFLAGS clean
79if [ $SPDK_BUILD_SHARED_OBJECT -eq 1 ]; then
80 ./configure $config_params --with-shared
81 $MAKE $MAKEFLAGS
82 $MAKE $MAKEFLAGS clean
83 report_test_completion "shared_object_build"
84fi
85
7c673cae 86fail=0
11fdf7f2 87./configure $config_params
7c673cae
FG
88time $scanbuild $MAKE $MAKEFLAGS || fail=1
89if [ $fail -eq 1 ]; then
90 if [ -d $out/scan-build-tmp ]; then
91 scanoutput=$(ls -1 $out/scan-build-tmp/)
92 mv $out/scan-build-tmp/$scanoutput $out/scan-build
93 rm -rf $out/scan-build-tmp
94 chmod -R a+rX $out/scan-build
95 fi
96 exit 1
97else
98 rm -rf $out/scan-build-tmp
99fi
11fdf7f2
TL
100timing_exit "$make_timing_label"
101
102# Check for generated files that are not listed in .gitignore
103timing_enter generated_files_check
104if [ `git status --porcelain --ignore-submodules | wc -l` -ne 0 ]; then
105 echo "Generated files missing from .gitignore:"
9f95a23c 106 git status --porcelain --ignore-submodules
11fdf7f2
TL
107 exit 1
108fi
109timing_exit generated_files_check
7c673cae
FG
110
111# Check that header file dependencies are working correctly by
112# capturing a binary's stat data before and after touching a
113# header file and re-making.
11fdf7f2 114timing_enter dependency_check
7c673cae
FG
115STAT1=`stat examples/nvme/identify/identify`
116sleep 1
117touch lib/nvme/nvme_internal.h
118$MAKE $MAKEFLAGS
119STAT2=`stat examples/nvme/identify/identify`
120
121if [ "$STAT1" == "$STAT2" ]; then
122 echo "Header dependency check failed"
123 exit 1
124fi
11fdf7f2 125timing_exit dependency_check
7c673cae 126
11fdf7f2
TL
127# Test 'make install'
128timing_enter make_install
129rm -rf /tmp/spdk
130mkdir /tmp/spdk
131$MAKE $MAKEFLAGS install DESTDIR=/tmp/spdk prefix=/usr
11fdf7f2 132timing_exit make_install
7c673cae 133
9f95a23c
TL
134# Test 'make uninstall'
135timing_enter make_uninstall
136# Create empty file to check if it is not deleted by target uninstall
137touch /tmp/spdk/usr/lib/sample_xyz.a
138$MAKE $MAKEFLAGS uninstall DESTDIR=/tmp/spdk prefix=/usr
139if [[ $(ls -A /tmp/spdk/usr | wc -l) -ne 2 ]] || [[ $(ls -A /tmp/spdk/usr/lib/ | wc -l) -ne 1 ]]; then
140 ls -lR /tmp/spdk
141 rm -rf /tmp/spdk
142 echo "Make uninstall failed"
143 exit 1
144else
145 rm -rf /tmp/spdk
146fi
147timing_exit make_uninstall
148
7c673cae 149timing_enter doxygen
11fdf7f2
TL
150if [ $SPDK_BUILD_DOC -eq 1 ] && hash doxygen; then
151 $MAKE -C "$rootdir"/doc --no-print-directory $MAKEFLAGS &> "$out"/doxygen.log
152 if [ -s "$out"/doxygen.log ]; then
153 cat "$out"/doxygen.log
154 echo "Doxygen errors found!"
155 exit 1
156 fi
157 if hash pdflatex 2>/dev/null; then
158 $MAKE -C "$rootdir"/doc/output/latex --no-print-directory $MAKEFLAGS &>> "$out"/doxygen.log
159 fi
7c673cae
FG
160 mkdir -p "$out"/doc
161 mv "$rootdir"/doc/output/html "$out"/doc
11fdf7f2
TL
162 if [ -f "$rootdir"/doc/output/latex/refman.pdf ]; then
163 mv "$rootdir"/doc/output/latex/refman.pdf "$out"/doc/spdk.pdf
164 fi
165 $MAKE -C "$rootdir"/doc --no-print-directory $MAKEFLAGS clean &>> "$out"/doxygen.log
166 if [ -s "$out"/doxygen.log ]; then
167 rm "$out"/doxygen.log
168 fi
7c673cae
FG
169 rm -rf "$rootdir"/doc/output
170fi
171timing_exit doxygen
172
173timing_exit autobuild