]> git.ipfire.org Git - people/ms/u-boot.git/blame - test/trace/test-trace.sh
Merge branch 'uboot'
[people/ms/u-boot.git] / test / trace / test-trace.sh
CommitLineData
37544a6d
SG
1# Copyright (c) 2013 The Chromium OS Authors.
2#
1a459660 3# SPDX-License-Identifier: GPL-2.0+
37544a6d
SG
4#
5
6# Simple test script for tracing with sandbox
7
37544a6d
SG
8TRACE_OPT="FTRACE=1"
9
129acd4c
SG
10BASE="$(dirname $0)/.."
11. $BASE/common.sh
37544a6d
SG
12
13run_trace() {
14 echo "Run trace"
15 ./${OUTPUT_DIR}/u-boot <<END
07b34278
SG
16trace stats
17hash sha256 0 10000
18trace pause
19trace stats
20hash sha256 0 10000
21trace stats
22trace resume
23hash sha256 0 10000
24trace pause
25trace stats
26reset
37544a6d
SG
27END
28}
29
30check_results() {
31 echo "Check results"
32
33 # Expect sha256 to run 3 times, so we see the string 6 times
34 if [ $(grep -c sha256 ${tmp}) -ne 6 ]; then
35 fail "sha256 error"
36 fi
37
38 # 4 sets of results (output of 'trace stats')
39 if [ $(grep -c "traced function calls" ${tmp}) -ne 4 ]; then
40 fail "trace output error"
41 fi
42
43 # Check trace counts. We expect to see an increase in the number of
44 # traced function calls between each 'trace stats' command, except
45 # between calls 2 and 3, where tracing is paused.
46 # This code gets the sign of the difference between each number and
47 # its predecessor.
48 counts="$(tr -d , <${tmp} | awk '/traced function calls/ { diff = $1 - upto; upto = $1; printf "%d ", diff < 0 ? -1 : (diff > 0 ? 1 : 0)}')"
49
50 if [ "${counts}" != "1 1 0 1 " ]; then
51 fail "trace collection error: ${counts}"
52 fi
53}
54
55echo "Simple trace test / sanity check using sandbox"
56echo
57tmp="$(tempfile)"
129acd4c 58build_uboot "${TRACE_OPT}"
37544a6d
SG
59run_trace >${tmp}
60check_results ${tmp}
61rm ${tmp}
62echo "Test passed"