From: Derrick Stolee Date: Thu, 06 Sep 2018 15:13:08 GMT Subject: [RFC PATCH 5/6] test-lib: add run_and_check_trace2 Message-ID: <20180906151309.66712-6-dstolee@microsoft.com> In-Reply-To: <20180906151309.66712-1-dstolee@microsoft.com> The trace2 facility allows tracing category-key-value triples that we can use to communicate runtime information to a side channel. One use is to track the number of commits that are walked by a graph algorithm. Add run_and_check_trace2 test function to run a given command with GIT_TR2_PERFORMANCE running. Then, check the output for the expected category-key-value triple. Use this function in t6600-test-reach.sh to verify can_all_from_reach only visits 11 commits in the example. Signed-off-by: Derrick Stolee --- t/t6600-test-reach.sh | 6 ++++++ t/test-lib.sh | 14 ++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/t/t6600-test-reach.sh b/t/t6600-test-reach.sh index d139a00d1d..98ad25bb45 100755 --- a/t/t6600-test-reach.sh +++ b/t/t6600-test-reach.sh @@ -183,6 +183,12 @@ test_expect_success 'can_all_from_reach:hit' ' test_three_modes can_all_from_reach ' +test_expect_success 'can_all_from_reach:perf' ' + cp commit-graph-full .git/objects/info/commit-graph && + run_and_check_trace2 can_all_from_reach_with_flag num_walked 40 input \ + "test-tool reach can_all_from_reach" +' + test_expect_success 'can_all_from_reach:miss' ' cat >input <<-\EOF && X:commit-2-10 diff --git a/t/test-lib.sh b/t/test-lib.sh index 8bb0f4348e..9b9f68f324 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -1231,3 +1231,17 @@ test_lazy_prereq CURL ' test_lazy_prereq SHA1 ' test $(git hash-object /dev/null) = e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 ' + +# Useage: run_and_check_trace2 +# Run "command