summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAlistair Popple <alistair@popple.id.au>2018-08-15 15:41:48 +1000
committerAlistair Popple <alistair@popple.id.au>2018-09-07 13:42:16 +1000
commit151fdf604521867320c7eb94b9a97ebd6f4d86b8 (patch)
tree873f6a38af1c2980d70f35e366818fd9d3c51ddc /tests
parent4fe0c9ffde474be561bec6fb4add5176b28607cb (diff)
downloadpdbg-151fdf604521867320c7eb94b9a97ebd6f4d86b8.tar.gz
pdbg-151fdf604521867320c7eb94b9a97ebd6f4d86b8.zip
tests: Add bmc hw tests
Reworked bmc hw test based on the updates to the test driver. This uses .test.bmc file to set up environment for the tests. Following variables are needed: BMC_HOST BMC_USER BMC_PASS PDBG_ARM_BUILD Signed-off-by: Alistair Popple <alistair@popple.id.au> Signed-off-by: Amitay Isaacs <amitay@ozlabs.org>
Diffstat (limited to 'tests')
-rwxr-xr-xtests/test_hw_bmc.sh113
1 files changed, 113 insertions, 0 deletions
diff --git a/tests/test_hw_bmc.sh b/tests/test_hw_bmc.sh
new file mode 100755
index 0000000..7054181
--- /dev/null
+++ b/tests/test_hw_bmc.sh
@@ -0,0 +1,113 @@
+#!/bin/bash
+
+. $(dirname "$0")/driver.sh
+
+BMC_TEST=".test.bmc"
+
+BMC_HOST=
+BMC_USER=
+BMC_PASS=
+
+PDBG_ARM_BUILD=
+PDBG_PATH=/tmp/pdbg
+PDBG=${PDBG_PATH}/pdbg
+
+load_config ()
+{
+ if [ ! -f "$BMC_TEST" ] ; then
+ echo "Missing file $BMC_TEST, skipping tests"
+ return 77
+ fi
+
+ fail=0
+ . "$BMC_TEST"
+
+ for var in "BMC_HOST" "BMC_USER" "BMC_PASS" "PDBG_ARM_BUILD"; do
+ eval value="\$$var"
+ if [ -z "$value" ] ; then
+ echo "$var not defined in $BMC_TEST"
+ fail=1
+ fi
+ done
+
+ return $fail
+}
+
+copy_pdbg ()
+{
+ sshpass -p "$BMC_PASS" \
+ rsync -Pav "${PDBG_ARM_BUILD}/.libs/"* \
+ ${BMC_USER}@${BMC_HOST}:${PDBG_PATH}
+}
+
+test_wrapper ()
+{
+ sshpass -p "$BMC_PASS" \
+ ssh ${BMC_USER}@${BMC_HOST} \
+ LD_LIBRARY_PATH="${PDBG_PATH}" \
+ "$@"
+}
+
+test_setup load_config
+test_setup copy_pdbg
+
+test_group "BMC HW tests"
+
+hw_state=0
+
+do_skip ()
+{
+ if [ $hw_state -ne 1 ] ; then
+ test_skip
+ fi
+}
+
+echo -n "Checking if the host is up... "
+output=$(test_wrapper /usr/sbin/obmcutil state | grep CurrentHostState)
+rc=$?
+if [ $rc -ne 0 ] || \
+ [ "$output" != "xyz.openbmc_project.State.Host.HostState.Running" ] ; then
+ echo "yes"
+ hw_state=1
+else
+ echo "no"
+fi
+
+result_filter ()
+{
+ sed -E -e 's#0x[[:xdigit:]]{16}#HEX16#' \
+ -E -e 's#0x[[:xdigit:]]{8}#HEX8#'
+}
+
+test_result 0 <<EOF
+p0:0xc09 = HEX8
+EOF
+
+do_skip
+test_run $PDBG -p0 getcfam 0xc09
+
+test_result 0 <<EOF
+p0:0xf000f = HEX16
+EOF
+
+do_skip
+test_run $PDBG -p0 getscom 0xf000f
+
+result_filter ()
+{
+ result_filter_default
+}
+
+test_result 0 <<EOF
+Wrote 8 bytes starting at 0x0000000031000000
+EOF
+
+do_skip
+echo -n "DEADBEEF" | test_run $PDBG -p0 putmem 0x31000000
+
+test_result 0 <<EOF
+DEADBEEF
+EOF
+
+do_skip
+test_run $PDBG -p0 getmem 0x31000000 0x8
OpenPOWER on IntegriCloud