Skip to content
2 changes: 1 addition & 1 deletion ci/ci_steps.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
ENVOY_BUILD_SHA=fc747b3c2fd49b1260484572071fe4194cd6824d
ENVOY_BUILD_SHA=1d2a2100708d1012cd61054ce04d4dc4e3b03ff2
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change has no effect outside of this PR until it is merged, correct?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that is correct. But it's failing due to changes in bazel per the other open PR. See the comments there.


# Script that lists all the steps take by the CI system when doing Envoy builds.
set -e
Expand Down
2 changes: 1 addition & 1 deletion ci/do_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ elif [[ "$1" == "bazel.coverage" ]]; then
export GCOVR_DIR="${ENVOY_BUILD_DIR}/bazel-envoy"
export TESTLOGS_DIR="${ENVOY_BUILD_DIR}/bazel-testlogs"
export BUILDIFIER_BIN="/usr/lib/go/bin/buildifier"
export WORKSPACE=ci
# There is a bug in gcovr 3.3, where it takes the -r path,
# in our case /source, and does a regex replacement of various
# source file paths during HTML generation. It attempts to strip
Expand All @@ -101,7 +102,6 @@ elif [[ "$1" == "bazel.coverage" ]]; then
# some Bazel created symlinks to the source directory in its output
# directory. Wow.
cd "${ENVOY_BUILD_DIR}"
export BAZEL_TEST_OPTIONS="${BAZEL_TEST_OPTIONS} -c dbg"
SRCDIR="${GCOVR_DIR}" "${ENVOY_SRCDIR}"/test/run_envoy_bazel_coverage.sh
rsync -av "${ENVOY_BUILD_DIR}"/bazel-envoy/generated/coverage/ "${ENVOY_COVERAGE_DIR}"
exit 0
Expand Down
10 changes: 6 additions & 4 deletions source/exe/signal_action.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ class SignalAction : NonCopyable {
*/
void doGoodAccessForTest();
void tryEvilAccessForTest(bool end);
/**
* The actual signal handler function with prototype matching signal.h
*
* Public so that we can exercise it directly from a test.
*/
static void sigHandler(int sig, siginfo_t* info, void* context);

private:
/**
Expand Down Expand Up @@ -91,10 +97,6 @@ class SignalAction : NonCopyable {
* Return the memory size we actually map including two guard pages.
*/
size_t mapSizeWithGuards() const { return altstack_size_ + guard_size_ * 2; }
/**
* The actual signal handler function with prototype matching signal.h
*/
static void sigHandler(int sig, siginfo_t* info, void* context);
/**
* Install all signal handlers and setup signal handling stack.
*/
Expand Down
17 changes: 12 additions & 5 deletions test/exe/signals_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ namespace Envoy {
#define ASANITIZED /* Sanitized by GCC */
#endif

// Memory violation signal tests are disabled under address sanitizer. The
// sanitizer does its own special signal handling and prints messages that are
// not ours instead of what this test expects. The signals special handled by ASAN
// include SIGSEGV, SIGBUS, and SIGFPE.
// Death tests that expect a particular output are disabled under address sanitizer.
// The sanitizer does its own special signal handling and prints messages that are
// not ours instead of what this test expects. As of latest Clang this appears
// to include abort() as well.
#ifndef ASANITIZED
TEST(Signals, InvalidAddressDeathTest) {
SignalAction actions;
Expand Down Expand Up @@ -52,7 +52,6 @@ TEST(Signals, BadMathDeathTest) {
raise(SIGFPE);
}(), "backtrace.*Floating point");
}
#endif

#if defined(__x86_64__) || defined(__i386__)
// Unfortunately we don't have a reliable way to do this on other platforms
Expand Down Expand Up @@ -81,6 +80,7 @@ TEST(Signals, RestoredPreviousHandlerDeathTest) {
// Outer SignalAction should be active again:
EXPECT_DEATH([]() -> void { abort(); }(), "backtrace.*Aborted");
}
#endif

TEST(Signals, IllegalStackAccessDeathTest) {
SignalAction actions;
Expand All @@ -107,4 +107,11 @@ TEST(Signals, LegalStackAccessTest) {
SignalAction actions;
actions.doGoodAccessForTest();
}

TEST(Signals, HandlerTest) {
siginfo_t fake_si;
fake_si.si_addr = nullptr;
SignalAction::sigHandler(SIGURG, &fake_si, nullptr);
}

} // Envoy
13 changes: 13 additions & 0 deletions test/run_envoy_bazel_coverage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ set -e
[[ -z "${TESTLOGS_DIR}" ]] && TESTLOGS_DIR="${SRCDIR}/bazel-testlogs"
[[ -z "${BAZEL_COVERAGE}" ]] && BAZEL_COVERAGE=bazel
[[ -z "${GCOVR}" ]] && GCOVR=gcovr
[[ -z "${WORKSPACE}" ]] && WORKSPACE=envoy

# This is the target that will be run to generate coverage data. It can be overriden by consumer
# projects that want to run coverage on a different/combined target.
Expand All @@ -23,6 +24,9 @@ do
done
echo "Cleanup completed."

# Force dbg for path consistency later, don't include debug code in coverage.
BAZEL_TEST_OPTIONS="${BAZEL_TEST_OPTIONS} -c dbg --copt=-DNDEBUG"

# Run all tests under "bazel test", no sandbox. We're going to generate the
# .gcda inplace in the bazel-out/ directory. This is in contrast to the "bazel
# coverage" method, which is currently broken for C++ (see
Expand All @@ -45,6 +49,15 @@ COVERAGE_DIR="${SRCDIR}"/generated/coverage
mkdir -p "${COVERAGE_DIR}"
COVERAGE_SUMMARY="${COVERAGE_DIR}/coverage_summary.txt"

# Copy .gcno objects into the same location that we find the .gcda.
# TODO(htuch): Should use rsync, but there are some symlink loops to fight.
pushd "${GCOVR_DIR}"
for f in $(find -L bazel-out/ -name "*.gcno")
do
cp --parents "$f" bazel-out/local-dbg/bin/test/coverage/coverage_tests.runfiles/"${WORKSPACE}"
done
popd

# gcovr is extremely picky about where it is run and where the paths of the
# original source are relative to its execution location.
cd "${SRCDIR}"
Expand Down