Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
brendangregg committed Aug 17, 2017
1 parent 2aa2153 commit 2b0ba56
Show file tree
Hide file tree
Showing 76 changed files with 2,442 additions and 15 deletions.
20 changes: 16 additions & 4 deletions record-test.sh
@@ -1,9 +1,21 @@
#!/bin/bash
#
# record-test.sh - Overwrite flame graph test result files.
#
# See test.sh, which checks these resulting files.
#
# Currently only tests stackcollapse-perf.pl.

set -v -x

for opt in pid tid inline kernel context ; do
for t in test/*.txt ; do
echo testing $t : $opt
./stackcollapse-perf.pl --"${opt}" "${t}" 2> /dev/null > test/results/"${t#*/}"-collapsed-"${opt}".txt
# ToDo: add some form of --inline, and --inline --context tests. These are
# tricky since they use addr2line, whose output will vary based on the test
# system's binaries and symbol tables.
for opt in pid tid kernel jit all addrs; do
for testfile in test/*.txt ; do
echo testing $testfile : $opt
outfile=${testfile#*/}
outfile=test/results/${outfile%.txt}"-collapsed-${opt}.txt"
./stackcollapse-perf.pl --"${opt}" "${testfile}" 2> /dev/null > $outfile
done
done
3 changes: 2 additions & 1 deletion stackcollapse-perf.pl
Expand Up @@ -105,11 +105,12 @@ sub remember_stack {
--jit # annotate jit functions with a _[j]
--context # adds source context to --inline
--addrs # include raw addresses where symbols can't be found
--event-filter # event name filter\n
--event-filter=EVENT # event name filter\n
[1] perf script must emit both PID and TIDs for these to work; eg, Linux < 4.1:
perf script -f comm,pid,tid,cpu,time,event,ip,sym,dso,trace
for Linux >= 4.1:
perf script -F comm,pid,tid,cpu,time,event,ip,sym,dso,trace
If you save this output add --header on Linux >= 3.14 to include perf info.
USAGE_END

if ($annotate_all) {
Expand Down
28 changes: 18 additions & 10 deletions test.sh
@@ -1,18 +1,26 @@
#!/bin/bash
#
# test.sh - Check flame graph software vs test result files.
#
# This is used to detect regressions in the flame graph software.
# See record-test.sh, which refreshes these files after intended software
# changes.
#
# Currently only tests stackcollapse-perf.pl.

set -euo pipefail
set -x
set -v


for opt in pid tid kernel ; do
for t in test/*.txt ; do
echo testing $t : $opt
outfile=test/results/${t#*/}-collapsed-${opt}.txt
perl ./stackcollapse-perf.pl --"${opt}" "${t}" 2> /dev/null | diff -u - "${outfile}"
perl ./flamegraph.pl "${outfile}" > /dev/null
done
done

# ToDo: add some form of --inline, and --inline --context tests. These are
# tricky since they use addr2line, whose output will vary based on the test
# system's binaries and symbol tables.
for opt in pid tid kernel jit all addrs; do
for testfile in test/*.txt ; do
echo testing $testfile : $opt
outfile=${testfile#*/}
outfile=test/results/${outfile%.txt}"-collapsed-${opt}.txt"
perl ./stackcollapse-perf.pl --"${opt}" "${testfile}" 2> /dev/null | diff -u - "${outfile}"
perl ./flamegraph.pl "${outfile}" > /dev/null
done
done

0 comments on commit 2b0ba56

Please sign in to comment.