diff --git a/IntegrationTests/allocation-counter-tests-framework/run-allocation-counter.sh b/IntegrationTests/allocation-counter-tests-framework/run-allocation-counter.sh index 0d366b37d..edbfbda50 100755 --- a/IntegrationTests/allocation-counter-tests-framework/run-allocation-counter.sh +++ b/IntegrationTests/allocation-counter-tests-framework/run-allocation-counter.sh @@ -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" diff --git a/IntegrationTests/tests_04_performance/test_01_allocation_counts.sh b/IntegrationTests/tests_04_performance/test_01_allocation_counts.sh index 3c0388897..00c1c17cd 100644 --- a/IntegrationTests/tests_04_performance/test_01_allocation_counts.sh +++ b/IntegrationTests/tests_04_performance/test_01_allocation_counts.sh @@ -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 diff --git a/IntegrationTests/tests_04_performance/test_01_resources/run-nio-alloc-counter-tests.sh b/IntegrationTests/tests_04_performance/test_01_resources/run-nio-alloc-counter-tests.sh index 22396f047..08788e8be 100755 --- a/IntegrationTests/tests_04_performance/test_01_resources/run-nio-alloc-counter-tests.sh +++ b/IntegrationTests/tests_04_performance/test_01_resources/run-nio-alloc-counter-tests.sh @@ -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