6 config_params
='--enable-debug --enable-werror'
8 export UBSAN_OPTIONS
='halt_on_error=1:print_stacktrace=1:abort_on_error=1'
10 # Override the default NRHUGE in scripts/setup.sh
15 config_params
+=' --with-dpdk=/usr/local/share/dpdk/x86_64-native-bsdapp-clang'
17 MAKEFLAGS
=${MAKEFLAGS:--j$(sysctl -a | egrep -i 'hw.ncpu' | awk '{print $2}')}
20 config_params+=' --with-dpdk=/usr
/local
/share
/dpdk
/x86_64-native-linuxapp-gcc
'
22 MAKEFLAGS=${MAKEFLAGS:--j$(nproc)}
23 config_params+=' --enable-coverage'
24 config_params+=' --enable-ubsan'
27 echo "Unknown OS in $0"
32 if [ -f /usr/include/infiniband/verbs.h ]; then
33 config_params+=' --with-rdma'
36 if [ -d /usr/src/fio ]; then
37 config_params+=' --with-fio=/usr
/src
/fio
'
40 if [ -d /usr/include/rbd ] && [ -d /usr/include/rados ]; then
41 config_params+=' --with-rbd'
46 if [ -z "$output_dir" ]; then
47 if [ -z "$rootdir" ] || [ ! -d "$rootdir/../output" ]; then
50 output_dir=$rootdir/../output
55 if hash valgrind &> /dev/null; then
56 valgrind='valgrind
--leak-check=full
--error-exitcode=2'
67 if [ "$direction" = "enter" ]; then
68 export timing_stack="${timing_stack};${now}"
69 export test_stack="${test_stack};${testname}"
71 child_time=$(grep "^${test_stack:1};" $output_dir/timing.txt | awk '{s
+=$2} END
{print s
}')
73 start_time=$(echo "$timing_stack" | sed -e 's@^.
*;@@
')
74 timing_stack=$(echo "$timing_stack" | sed -e 's@
;[^
;]*$@@
')
76 elapsed=$((now - start_time - child_time))
77 echo "${test_stack:1} $elapsed" >> $output_dir/timing.txt
79 test_stack=$(echo "$test_stack" | sed -e 's@
;[^
;]*$@@
')
83 function timing_enter() {
89 function timing_exit() {
95 function timing_finish() {
96 flamegraph='/usr
/local
/FlameGraph
/flamegraph.pl
'
97 if [ -x "$flamegraph" ]; then
99 --title 'Build Timing
' \
101 --countname seconds \
102 $output_dir/timing.txt \
103 >$output_dir/timing.svg
107 function process_core() {
109 for core in $(find . -type f \( -name 'core
*' -o -name '*.core
' \)); do
110 exe=$(eu-readelf -n "$core" | grep psargs | sed "s/.*psargs: \([^ \'\" ]*\).*/\1/")
111 echo "exe for $core is $exe"
112 if [[ ! -z "$exe" ]]; then
114 gdb -batch -ex "bt full" $exe $core
119 chmod a+r $output_dir/$core
125 function waitforlisten() {
127 # $2 = TCP port number
128 if [ -z "$1" ] || [ -z "$2" ]; then
132 echo "Waiting for process to start up and listen on TCP port $2..."
133 # turn off trace for this loop
136 while [ $ret -ne 0 ]; do
137 # if the process is no longer running, then exit the script
138 # since it means the application crashed
139 if ! kill -s 0 $1; then
142 if netstat -an --tcp | grep -iw listen | grep -q $2; then
149 function killprocess() {
155 echo "killing process with pid $1"
160 function iscsicleanup() {
161 echo "Cleaning up iSCSI connection"
162 iscsiadm -m node --logout || true
163 iscsiadm -m node -o delete || true
166 function stop_iscsi_service() {
167 if cat /etc/*-release | grep Ubuntu; then
168 service open-iscsi stop
174 function start_iscsi_service() {
175 if cat /etc/*-release | grep Ubuntu; then
176 service open-iscsi start
182 function rbd_setup() {
183 export CEPH_DIR=/home/sys_sgsw/ceph/build
185 if [ -d $CEPH_DIR ]; then
188 (cd $CEPH_DIR && ../src/vstart.sh -d -n -x -l)
189 /usr/local/bin/rbd create $RBD_NAME --size 1000
193 function rbd_cleanup() {
194 if [ -d $CEPH_DIR ]; then
195 (cd $CEPH_DIR && ../src/stop.sh || true)
199 function run_test() {
201 echo "************************************"
203 echo "************************************"
207 echo "************************************"
209 echo "************************************"
213 function print_backtrace() {
215 echo "========== Backtrace start: =========="
217 for i in $(seq 1 $((${#FUNCNAME[@]} - 1))); do
218 local func="${FUNCNAME[$i]}"
219 local line_nr="${BASH_LINENO[$((i - 1))]}"
220 local src="${BASH_SOURCE[$i]/#$rootdir/.}"
221 echo "in $src:$line_nr -> $func()"
223 nl -w 4 -ba -nln $src | grep -B 5 -A 5 "^$line_nr" | \
224 sed "s/^/ /g" | sed "s/^ $line_nr /=> $line_nr /g"
228 echo "========== Backtrace end =========="
234 trap "trap - ERR; print_backtrace >&2" ERR