summaryrefslogtreecommitdiffstats
path: root/tests/libptxdisttest.sh
diff options
context:
space:
mode:
authorJochen Frieling <j.frieling@pengutronix.de>2008-06-16 17:16:37 +0000
committerJochen Frieling <j.frieling@pengutronix.de>2008-06-16 17:16:37 +0000
commite0e5bea683bda29d3178c85561de101ca5f30eb8 (patch)
tree876f462e2466f330c0ca342df0610abda11bedfd /tests/libptxdisttest.sh
parent420d1b114db5612418bc2a6ce2670223c2fdf77e (diff)
downloadptxdist-e0e5bea683bda29d3178c85561de101ca5f30eb8.tar.gz
ptxdist-e0e5bea683bda29d3178c85561de101ca5f30eb8.tar.xz
* ptxdist: pull platform dependent part out of platformconfig
git-svn-id: https://svn.pengutronix.de/svn/ptxdist/trunks/ptxdist-trunk@8526 33e552b5-05e3-0310-8538-816dae2090ed
Diffstat (limited to 'tests/libptxdisttest.sh')
-rw-r--r--tests/libptxdisttest.sh143
1 files changed, 84 insertions, 59 deletions
diff --git a/tests/libptxdisttest.sh b/tests/libptxdisttest.sh
index 20067a919..6309e246a 100644
--- a/tests/libptxdisttest.sh
+++ b/tests/libptxdisttest.sh
@@ -1,47 +1,48 @@
# Library for acctest acceptance tests done by ssh access to the target
# to be sourced at beginning of tests/acctest bash script
#
-# 2007-08 PTX,JFR
+# 2007-08, 2008-06 jfr@pengutronix.de
# needs bash
+# Choose the communication method: 'ssh' or 'rsh'
+SSH_COMMAND='rsh'
+
+LOGFILE="${PTXDIST_WORKSPACE}/test.log"
+
+
RED='\0033[1;31m'
GREEN='\0033[1;32m'
NC='\0033[0m' # No Color
ok_count=0
fail_count=0
-# SSH_COMMAND='ssh -q -o StrictHostKeyChecking=no'
-SSH_COMMAND='rsh'
-LOGFILE="${PTXDIST_WORKSPACE}/test.log"
-
checking() {
- printf "%-71s" "checking $1" >&2
+ printf "%-71s" "checking $1" >&2
}
result_ok() {
- printf "%8b" "[${GREEN} OK ${NC}]\n" >&2
- (( ok_count++ ))
+ printf "%8b" "[${GREEN} OK ${NC}]\n" >&2
+ (( ok_count++ ))
}
result_fail() {
- printf "%8b" "[${RED}FAILED${NC}]\n" >&2
- (( fail_count++ ))
-
+ printf "%8b" "[${RED}FAILED${NC}]\n" >&2
+ (( fail_count++ ))
}
result() {
- if [ "$?" = "0" ]; then
- printf "%8b" "[${GREEN} OK ${NC}]\n" >&2
- (( ok_count++ ))
- else
- printf "%8b" "[${RED}FAILED${NC}]\n" >&2
- (( fail_count++ ))
+ if [ "$?" = "0" ]; then
+ printf "%8b" "[${GREEN} OK ${NC}]\n" >&2
+ (( ok_count++ ))
+ else
+ printf "%8b" "[${RED}FAILED${NC}]\n" >&2
+ (( fail_count++ ))
if [ "$1" = "fatal" ]; then
printf "%8b" "${RED}Fatal. Cannot continue.${NC}\n" >&2
exit 1
fi
- fi
+ fi
}
#
@@ -49,61 +50,85 @@ result() {
#
remote() {
- echo "$SSH_COMMAND root@${PTXCONF_BOARDSETUP_TARGETIP} $1" >> "$LOGFILE"
- $SSH_COMMAND -l root ${PTXCONF_BOARDSETUP_TARGETIP} $1 2>> "$LOGFILE"
+ case "$SSH_COMMAND" in
+ 'ssh')
+ echo "ssh -q -o StrictHostKeyChecking=no -l root ${PTXCONF_BOARDSETUP_TARGETIP} $1" >> "$LOGFILE"
+ local stdoutret=$(ssh -l root ${PTXCONF_BOARDSETUP_TARGETIP} $1'; echo ret=$?') 2>> "$LOGFILE"
+ ;;
+ 'rsh')
+ echo "rsh -l root ${PTXCONF_BOARDSETUP_TARGETIP} $1" >> "$LOGFILE"
+ local stdoutret=$(rsh -l root ${PTXCONF_BOARDSETUP_TARGETIP} $1'; echo ret=$?') 2>> "$LOGFILE"
+ ;;
+ *)
+ echo "Error: No or wrong remote-shell command defined in test script $0" >> "$LOGFILE"
+ false
+ esac
+ local stdout=$(echo "$stdoutret" | head -n-1)
+ local retvalline=$(echo "$stdoutret" | tail -n1)
+ if [ ${retvalline:0:4} = "ret=" ]
+ then # The "ret=" is on a line of its own
+ local retvallinestdoutpart=""
+ local retvallineretpart=""
+ else # There was no newline before "ret="
+ local retvallineretpart=$(expr "$retvalline" : '.*\(ret=.*\)')
+ local retvallinestdoutpart="${retvalline%$retvallineretpart}"
+ retvalline="$retvallineretpart"
+ fi
+ echo "$stdout"
+ echo -n "$retvallinestdoutpart"
+ return ${retvalline:4}
}
-
remote_compare() {
- echo "test \"\$\($SSH_COMMAND root@${PTXCONF_BOARDSETUP_TARGETIP} $1\)\" = \"$2\"" >> "$LOGFILE"
- local ret=$($SSH_COMMAND root@${PTXCONF_BOARDSETUP_TARGETIP} $1) 2>> "$LOGFILE"
- test "$ret" = "$2" 2>> "${PTXDIST_WORKSPACE}/test.log"
+ echo "test \"remote $1\)\" = \"$2\"" >> "$LOGFILE"
+ local ret=$(remote $1) 2>> "$LOGFILE"
+ test "$ret" = "$2" 2>> "${PTXDIST_WORKSPACE}/test.log"
}
remote_assure_module() {
# this should not be used as an indicator for functionality:
# don't just check on loaded modules; rather check their indirect signs of operationality.
- echo "$SSH_COMMAND root@${PTXCONF_BOARDSETUP_TARGETIP} lsmod | grep \"^$1 \"" >> "$LOGFILE"
- local ret=$($SSH_COMMAND root@${PTXCONF_BOARDSETUP_TARGETIP} lsmod | grep "^$1 ") 2>> "$LOGFILE"
- test "${ret:0:${#1}}" = "$1" 2>> "${PTXDIST_WORKSPACE}/test.log"
+ echo "remote lsmod | grep \"^$1 \"" >> "$LOGFILE"
+ local ret=$(remote lsmod | grep "^$1 ") 2>> "$LOGFILE"
+ test "${ret:0:${#1}}" = "$1" 2>> "${PTXDIST_WORKSPACE}/test.log"
}
remote_assure_process() {
- local bbtest=$($SSH_COMMAND root@${PTXCONF_BOARDSETUP_TARGETIP} ps --help 2>&1 | grep ^BusyBox) 2>> "$LOGFILE"
- if [ "${bbtest:0:7}" = "BusyBox" ]
- then
- echo "$SSH_COMMAND root@${PTXCONF_BOARDSETUP_TARGETIP} ps | grep \"$1\" | grep -v grep" >> "$LOGFILE"
- local ret=$($SSH_COMMAND root@${PTXCONF_BOARDSETUP_TARGETIP} ps | grep $1 | grep -v grep) 2>> "$LOGFILE"
- echo "$ret" | grep "$1[$ ]" 2>> "${PTXDIST_WORKSPACE}/test.log"
- else
- echo "$SSH_COMMAND root@${PTXCONF_BOARDSETUP_TARGETIP} ps axo s,comm | grep \"^S $1\"" >> "$LOGFILE"
- local ret=$($SSH_COMMAND root@${PTXCONF_BOARDSETUP_TARGETIP} ps axo s,comm | grep "^S $1") 2>> "$LOGFILE"
- test "${ret:2:${#1}}" = "$1" 2>> "${PTXDIST_WORKSPACE}/test.log"
- fi
+ local bbtest=$($SSH_COMMAND root@${PTXCONF_BOARDSETUP_TARGETIP} ps --help 2>&1 | grep ^BusyBox) 2>> "$LOGFILE"
+ if [ "${bbtest:0:7}" = "BusyBox" ]
+ then
+ echo "remote ps | grep \"$1\" | grep -v grep" >> "$LOGFILE"
+ local ret=$(remote ps | grep $1 | grep -v grep) 2>> "$LOGFILE"
+ echo "$ret" | grep "$1[$ ]" 2>> "${PTXDIST_WORKSPACE}/test.log"
+ else
+ echo "remote ps axo s,comm | grep \"^S $1\"" >> "$LOGFILE"
+ local ret=$(remote ps axo s,comm | grep "^S $1") 2>> "$LOGFILE"
+ test "${ret:2:${#1}}" = "$1" 2>> "${PTXDIST_WORKSPACE}/test.log"
+ fi
}
remote_file() {
- case "$2" in
- 'block')
- echo "$SSH_COMMAND root@${PTXCONF_BOARDSETUP_TARGETIP} test -b \"$1\"" >> "$LOGFILE"
- $SSH_COMMAND root@${PTXCONF_BOARDSETUP_TARGETIP} test -b "$1" 2>> "$LOGFILE"
- ;;
- 'character')
- echo "$SSH_COMMAND root@${PTXCONF_BOARDSETUP_TARGETIP} test -c \"$1\"" >> "$LOGFILE"
- $SSH_COMMAND root@${PTXCONF_BOARDSETUP_TARGETIP} test -c "$1" 2>> "$LOGFILE"
- ;;
- 'exists')
- echo "$SSH_COMMAND root@${PTXCONF_BOARDSETUP_TARGETIP} test -e \"$1\"" >> "$LOGFILE"
- $SSH_COMMAND root@${PTXCONF_BOARDSETUP_TARGETIP} test -e "$1" 2>> "$LOGFILE"
- ;;
- 'executable')
- echo "$SSH_COMMAND root@${PTXCONF_BOARDSETUP_TARGETIP} test -x \"$1\"" >> "$LOGFILE"
- $SSH_COMMAND root@${PTXCONF_BOARDSETUP_TARGETIP} test -x "$1" 2>> "$LOGFILE"
- ;;
- *)
- echo "Syntax error in test script $0" >> "$LOGFILE"
- false
- esac
+ case "$2" in
+ 'block')
+ echo "remote test -b \"$1\"" >> "$LOGFILE"
+ remote test -b "$1" 2>> "$LOGFILE"
+ ;;
+ 'character')
+ echo "remote test -c \"$1\"" >> "$LOGFILE"
+ remote test -c "$1" 2>> "$LOGFILE"
+ ;;
+ 'exists')
+ echo "remote test -e \"$1\"" >> "$LOGFILE"
+ remote test -e "$1" 2>> "$LOGFILE"
+ ;;
+ 'executable')
+ echo "remote test -x \"$1\"" >> "$LOGFILE"
+ remote test -x "$1" 2>> "$LOGFILE"
+ ;;
+ *)
+ echo "Syntax error in test script $0" >> "$LOGFILE"
+ false
+ esac
}
all_on_board() {