2015-09-21 15:52:41 +00:00
|
|
|
set -xe
|
|
|
|
ulimit -c unlimited
|
|
|
|
|
2015-10-22 18:26:21 +00:00
|
|
|
MAKECONFIG='CONFIG_DEBUG=y'
|
|
|
|
|
2015-10-03 00:11:56 +00:00
|
|
|
case `uname` in
|
|
|
|
FreeBSD)
|
|
|
|
DPDK_DIR=/usr/local/share/dpdk/x86_64-native-bsdapp-clang
|
|
|
|
MAKE=gmake
|
2015-12-31 17:28:18 +00:00
|
|
|
MAKEFLAGS=${MAKEFLAGS:--j$(sysctl -a | egrep -i 'hw.ncpu' | awk '{print $2}')}
|
2015-10-03 00:11:56 +00:00
|
|
|
;;
|
|
|
|
Linux)
|
2016-01-05 20:31:07 +00:00
|
|
|
DPDK_DIR=/usr/local/share/dpdk/x86_64-native-linuxapp-gcc
|
2015-10-03 00:11:56 +00:00
|
|
|
MAKE=make
|
2015-12-31 17:28:18 +00:00
|
|
|
MAKEFLAGS=${MAKEFLAGS:--j$(nproc)}
|
2015-10-22 18:26:21 +00:00
|
|
|
MAKECONFIG="$MAKECONFIG CONFIG_COVERAGE=y"
|
2015-10-03 00:11:56 +00:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Unknown OS in $0"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
MAKEFLAGS=${MAKEFLAGS:--j16}
|
|
|
|
|
2015-10-09 00:22:39 +00:00
|
|
|
if [ -z "$output_dir" ]; then
|
|
|
|
if [ -z "$rootdir" ] || [ ! -d "$rootdir/../output" ]; then
|
|
|
|
output_dir=.
|
|
|
|
else
|
|
|
|
output_dir=$rootdir/../output
|
|
|
|
fi
|
|
|
|
export output_dir
|
2015-09-21 15:52:41 +00:00
|
|
|
fi
|
|
|
|
|
2015-10-05 17:54:32 +00:00
|
|
|
if hash valgrind &> /dev/null; then
|
|
|
|
# TODO: add --error-exitcode=2 when all Valgrind warnings are fixed
|
|
|
|
valgrind='valgrind --leak-check=full'
|
|
|
|
else
|
|
|
|
valgrind=''
|
|
|
|
fi
|
|
|
|
|
2015-09-21 15:52:41 +00:00
|
|
|
function timing() {
|
|
|
|
direction="$1"
|
|
|
|
testname="$2"
|
|
|
|
|
|
|
|
now=$(date +%s)
|
|
|
|
|
|
|
|
if [ "$direction" = "enter" ]; then
|
2015-10-08 19:40:44 +00:00
|
|
|
export timing_stack="${timing_stack};${now}"
|
|
|
|
export test_stack="${test_stack};${testname}"
|
2015-09-21 15:52:41 +00:00
|
|
|
else
|
2015-10-08 19:40:44 +00:00
|
|
|
child_time=$(grep "^${test_stack:1};" $output_dir/timing.txt | awk '{s+=$2} END {print s}')
|
2015-09-21 15:52:41 +00:00
|
|
|
|
2015-10-08 19:40:44 +00:00
|
|
|
start_time=$(echo "$timing_stack" | sed -e 's@^.*;@@')
|
|
|
|
timing_stack=$(echo "$timing_stack" | sed -e 's@;[^;]*$@@')
|
2015-09-21 15:52:41 +00:00
|
|
|
|
2015-10-08 19:40:44 +00:00
|
|
|
elapsed=$((now - start_time - child_time))
|
|
|
|
echo "${test_stack:1} $elapsed" >> $output_dir/timing.txt
|
|
|
|
|
|
|
|
test_stack=$(echo "$test_stack" | sed -e 's@;[^;]*$@@')
|
2015-09-21 15:52:41 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function timing_enter() {
|
|
|
|
timing "enter" "$1"
|
|
|
|
}
|
|
|
|
|
|
|
|
function timing_exit() {
|
|
|
|
timing "exit" "$1"
|
|
|
|
}
|
|
|
|
|
2015-10-08 19:40:44 +00:00
|
|
|
function timing_finish() {
|
|
|
|
flamegraph='/usr/local/FlameGraph/flamegraph.pl'
|
|
|
|
if [ -x "$flamegraph" ]; then
|
|
|
|
"$flamegraph" \
|
|
|
|
--title 'Build Timing' \
|
|
|
|
--nametype 'Step:' \
|
|
|
|
--countname seconds \
|
|
|
|
$output_dir/timing.txt \
|
|
|
|
>$output_dir/timing.svg
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2015-09-21 15:52:41 +00:00
|
|
|
function process_core() {
|
|
|
|
ret=0
|
|
|
|
for core in $(find . -type f -name 'core*'); do
|
2015-12-02 20:10:54 +00:00
|
|
|
exe=$(eu-readelf -n "$core" | grep psargs | sed "s/.*psargs: \([^ \'\" ]*\).*/\1/")
|
2015-09-21 15:52:41 +00:00
|
|
|
echo "exe for $core is $exe"
|
|
|
|
if [[ ! -z "$exe" ]]; then
|
|
|
|
if hash gdb; then
|
|
|
|
gdb -batch -ex "bt" $exe $core
|
|
|
|
fi
|
|
|
|
cp $exe $output_dir
|
|
|
|
fi
|
|
|
|
mv $core $output_dir
|
|
|
|
chmod a+r $output_dir/$core
|
|
|
|
ret=1
|
|
|
|
done
|
|
|
|
return $ret
|
|
|
|
}
|
|
|
|
|