diff mbox series

[v2] tests: Add bmc hw tests

Message ID 20180815054148.883478-1-amitay@ozlabs.org
State Accepted
Headers show
Series [v2] 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:41 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

v2:

I have dropped "-d p8" from PDBG command line.  This was for my testing
with palmetto.
---
 Makefile.am          |   3 +-
 tests/test_hw_bmc.sh | 113 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 115 insertions(+), 1 deletion(-)
 create mode 100755 tests/test_hw_bmc.sh

Comments

Alistair Popple Aug. 15, 2018, 6:06 a.m. UTC | #1
Awesome, thanks Amitay.

Are you ok with me adding your signed-off-by to this patch when I commit it?

- Alistair

On Wednesday, 15 August 2018 3:41:48 PM AEST Amitay Isaacs wrote:
> 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
> 
> v2:
> 
> I have dropped "-d p8" from PDBG command line.  This was for my testing
> with palmetto.
> ---
>  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 --git a/Makefile.am b/Makefile.am
> index a3f1bcf..fb8a270 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..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
>
Amitay Isaacs Aug. 15, 2018, 6:17 a.m. UTC | #2
On Wed, 2018-08-15 at 16:06 +1000, Alistair Popple wrote:
> Awesome, thanks Amitay.
> 
> Are you ok with me adding your signed-off-by to this patch when I
> commit it?
> 

Sure.

> - Alistair
> 
> On Wednesday, 15 August 2018 3:41:48 PM AEST Amitay Isaacs wrote:
> > 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
> > 
> > v2:
> > 
> > I have dropped "-d p8" from PDBG command line.  This was for my
> > testing
> > with palmetto.
> > ---
> >  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 --git a/Makefile.am b/Makefile.am
> > index a3f1bcf..fb8a270 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..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
> > 
> 
> 

Amitay.
diff mbox series

Patch

diff --git a/Makefile.am b/Makefile.am
index a3f1bcf..fb8a270 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..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