diff --git a/test/BUILD b/test/BUILD index 8cf4cbe..93f4848 100644 --- a/test/BUILD +++ b/test/BUILD @@ -19,8 +19,8 @@ cc_test( # The best we have for now is just running one of the benchmarks that use pthreads with tracing, # and verifying it doesn't crash and we see expected pthread_trace output. sh_test( - name = "trace_thread_benchmark", - srcs = ["trace_test.sh"], + name = "ld_preload_test_thread_benchmark", + srcs = ["ld_preload_test.sh"], data = [ ":thread_benchmark", "//:pthread_trace.so", @@ -41,6 +41,28 @@ cc_test( size = "small", ) +cc_test( + name = "traced_thread_benchmark", + srcs = ["thread_benchmark.cc"], + deps = [ + "//:pthread_trace", + "@google_benchmark//:benchmark_main", + ], + args = ["--benchmark_min_time=1x"], + size = "small", +) + +sh_test( + name = "linked_test_thread_benchmark", + srcs = ["linked_test.sh"], + data = [":traced_thread_benchmark"], + args = [ + "$(location :traced_thread_benchmark)", + "--benchmark_min_time=1x", + ], + size = "small", +) + cc_test( name = "proto_benchmark", srcs = ["proto_benchmark.cc"], diff --git a/test/trace_test.sh b/test/ld_preload_test.sh old mode 100755 new mode 100644 similarity index 100% rename from test/trace_test.sh rename to test/ld_preload_test.sh diff --git a/test/linked_test.sh b/test/linked_test.sh new file mode 100644 index 0000000..ba07529 --- /dev/null +++ b/test/linked_test.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +target="$1" + +shift + +fail() { rc=$?; (( $# )) && printf '%s\n' "$*" >&2; exit $(( rc == 0 ? 1 : rc )); } + +trace=$(mktemp) + +exec 5>&1 +output=$(PTHREAD_TRACE_BUFFER_SIZE_KB=1 PTHREAD_TRACE_PATH=$trace "$target" "$@" 2>&1 | tee >(cat - >&5)) + +echo "$output" | grep "pthread_trace: Recorded.*KB trace" > /dev/null || fail "Did not find pthread_trace report in output" \ No newline at end of file