Skip to content
Permalink
Browse files

alloc counters: propagate tmp dir (#1000)

Motivation:

The allocation counter tests should default to using the integration
tests' tmp dir.

Modifications:

Propagate the right tmp dir.

Result:

fewer orphaned tmp dirs lying around in case of error.
  • Loading branch information...
weissi authored and Lukasa committed May 10, 2019
1 parent a2ecd50 commit d1c7cd0bacc47ab23daef5feab03199544e1dd87
@@ -201,8 +201,9 @@ pkg_root="$here/.."
shared_file=""
modules=()
extra_dependencies_file=""
tmp_dir="/tmp"

while getopts "ns:p:m:d:" opt; do
while getopts "ns:p:m:d:t:" opt; do
case "$opt" in
n)
do_hooking=false
@@ -219,6 +220,9 @@ while getopts "ns:p:m:d:" opt; do
d)
extra_dependencies_file="$OPTARG"
;;
t)
tmp_dir="$OPTARG"
;;
\?)
die "unknown option $opt"
;;
@@ -252,7 +256,7 @@ for f in "${files[@]}"; do
test -f "$f" || die "file '$f' not a file"
done

tmpdir=$(mktemp -d /tmp/thing_XXXXXX)
working_dir=$(mktemp -d "$tmp_dir/.nio_alloc_counter_tests_XXXXXX")

selected_hooked_functions="HookedFunctionsDoHook"
selected_bootstrap="bootstrapDoHook"
@@ -263,7 +267,7 @@ if ! $do_hooking; then
fi

build_package \
"$tmpdir" \
"$working_dir" \
"$here/template" \
"$pkg_root" \
"$(find_swiftpm_package_name "$pkg_root")" \
@@ -275,10 +279,12 @@ build_package \
-- \
"${files[@]}"
(
cd "$tmpdir"
set -eu
cd "$working_dir"
swift build "${build_opts[@]}"
for f in "${files[@]}"; do
echo "- $f"
swift run "${build_opts[@]}" "$(module_name_from_path "$f")"
done
)
rm -rf "$working_dir"
@@ -26,7 +26,7 @@ for file in "$here/test_01_resources/"test_*.swift; do
all_tests+=( "$test_name" )
done

"$here/test_01_resources/run-nio-alloc-counter-tests.sh" > "$tmp/output"
"$here/test_01_resources/run-nio-alloc-counter-tests.sh" -t "$tmp" > "$tmp/output"

for test in "${all_tests[@]}"; do
cat "$tmp/output" # helps debugging
@@ -16,8 +16,27 @@
set -eu
here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

tmp_dir="/tmp"

function die() {
echo >&2 "ERROR: $*"
exit 1
}

while getopts "t:" opt; do
case "$opt" in
t)
tmp_dir="$OPTARG"
;;
\?)
die "unknown option $opt"
;;
esac
done

"$here/../../allocation-counter-tests-framework/run-allocation-counter.sh" \
-p "$here/../../.." \
-m NIO -m NIOHTTP1 \
-s "$here/shared.swift" \
-t "$tmp_dir" \
"$here"/test_*.swift

0 comments on commit d1c7cd0

Please sign in to comment.
You can’t perform that action at this time.