]> git.proxmox.com Git - ceph.git/blob - ceph/src/spdk/autobuild.sh
import 15.2.0 Octopus source
[ceph.git] / ceph / src / spdk / autobuild.sh
1 #!/usr/bin/env bash
2
3 set -e
4
5 # If the configuration of tests is not provided, no tests will be carried out.
6 if [[ ! -f $1 ]]; then
7 echo "ERROR: SPDK test configuration not specified"
8 exit 1
9 fi
10
11 source "$1"
12
13 rootdir=$(readlink -f $(dirname $0))
14 source "$rootdir/test/common/autotest_common.sh"
15
16 out=$PWD
17
18 umask 022
19
20 cd $rootdir
21
22 date -u
23 git describe --tags
24
25 if [ "$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"
34 fi
35
36 ./configure $config_params
37
38 # Print some test system info out for the log
39 echo "** START ** Info for Hostname: $HOSTNAME"
40 uname -a
41 $MAKE cc_version
42 $MAKE cxx_version
43 echo "** END ** Info for Hostname: $HOSTNAME"
44
45 timing_enter autobuild
46
47 timing_enter check_format
48 if [ $SPDK_RUN_CHECK_FORMAT -eq 1 ]; then
49 ./scripts/check_format.sh
50 fi
51 timing_exit check_format
52
53 scanbuild=''
54 make_timing_label='make'
55 if [ $SPDK_RUN_SCANBUILD -eq 1 ] && hash scan-build; then
56 scanbuild="scan-build -o $out/scan-build-tmp --status-bugs"
57 make_timing_label='scanbuild_make'
58 report_test_completion "scanbuild"
59
60 fi
61
62 if [ $SPDK_RUN_VALGRIND -eq 1 ]; then
63 report_test_completion "valgrind"
64 fi
65
66 if [ $SPDK_RUN_ASAN -eq 1 ]; then
67 report_test_completion "asan"
68 fi
69
70 if [ $SPDK_RUN_UBSAN -eq 1 ]; then
71 report_test_completion "ubsan"
72 fi
73
74 echo $scanbuild
75
76 timing_enter "$make_timing_label"
77
78 $MAKE $MAKEFLAGS clean
79 if [ $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"
84 fi
85
86 fail=0
87 ./configure $config_params
88 time $scanbuild $MAKE $MAKEFLAGS || fail=1
89 if [ $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
97 else
98 rm -rf $out/scan-build-tmp
99 fi
100 timing_exit "$make_timing_label"
101
102 # Check for generated files that are not listed in .gitignore
103 timing_enter generated_files_check
104 if [ `git status --porcelain --ignore-submodules | wc -l` -ne 0 ]; then
105 echo "Generated files missing from .gitignore:"
106 git status --porcelain --ignore-submodules
107 exit 1
108 fi
109 timing_exit generated_files_check
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.
114 timing_enter dependency_check
115 STAT1=`stat examples/nvme/identify/identify`
116 sleep 1
117 touch lib/nvme/nvme_internal.h
118 $MAKE $MAKEFLAGS
119 STAT2=`stat examples/nvme/identify/identify`
120
121 if [ "$STAT1" == "$STAT2" ]; then
122 echo "Header dependency check failed"
123 exit 1
124 fi
125 timing_exit dependency_check
126
127 # Test 'make install'
128 timing_enter make_install
129 rm -rf /tmp/spdk
130 mkdir /tmp/spdk
131 $MAKE $MAKEFLAGS install DESTDIR=/tmp/spdk prefix=/usr
132 timing_exit make_install
133
134 # Test 'make uninstall'
135 timing_enter make_uninstall
136 # Create empty file to check if it is not deleted by target uninstall
137 touch /tmp/spdk/usr/lib/sample_xyz.a
138 $MAKE $MAKEFLAGS uninstall DESTDIR=/tmp/spdk prefix=/usr
139 if [[ $(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
144 else
145 rm -rf /tmp/spdk
146 fi
147 timing_exit make_uninstall
148
149 timing_enter doxygen
150 if [ $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
160 mkdir -p "$out"/doc
161 mv "$rootdir"/doc/output/html "$out"/doc
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
169 rm -rf "$rootdir"/doc/output
170 fi
171 timing_exit doxygen
172
173 timing_exit autobuild