Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions bazel/coverage/collect_cc_coverage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
# gcda or profraw) and uses either lcov or gcov to get the coverage data.
# The coverage data is placed in $COVERAGE_OUTPUT_FILE.

read -ra COVERAGE_GCOV_OPTIONS <<< "${COVERAGE_GCOV_OPTIONS:-}"

# Checks if clang llvm coverage should be used instead of lcov.
function uses_llvm() {
if stat "${COVERAGE_DIR}"/*.profraw >/dev/null 2>&1; then
Expand Down Expand Up @@ -68,24 +70,24 @@ function init_gcov() {
# $COVERAGE_DIR.
# Writes the collected coverage into the given output file.
function llvm_coverage() {
local output_file="${1}"; shift
local output_file="${1}" object_file object_files object_param=()
shift
export LLVM_PROFILE_FILE="${COVERAGE_DIR}/%h-%p-%m.profraw"
"${COVERAGE_GCOV_PATH}" merge -output "${output_file}.data" \
"${COVERAGE_DIR}"/*.profraw


local object_files="$(find -L "${RUNFILES_DIR}" -type f -exec file -L {} \; \
object_files="$(find -L "${RUNFILES_DIR}" -type f -exec file -L {} \; \
| grep ELF | grep -v "LSB core" | sed 's,:.*,,')"

local object_param=""

for object_file in ${object_files}; do
object_param+=" -object ${object_file}"
object_param+=(-object "${object_file}")
done

llvm-cov export -instr-profile "${output_file}.data" -format=lcov \
-ignore-filename-regex='.*external/.+' \
-ignore-filename-regex='/tmp/.+' \
${object_param} | sed 's#/proc/self/cwd/##' > "${output_file}"
"${object_param[@]}" | sed 's#/proc/self/cwd/##' > "${output_file}"
}

# Generates a code coverage report in gcov intermediate text format by invoking
Expand All @@ -97,25 +99,23 @@ function llvm_coverage() {
# - output_file The location of the file where the generated code coverage
# report is written.
function gcov_coverage() {
local output_file="${1}"; shift

# We'll save the standard output of each the gcov command in this log.
local gcov_log="$output_file.gcov.log"
local gcda gcno_path line output_file="${1}"
shift

# Copy .gcno files next to their corresponding .gcda files in $COVERAGE_DIR
# because gcov expects them to be in the same directory.
while read -r line; do
if [[ ${line: -4} == "gcno" ]]; then
gcno_path=${line}
local gcda="${COVERAGE_DIR}/$(dirname ${gcno_path})/$(basename ${gcno_path} .gcno).gcda"
gcda="${COVERAGE_DIR}/$(dirname "${gcno_path}")/$(basename "${gcno_path}" .gcno).gcda"
# If the gcda file was not found we skip generating coverage from the gcno
# file.
if [[ -f "$gcda" ]]; then
# gcov expects both gcno and gcda files to be in the same directory.
# We overcome this by copying the gcno to $COVERAGE_DIR where the gcda
# files are expected to be.
if [ ! -f "${COVERAGE_DIR}/${gcno_path}" ]; then
mkdir -p "${COVERAGE_DIR}/$(dirname ${gcno_path})"
mkdir -p "${COVERAGE_DIR}/$(dirname "${gcno_path}")"
cp "$ROOT/${gcno_path}" "${COVERAGE_DIR}/${gcno_path}"
fi
# Invoke gcov to generate a code coverage report with the flags:
Expand All @@ -134,12 +134,12 @@ function gcov_coverage() {
# Don't generate branch coverage (-b) because of a gcov issue that
# segfaults when both -i and -b are used (see
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84879).
"${GCOV}" -i $COVERAGE_GCOV_OPTIONS -o "$(dirname ${gcda})" "${gcda}"
"${GCOV}" -i "${COVERAGE_GCOV_OPTIONS[@]}" -o "$(dirname "${gcda}")" "${gcda}"

# Append all .gcov files in the current directory to the output file.
cat *.gcov >> "$output_file"
cat ./*.gcov >> "$output_file"
# Delete the .gcov files.
rm *.gcov
rm ./*.gcov
fi
fi
done < "${COVERAGE_MANIFEST}"
Expand Down
11 changes: 7 additions & 4 deletions bazel/coverage/fuzz_coverage_wrapper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@ shift
rm -rf fuzz_corpus

mkdir -p fuzz_corpus/seed_corpus
cp -r $@ fuzz_corpus/seed_corpus
cp -r "$@" fuzz_corpus/seed_corpus

# TODO(asraa): When fuzz targets are stable, remove error suppression and run coverage while fuzzing.
LLVM_PROFILE_FILE= ${TEST_BINARY} fuzz_corpus -seed=${FUZZ_CORPUS_SEED:-1} -max_total_time=${FUZZ_CORPUS_TIME:-60} -max_len=2048 -rss_limit_mb=8192 -timeout=30 || true
LLVM_PROFILE_FILE='' ${TEST_BINARY} fuzz_corpus -seed="${FUZZ_CORPUS_SEED:-1}" -max_total_time="${FUZZ_CORPUS_TIME:-60}" -max_len=2048 -rss_limit_mb=8192 -timeout=30 || :

# Passing files instead of a directory will run fuzzing as a regression test.
# TODO(asraa): Remove manual `|| true`, but this shouldn't be necessary.
${TEST_BINARY} $(find fuzz_corpus -type f) -rss_limit_mb=8192 || true
# TODO(asraa): Remove manual `|| :`, but this shouldn't be necessary.
_CORPUS="$(find fuzz_corpus -type f)"
while read -r line; do CORPUS+=("$line"); done \
<<< "$_CORPUS"
${TEST_BINARY} "${CORPUS[@]}" -rss_limit_mb=8192 || :
2 changes: 1 addition & 1 deletion bazel/gen_sh_test_runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ TEST_NAME="${RAW_TEST_NAME//./_}"

EXEC_ARGS="\"$1\""
shift
for a in $@
for a in "$@"
do
EXEC_ARGS="${EXEC_ARGS}, \"$a\""
done
Expand Down
15 changes: 4 additions & 11 deletions bazel/get_workspace_status
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,14 @@ then
fi

# The code below presents an implementation that works for git repository
git_rev=$(git rev-parse HEAD)
if [[ $? != 0 ]];
then
exit 1
fi
git_rev=$(git rev-parse HEAD) || exit 1
echo "BUILD_SCM_REVISION ${git_rev}"
echo "STABLE_BUILD_SCM_REVISION ${git_rev}"

# Check whether there are any uncommitted changes
git diff-index --quiet HEAD --
if [[ $? == 0 ]];
then
tree_status="Clean"
else
tree_status="Clean"
git diff-index --quiet HEAD -- || {
tree_status="Modified"
fi
}
echo "BUILD_SCM_STATUS ${tree_status}"
echo "STABLE_BUILD_SCM_STATUS ${tree_status}"
8 changes: 4 additions & 4 deletions bazel/setup_clang.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ if [[ ! -e "${LLVM_PREFIX}/bin/llvm-config" ]]; then
exit 1
fi

export PATH="$(${LLVM_PREFIX}/bin/llvm-config --bindir):${PATH}"
PATH="$("${LLVM_PREFIX}"/bin/llvm-config --bindir):${PATH}"
export PATH

RT_LIBRARY_PATH="$(dirname $(find $(llvm-config --libdir) -name libclang_rt.ubsan_standalone_cxx-x86_64.a | head -1))"
RT_LIBRARY_PATH="$(dirname "$(find "$(llvm-config --libdir)" -name libclang_rt.ubsan_standalone_cxx-x86_64.a | head -1)")"

echo "# Generated file, do not edit. If you want to disable clang, just delete this file.
build:clang --action_env='PATH=${PATH}'
Expand All @@ -28,5 +29,4 @@ build:clang-asan --linkopt=-fsanitize=vptr,function
build:clang-asan --linkopt='-L${RT_LIBRARY_PATH}'
build:clang-asan --linkopt=-l:libclang_rt.ubsan_standalone-x86_64.a
build:clang-asan --linkopt=-l:libclang_rt.ubsan_standalone_cxx-x86_64.a
" > ${BAZELRC_FILE}

" > "${BAZELRC_FILE}"
3 changes: 1 addition & 2 deletions bazel/setup_local_tsan.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,4 @@ build:local-tsan --config=libc++
build:local-tsan --config=clang-tsan
build:local-tsan --linkopt=-L${LIBCXX_PREFIX}/lib
build:local-tsan --linkopt=-Wl,-rpath,${LIBCXX_PREFIX}/lib
" > ${BAZELRC_FILE}

" > "${BAZELRC_FILE}"
4 changes: 2 additions & 2 deletions bazel/sh_test_wrapper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
# TODO(lizan): remove when we have a solution for
# https://github.com/bazelbuild/bazel/issues/3510

cd $(dirname "$0")
cd "$(dirname "$0")" || exit 1

if [ $# -gt 0 ]; then
"./$@"
"./${1}" "${@:2}"
fi
2 changes: 1 addition & 1 deletion bazel/test_for_benchmark_wrapper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
# Set the benchmark time to 0 to just verify that the benchmark runs to
# completion. We're interacting with two different flag parsers, so the order
# of flags and the -- matters.
"${TEST_SRCDIR}/envoy/$@" --skip_expensive_benchmarks -- --benchmark_min_time=0
"${TEST_SRCDIR}/envoy/${1}" "${@:2}" --skip_expensive_benchmarks -- --benchmark_min_time=0
4 changes: 3 additions & 1 deletion ci/build_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ export LLVM_ROOT="${LLVM_ROOT:-/opt/llvm}"

[[ "${BUILD_REASON}" != "PullRequest" ]] && BAZEL_EXTRA_TEST_OPTIONS+=("--nocache_test_results")

export BAZEL_QUERY_OPTIONS="${BAZEL_OPTIONS}"
# TODO(phlax): deprecate/remove this - i believe it was made redundant here:
# https://github.com/envoyproxy/envoy/commit/3ebedeb708a23062332a6fcdf33b462b7070adba#diff-2fa22a1337effee365a51e6844be0ab3
export BAZEL_QUERY_OPTIONS="${BAZEL_OPTIONS[*]}"
# Use https://docs.bazel.build/versions/master/command-line-reference.html#flag--experimental_repository_cache_hardlinks
# to save disk space.
BAZEL_BUILD_OPTIONS=(
Expand Down
2 changes: 1 addition & 1 deletion examples/cache/start_service.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/sh
python3 /code/service.py &
envoy -c /etc/service-envoy.yaml --service-cluster service${SERVICE_NAME}
envoy -c /etc/service-envoy.yaml --service-cluster "service${SERVICE_NAME}"
20 changes: 12 additions & 8 deletions examples/cache/verify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ export NAME=cache

check_validated() {
# Get the date header and the response generation timestamp
local dates
dates=($(grep -oP '\d\d:\d\d:\d\d' <<< "$1"))
local _dates dates
_dates=$(grep -oP '\d\d:\d\d:\d\d' <<< "$1")
while read -r line; do dates+=("$line"); done \
<<< "$_dates"
# Make sure they are different
if [[ ${dates[0]} == ${dates[1]} ]]; then
if [[ ${dates[0]} == "${dates[1]}" ]]; then
echo "ERROR: validated responses should have a date AFTER the generation timestamp" >&2
return 1
fi
Expand All @@ -31,10 +33,12 @@ check_cached() {

check_from_origin() {
# Get the date header and the response generation timestamp
local dates
dates=($(grep -oP '\d\d:\d\d:\d\d' <<< "$1"))
local _dates dates
_dates=$(grep -oP '\d\d:\d\d:\d\d' <<< "$1")
while read -r line; do dates+=("$line"); done \
<<< "$_dates"
# Make sure they are equal
if [[ ${dates[0]} != ${dates[1]} ]]; then
if [[ ${dates[0]} != "${dates[1]}" ]]; then
echo "ERROR: responses from origin should have a date equal to the generation timestamp" >&2
return 1
fi
Expand Down Expand Up @@ -65,7 +69,7 @@ response=$(curl -si localhost:8000/service/1/valid-for-minute)
check_validated "$response"

run_log "Private: Make 4 requests make sure they are all served by the origin"
for i in {0..3}
for _ in {0..3}
do
response=$(curl -si localhost:8000/service/1/private)
check_from_origin "$response"
Expand All @@ -76,7 +80,7 @@ response=$(curl -si localhost:8000/service/1/no-cache)
check_from_origin "$response"

run_log "No-cache: Make 4 more requests and make sure they are all validated before being served from cache"
for i in {0..3}
for _ in {0..3}
do
sleep 1
response=$(curl -si localhost:8000/service/1/no-cache)
Expand Down
2 changes: 1 addition & 1 deletion examples/front-proxy/start_service.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/sh
python3 /code/service.py &
envoy -c /etc/service-envoy.yaml --service-cluster service${SERVICE_NAME}
envoy -c /etc/service-envoy.yaml --service-cluster "service${SERVICE_NAME}"
6 changes: 3 additions & 3 deletions examples/load-reporting-service/send_requests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

counter=1
while [ $counter -le 50 ]
do
do
# generate random Port number to send requests
ports=("80" "81")
port=${ports[$RANDOM % ${#ports[@]} ]}

curl -v localhost:$port/service
curl -v "localhost:${port}/service"
((counter++))
done
done
4 changes: 2 additions & 2 deletions examples/load-reporting-service/start_service.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/sh
#!/bin/bash
python3 /code/http_server.py &
/usr/local/bin/envoy -c /etc/service-envoy-w-lrs.yaml --service-node ${HOSTNAME} --service-cluster http_service
/usr/local/bin/envoy -c /etc/service-envoy-w-lrs.yaml --service-node "${HOSTNAME}" --service-cluster http_service
4 changes: 2 additions & 2 deletions test/integration/hotrestart_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ echo "Hot restart test using dynamic base id"

TEST_INDEX=0
function run_testsuite() {
local BASE_ID BASE_ID_PATH HOT_RESTART_JSON="$1" FAKE_SYMBOL_TABLE="$2"
local BASE_ID BASE_ID_PATH HOT_RESTART_JSON="$1" FAKE_SYMBOL_TABLE="$2"
local SOCKET_PATH=@envoy_domain_socket
local SOCKET_MODE=0
if [ ! -z "$3" ] && [ ! -z "$4" ]
if [ -n "$3" ] && [ -n "$4" ]
then
SOCKET_PATH="$3"
SOCKET_MODE="$4"
Expand Down
2 changes: 1 addition & 1 deletion tools/code_format/check_shellcheck_format.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash -e

EXCLUDED_SHELLFILES=${EXCLUDED_SHELLFILES:-"^examples|^bin|^source|^bazel|^.github"}
EXCLUDED_SHELLFILES=${EXCLUDED_SHELLFILES:-"^.github|.rst$|.md$"}


find_shell_files () {
Expand Down