diff mbox series

tests: Add bmc hw tests

Message ID 20180815050617.856015-1-amitay@ozlabs.org
State Superseded
Headers show
Series tests: Add bmc hw tests | expand

Checks

Context Check Description
snowpatch_ozlabs/apply_patch success master/apply_patch Successfully applied
snowpatch_ozlabs/build-multiarch success Test build-multiarch on branch master

Commit Message

Amitay Isaacs Aug. 15, 2018, 5:06 a.m. UTC
From: Alistair Popple <alistair@popple.id.au>

Alistair,

Here's 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
---
 Makefile.am          |   3 +-
 tests/test_hw_bmc.sh | 113 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 115 insertions(+), 1 deletion(-)
 create mode 100755 tests/test_hw_bmc.sh
diff mbox series

Patch

diff --git a/Makefile.am b/Makefile.am
index 215f997..5036a57 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -7,7 +7,8 @@  bin_PROGRAMS = pdbg
 check_PROGRAMS = optcmd_test
 
 PDBG_TESTS = \
-	tests/test_selection.sh
+	tests/test_selection.sh 	\
+	tests/test_hw_bmc.sh
 
 TESTS = optcmd_test $(PDBG_TESTS)
 
diff --git a/tests/test_hw_bmc.sh b/tests/test_hw_bmc.sh
new file mode 100755
index 0000000..327add3
--- /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 -d p8 -p0 getcfam 0xc09
+
+test_result 0 <<EOF
+p0:0xf000f = HEX16
+EOF
+
+do_skip
+test_run $PDBG -d p8 -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 -d p8 -p0 putmem 0x31000000
+
+test_result 0 <<EOF
+DEADBEEF
+EOF
+
+do_skip
+test_run $PDBG -d p8 -p0 getmem 0x31000000 0x8