diff options
author | Wolfram Sang <w.sang@pengutronix.de> | 2008-08-13 23:33:06 +0000 |
---|---|---|
committer | Wolfram Sang <w.sang@pengutronix.de> | 2008-08-13 23:33:06 +0000 |
commit | 028ea9e7ad9a1b0ec1d9faf4bb5568b44b50801f (patch) | |
tree | aa0eb35f1b3d3bd4c6ccbad8f345f5efbf463774 /tests | |
parent | 0a0e36ca05824c69bc62f2e236879a2c7aa89b59 (diff) | |
download | ptxdist-028ea9e7ad9a1b0ec1d9faf4bb5568b44b50801f.tar.gz ptxdist-028ea9e7ad9a1b0ec1d9faf4bb5568b44b50801f.tar.xz |
* first set of test scripts also suitable for U-Boot1
git-svn-id: https://svn.pengutronix.de/svn/ptxdist/trunks/ptxdist-trunk@8744 33e552b5-05e3-0310-8538-816dae2090ed
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/flash.kermit | 15 | ||||
-rwxr-xr-x | tests/kwrapper | 20 | ||||
-rw-r--r-- | tests/libptxdisttest.kermit | 110 | ||||
-rw-r--r-- | tests/libptxdisttest.sh | 6 | ||||
-rwxr-xr-x | tests/setenv.kermit | 32 |
5 files changed, 181 insertions, 2 deletions
diff --git a/tests/flash.kermit b/tests/flash.kermit new file mode 100755 index 000000000..c789c9090 --- /dev/null +++ b/tests/flash.kermit @@ -0,0 +1,15 @@ +#!/usr/bin/kermit + + +#Read the library +take \%1 + +#Set up the line +ptx_init \%2 + +ptx_uboot_enter_shell + +ptx_uboot_exec_single "Flashing kernel" "run prg_kernel" 300 +ptx_uboot_exec_single "Flashing oftree" "run prg_oftree" 10 +#ptx_uboot_exec_single "Flashing jffs2" "run prg_jffs2" 600 + +ptx_exit diff --git a/tests/kwrapper b/tests/kwrapper new file mode 100755 index 000000000..6563d7117 --- /dev/null +++ b/tests/kwrapper @@ -0,0 +1,20 @@ +#!/bin/bash + +OURDIR="$(dirname $0)" +KSCRIPT="${OURDIR}/$1.kermit" +LIB="${OURDIR}/libptxdisttest.kermit" + +if [ ! -e ${PTXDIST_WORKSPACE}/boardsetup/boardsetup ]; then + echo "Please run 'ptxdist boardsetup' first!" + exit 1 +fi + +if [ ! -e $LIB ]; then + echo "Could not find $LIB!" + exit 1 +fi + +#we _must_ set the variables in kermit using 'define'! '.' has a bug there (patch already mainlined). +sed -e 's/^\(PTXCONF_BOARDSETUP_[A-Z0-9_]*\)=/define \1 /' ${PTXDIST_WORKSPACE}/boardsetup/boardsetup >/tmp/boardsetup.kermit + +$KSCRIPT ${LIB} /tmp/boardsetup.kermit $2 diff --git a/tests/libptxdisttest.kermit b/tests/libptxdisttest.kermit new file mode 100644 index 000000000..6f9902fd7 --- /dev/null +++ b/tests/libptxdisttest.kermit @@ -0,0 +1,110 @@ +#!/usr/bin/kermit +define ptx_init { + + take \%1 + + set line \m(PTXCONF_BOARDSETUP_SERIALPORT) + set speed \m(PTXCONF_BOARDSETUP_SERIALBAUDRATE) + set parity none + set stop-bits 1 + set carrier-watch off + set handshake none + set flow-control none + robust + + set input cancellation off + set input case observe + set input buffer-length 16384 + + writeln ERROR "Communicating via \m(PTXCONF_BOARDSETUP_SERIALPORT) at \m(PTXCONF_BOARDSETUP_SERIALBAUDRATE) bps." + writeln ERROR + writeln ERROR "===============================" + writeln ERROR "Please power on your board now!" + writeln ERROR "===============================" + writeln ERROR + + .uboot_version := 1 + .uboot_prompt := "uboot> " + .wait_time_default := 300 + +} + +define ptx_exit { + + writeln ERROR "All OK!" + exit 0 +} + +define ptx_test_start { + #do padding with '.' + write ERROR "\frpad(\%1,40,.)" +} + +define ptx_test_end { + + writeln ERROR "OK" +} + +define ptx_wait_string { + + if def \%2 { + .wait_time := \%2 + } else { + .wait_time := \m(wait_time_default) + } + input \m(wait_time) \%1 + if failure { + writeln ERROR "FAILED! (waiting for '\%1')" + exit 1 + } +} + +define ptx_uboot_enter_shell { + + ptx_test_start "Logging into U-Boot" + ptx_wait_string "U-Boot" 120 + lineout + ptx_wait_string \m(uboot_prompt) 10 + ptx_test_end +} + +define ptx_uboot_exec { + + if def \%2 { + .wait_time := \%2 + } else { + .wait_time := \m(wait_time_default) + } + lineout "\%1" + input \m(wait_time) \m(uboot_prompt) + if failure { + writeln ERROR "FAILED! (timeout while waiting for shell prompt after \%1)" + exit 1 + } + + if = \m(uboot_version) 2 { + lineout "echo k-res:$?" + input 10 \fpattern(k-res:0$) + + if failure { + writeln ERROR "FAILED! (returncode from \%1 is not 0)" + exit 1 + } + + input 10 \m(uboot_prompt) + } +} + +define ptx_uboot_exec_single { + + ptx_test_start "\%1" + ptx_uboot_exec "\%2" \%3 + ptx_test_end +} + +define ptx_wait_string_single { + + ptx_test_start "\%1" + ptx_wait_string "\%2" \%3 + ptx_test_end +} diff --git a/tests/libptxdisttest.sh b/tests/libptxdisttest.sh index 3f7330430..be54c1a86 100644 --- a/tests/libptxdisttest.sh +++ b/tests/libptxdisttest.sh @@ -158,8 +158,10 @@ remote_busybox() { remote_assure_process() { if remote_busybox then - echo "remote \"ps | grep $1 | grep -v grep\"" >> "$LOGFILE" - local ret=$(remote "ps | grep $1 | grep -v grep") 2>> "$LOGFILE" + #put brackets around the first char of search string, so grep won't hit its own pid + local lookfor="[${1:0:1}]${1:1}" + echo "remote \"ps | grep $lookfor\"" >> "$LOGFILE" + local ret=$(remote "ps | grep $lookfor") 2>> "$LOGFILE" echo "$ret" | grep "$1[$ ]" 2>> "${PTXDIST_WORKSPACE}/test.log" else echo "remote \"ps axo s,comm | grep \\\"^S $1\\\"\"" >> "$LOGFILE" diff --git a/tests/setenv.kermit b/tests/setenv.kermit new file mode 100755 index 000000000..eb02ccbab --- /dev/null +++ b/tests/setenv.kermit @@ -0,0 +1,32 @@ +#!/usr/bin/kermit + + +#Read the library +take \%1 + +#Set up the line +ptx_init \%2 + +ptx_uboot_enter_shell + +ptx_test_start "Setting new environment" +ptx_uboot_exec "printenv" 10 + +open read \%3 +if failure { + writeln ERROR "FAILED! Could not open \%3." + exit 1 +} + +while true { + read \%l + if fail break + ptx_uboot_exec "\%l" 5 +} + +close read + +ptx_uboot_exec "printenv" +#ptx_uboot_exec "saveenv" +ptx_test_end + +ptx_exit |