[U-Boot] [PATCH v2 1/4] Reactivate the tracing feature

This was lost sometime in the Kbuild conversion. Add it back.
Check that the trace test now passes:
$ ./test/trace/test-trace.sh Simple trace test / sanity check using sandbox
/tmp/filemHKPGw Build sandbox O=sandbox FTRACE=1 GEN /home/sjg/c/src/third_party/u-boot/files/sandbox/Makefile Configuring for sandbox board... Check results Test passed
Signed-off-by: Simon Glass sjg@chromium.org ---
Changes in v2: None
config.mk | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/config.mk b/config.mk index b4bf6f9..2157537 100644 --- a/config.mk +++ b/config.mk @@ -53,6 +53,10 @@ ifdef BOARD sinclude $(srctree)/board/$(BOARDDIR)/config.mk # include board specific rules endif
+ifdef FTRACE +PLATFORM_CPPFLAGS += -finstrument-functions -DFTRACE +endif + #########################################################################
RELFLAGS := $(PLATFORM_RELFLAGS)

This is not supported properly on sandbox, and interferes with running tests, since when a test script is piped in, some commands will call ctrlc() which will drop characters from the test script.
Signed-off-by: Simon Glass sjg@chromium.org ---
Changes in v2: - Remove more elaborate feature and just disable ctrlc for sandbox
common/console.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/common/console.c b/common/console.c index 898da39..5a2f411 100644 --- a/common/console.c +++ b/common/console.c @@ -524,6 +524,7 @@ static int ctrlc_disabled = 0; /* see disable_ctrl() */ static int ctrlc_was_pressed = 0; int ctrlc(void) { +#ifndef CONFIG_SANDBOX if (!ctrlc_disabled && gd->have_console) { if (tstc()) { switch (getc()) { @@ -535,6 +536,8 @@ int ctrlc(void) } } } +#endif + return 0; } /* Reads user's confirmation.

On Sun, Sep 14, 2014 at 12:40:15PM -0600, Simon Glass wrote:
This is not supported properly on sandbox, and interferes with running tests, since when a test script is piped in, some commands will call ctrlc() which will drop characters from the test script.
Signed-off-by: Simon Glass sjg@chromium.org
Applied to u-boot/master, thanks!

These cause U-Boot to print a list of available commands. It doesn't break the test, but it is best to remove them from the output.
Signed-off-by: Simon Glass sjg@chromium.org ---
Changes in v2: None
test/trace/test-trace.sh | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/test/trace/test-trace.sh b/test/trace/test-trace.sh index aa02f09..973063c 100755 --- a/test/trace/test-trace.sh +++ b/test/trace/test-trace.sh @@ -27,17 +27,17 @@ build_uboot() { run_trace() { echo "Run trace" ./${OUTPUT_DIR}/u-boot <<END - trace stats - hash sha256 0 10000 - trace pause - trace stats - hash sha256 0 10000 - trace stats - trace resume - hash sha256 0 10000 - trace pause - trace stats - reset +trace stats +hash sha256 0 10000 +trace pause +trace stats +hash sha256 0 10000 +trace stats +trace resume +hash sha256 0 10000 +trace pause +trace stats +reset END }

On Sun, Sep 14, 2014 at 12:40:16PM -0600, Simon Glass wrote:
These cause U-Boot to print a list of available commands. It doesn't break the test, but it is best to remove them from the output.
Signed-off-by: Simon Glass sjg@chromium.org
Applied to u-boot/master, thanks!

This performs a command, then repeats it, and checks that the repeat happens.
Signed-off-by: Simon Glass sjg@chromium.org ---
Changes in v2: None
test/cmd_repeat.sh | 29 +++++++++++++++++++++++++++++ test/common.sh | 20 ++++++++++++++++++++ test/trace/test-trace.sh | 20 +++----------------- 3 files changed, 52 insertions(+), 17 deletions(-) create mode 100755 test/cmd_repeat.sh create mode 100644 test/common.sh
diff --git a/test/cmd_repeat.sh b/test/cmd_repeat.sh new file mode 100755 index 0000000..990e799 --- /dev/null +++ b/test/cmd_repeat.sh @@ -0,0 +1,29 @@ +#!/bin/sh + +# Test for U-Boot cli including command repeat + +BASE="$(dirname $0)" +. $BASE/common.sh + +run_test() { + ./${OUTPUT_DIR}/u-boot <<END +setenv ctrlc_ignore y +md 0 + +reset +END +} +check_results() { + echo "Check results" + + grep -q 00000100 ${tmp} || fail "Command did not repeat" +} + +echo "Test CLI repeat" +echo +tmp="$(tempfile)" +build_uboot +run_test >${tmp} +check_results ${tmp} +rm ${tmp} +echo "Test passed" diff --git a/test/common.sh b/test/common.sh new file mode 100644 index 0000000..702d1ed --- /dev/null +++ b/test/common.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +OUTPUT_DIR=sandbox + +fail() { + echo "Test failed: $1" + if [ -n ${tmp} ]; then + rm ${tmp} + fi + exit 1 +} + +build_uboot() { + echo "Build sandbox" + OPTS="O=${OUTPUT_DIR} $1" + NUM_CPUS=$(grep -c processor /proc/cpuinfo) + echo ${OPTS} + make ${OPTS} sandbox_config + make ${OPTS} -s -j${NUM_CPUS} +} diff --git a/test/trace/test-trace.sh b/test/trace/test-trace.sh index 973063c..3e8651e 100755 --- a/test/trace/test-trace.sh +++ b/test/trace/test-trace.sh @@ -5,24 +5,10 @@
# Simple test script for tracing with sandbox
-OUTPUT_DIR=sandbox TRACE_OPT="FTRACE=1"
-fail() { - echo "Test failed: $1" - if [ -n ${tmp} ]; then - rm ${tmp} - fi - exit 1 -} - -build_uboot() { - echo "Build sandbox" - OPTS="O=${OUTPUT_DIR} ${TRACE_OPT}" - NUM_CPUS=$(grep -c processor /proc/cpuinfo) - make ${OPTS} sandbox_config - make ${OPTS} -s -j${NUM_CPUS} -} +BASE="$(dirname $0)/.." +. $BASE/common.sh
run_trace() { echo "Run trace" @@ -69,7 +55,7 @@ check_results() { echo "Simple trace test / sanity check using sandbox" echo tmp="$(tempfile)" -build_uboot +build_uboot "${TRACE_OPT}" run_trace >${tmp} check_results ${tmp} rm ${tmp}

On Sun, Sep 14, 2014 at 12:40:17PM -0600, Simon Glass wrote:
This performs a command, then repeats it, and checks that the repeat happens.
Signed-off-by: Simon Glass sjg@chromium.org
Applied to u-boot/master, thanks!

On Sun, Sep 14, 2014 at 12:40:14PM -0600, Simon Glass wrote:
This was lost sometime in the Kbuild conversion. Add it back.
Check that the trace test now passes:
$ ./test/trace/test-trace.sh Simple trace test / sanity check using sandbox
/tmp/filemHKPGw Build sandbox O=sandbox FTRACE=1 GEN /home/sjg/c/src/third_party/u-boot/files/sandbox/Makefile Configuring for sandbox board... Check results Test passed
Signed-off-by: Simon Glass sjg@chromium.org
Applied to u-boot/master, thanks!
participants (2)
-
Simon Glass
-
Tom Rini