mirror of
https://github.com/apache/impala.git
synced 2025-12-19 09:58:28 -05:00
This change adds an optional flag to coverage_helper.sh script that accepts additional parameters for the wrapped gcovr call. Tests: - manually validated that the script has the original behaviour if the newly added flag is not set, also if it's set, the parameters are pushed down correctly. Change-Id: Iea26c9967b62b06ded6a0cb4c0346f0e789beb80 Reviewed-on: http://gerrit.cloudera.org:8080/23290 Reviewed-by: Impala Public Jenkins <impala-public-jenkins@cloudera.com> Tested-by: Peter Rozsa <prozsa@cloudera.com>
95 lines
3.1 KiB
Bash
Executable File
95 lines
3.1 KiB
Bash
Executable File
#!/bin/bash
|
|
#
|
|
# Licensed to the Apache Software Foundation (ASF) under one
|
|
# or more contributor license agreements. See the NOTICE file
|
|
# distributed with this work for additional information
|
|
# regarding copyright ownership. The ASF licenses this file
|
|
# to you under the Apache License, Version 2.0 (the
|
|
# "License"); you may not use this file except in compliance
|
|
# with the License. You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing,
|
|
# software distributed under the License is distributed on an
|
|
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
# KIND, either express or implied. See the License for the
|
|
# specific language governing permissions and limitations
|
|
# under the License.
|
|
|
|
set -eu -o pipefail
|
|
|
|
ZERO_COUNTERS_ACTION=0
|
|
REPORT_ACTION=0
|
|
REPORT_DIRECTORY=${IMPALA_HOME}/logs/coverage
|
|
|
|
function print_usage {
|
|
echo "coverage_helper.sh - Driver script for coverage"
|
|
echo "[-zerocounters] : Reset coverage counters"
|
|
echo "[-report] : Generate a detailed coverage report"
|
|
echo "[-reportdirectory <directory>] : Output directory for coverage report files"
|
|
}
|
|
|
|
while [ -n "$*" ]
|
|
do
|
|
case "$1" in
|
|
-zerocounters)
|
|
ZERO_COUNTERS_ACTION=1
|
|
;;
|
|
-report)
|
|
REPORT_ACTION=1
|
|
;;
|
|
-reportdirectory)
|
|
REPORT_DIRECTORY="${2-}"
|
|
shift
|
|
;;
|
|
-help|*)
|
|
print_usage
|
|
exit 1
|
|
;;
|
|
esac
|
|
shift
|
|
done
|
|
|
|
if [[ ${ZERO_COUNTERS_ACTION} -eq 0 && ${REPORT_ACTION} -eq 0 ]]; then
|
|
print_usage
|
|
exit 1
|
|
fi
|
|
|
|
if pgrep -U "$USER" impalad; then
|
|
echo "Warning: impalad is running. Coverage counters are only updated when"
|
|
echo "a program exits. Any report will not include the information from"
|
|
echo "the running impalad. Similarly, zeroing the counters will not zero"
|
|
echo "the counters for the running impalad."
|
|
fi
|
|
|
|
if [ ${REPORT_ACTION} -eq 1 ]; then
|
|
mkdir -p "${REPORT_DIRECTORY}"
|
|
rm -f "${REPORT_DIRECTORY}"/index*.html
|
|
# Use gcov from the toolchain's GCC directory, so the gcov version always matches
|
|
# our toolchain compiler version.
|
|
export PATH="$IMPALA_TOOLCHAIN_PACKAGES_HOME/gcc-$IMPALA_GCC_VERSION/bin:$PATH"
|
|
echo "Using gcov at `which gcov`"
|
|
# src/util/bit-packing.inline.h gets lots of hits, so generating a detailed report
|
|
# for it takes several minutes. Exclude it to keep the execution time down.
|
|
# gcovr excludes are buggy, so on some environments these excludes won't work.
|
|
echo "Generating report in directory: ${REPORT_DIRECTORY}"
|
|
cd "${IMPALA_HOME}"
|
|
"${IMPALA_HOME}/bin/impala-gcovr" -v -r "${IMPALA_HOME}/be" \
|
|
--exclude=".*src/benchmarks.*" \
|
|
--exclude=".*src/gutil.*" \
|
|
--exclude=".*src/kudu.*" \
|
|
--exclude=".*generated-sources/gen-cpp.*" \
|
|
--exclude=".*src/util/bit-packing.inline.h.*" \
|
|
--html --html-details="${REPORT_DIRECTORY}/index.html" \
|
|
${EXTRA_COVERAGE_REPORTING_ARGUMENTS[@]} \
|
|
> "${REPORT_DIRECTORY}/gcovr.out" 2>&1
|
|
fi
|
|
|
|
if [ ${ZERO_COUNTERS_ACTION} -eq 1 ]; then
|
|
# The .gcda files contain the counters for coverage. Deleting them zeros the
|
|
# the counters.
|
|
echo "Zeroing Counters"
|
|
find "${IMPALA_HOME}/be" -name "*.gcda" -delete
|
|
fi
|