Skip to content
Merged
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
17 changes: 14 additions & 3 deletions tests/e2e/340_no_orphan_survives_a_killed_mcpp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,23 @@ work="$(mktemp -d)"; trap 'rm -rf "$work"' EXIT
cd "$work"
mkdir -p src

# Counting by executable name, not by a `pgrep -f` pattern: this script's own
# command line contains the word, and a pattern match finds itself.
# COUNTING BY EXECUTABLE NAME AND BY WORKING DIRECTORY, AND BOTH HALVES MATTER.
#
# Not by a `pgrep -f` pattern: this script's own command line contains the word,
# and a pattern match finds itself.
#
# And not every ninja on the machine: a build server, a developer's second
# checkout, or another test running in parallel can start one inside this
# check's window, and a baseline taken before the build does not cover a process
# that appears during it. Measured in an ecosystem sandbox — which shares the
# host's PID namespace — where an unrelated session's ninja in a different
# project failed this assertion. The predicate was right and the object was
# wrong.
count_ninja() {
local n=0 p
for p in /proc/[0-9]*; do
[[ "$(cat "$p/comm" 2>/dev/null)" == "ninja" ]] && n=$((n+1))
[[ "$(cat "$p/comm" 2>/dev/null)" == "ninja" ]] || continue
case "$(readlink "$p/cwd" 2>/dev/null)" in "$work"*) n=$((n+1));; esac
done
echo "$n"
}
Expand Down
Loading