Skip to content

Commit 129acd4

Browse files
sjg20trini
authored andcommitted
test: Add a test for command repeat
This performs a command, then repeats it, and checks that the repeat happens. Signed-off-by: Simon Glass <[email protected]>
1 parent 07b3427 commit 129acd4

File tree

3 files changed

+52
-17
lines changed

3 files changed

+52
-17
lines changed

test/cmd_repeat.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/sh
2+
3+
# Test for U-Boot cli including command repeat
4+
5+
BASE="$(dirname $0)"
6+
. $BASE/common.sh
7+
8+
run_test() {
9+
./${OUTPUT_DIR}/u-boot <<END
10+
setenv ctrlc_ignore y
11+
md 0
12+
13+
reset
14+
END
15+
}
16+
check_results() {
17+
echo "Check results"
18+
19+
grep -q 00000100 ${tmp} || fail "Command did not repeat"
20+
}
21+
22+
echo "Test CLI repeat"
23+
echo
24+
tmp="$(tempfile)"
25+
build_uboot
26+
run_test >${tmp}
27+
check_results ${tmp}
28+
rm ${tmp}
29+
echo "Test passed"

test/common.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/sh
2+
3+
OUTPUT_DIR=sandbox
4+
5+
fail() {
6+
echo "Test failed: $1"
7+
if [ -n ${tmp} ]; then
8+
rm ${tmp}
9+
fi
10+
exit 1
11+
}
12+
13+
build_uboot() {
14+
echo "Build sandbox"
15+
OPTS="O=${OUTPUT_DIR} $1"
16+
NUM_CPUS=$(grep -c processor /proc/cpuinfo)
17+
echo ${OPTS}
18+
make ${OPTS} sandbox_config
19+
make ${OPTS} -s -j${NUM_CPUS}
20+
}

test/trace/test-trace.sh

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,10 @@
55

66
# Simple test script for tracing with sandbox
77

8-
OUTPUT_DIR=sandbox
98
TRACE_OPT="FTRACE=1"
109

11-
fail() {
12-
echo "Test failed: $1"
13-
if [ -n ${tmp} ]; then
14-
rm ${tmp}
15-
fi
16-
exit 1
17-
}
18-
19-
build_uboot() {
20-
echo "Build sandbox"
21-
OPTS="O=${OUTPUT_DIR} ${TRACE_OPT}"
22-
NUM_CPUS=$(grep -c processor /proc/cpuinfo)
23-
make ${OPTS} sandbox_config
24-
make ${OPTS} -s -j${NUM_CPUS}
25-
}
10+
BASE="$(dirname $0)/.."
11+
. $BASE/common.sh
2612

2713
run_trace() {
2814
echo "Run trace"
@@ -69,7 +55,7 @@ check_results() {
6955
echo "Simple trace test / sanity check using sandbox"
7056
echo
7157
tmp="$(tempfile)"
72-
build_uboot
58+
build_uboot "${TRACE_OPT}"
7359
run_trace >${tmp}
7460
check_results ${tmp}
7561
rm ${tmp}

0 commit comments

Comments
 (0)