[kvm-unit-tests,v5,15/18] powerpc/ppc64: add run script and unittests.cfg
diff mbox

Message ID 1455734459-31902-16-git-send-email-drjones@redhat.com
State Superseded
Headers show

Commit Message

Andrew Jones Feb. 17, 2016, 6:40 p.m. UTC
Now that we have all the pieces, pull them together into a
run script (adapted from arm's). To run a test do './powerpc-run
powerpc/test.elf'. To run all tests in unittests.cfg do
'./run_tests.sh'

(We can now run simple unit tests, but they don't quit on their
 own yet. Use ^C to quit them.)

Signed-off-by: Andrew Jones <drjones@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Tested-by: Laurent Vivier <lvivier@redhat.com>
---
 powerpc/run           | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++
 powerpc/unittests.cfg | 30 +++++++++++++++++++++++++++++
 2 files changed, 82 insertions(+)
 create mode 100755 powerpc/run
 create mode 100644 powerpc/unittests.cfg

Comments

David Gibson Feb. 19, 2016, 3:43 a.m. UTC | #1
On Wed, Feb 17, 2016 at 07:40:56PM +0100, Andrew Jones wrote:
> Now that we have all the pieces, pull them together into a
> run script (adapted from arm's). To run a test do './powerpc-run
> powerpc/test.elf'. To run all tests in unittests.cfg do
> './run_tests.sh'
> 
> (We can now run simple unit tests, but they don't quit on their
>  own yet. Use ^C to quit them.)
> 
> Signed-off-by: Andrew Jones <drjones@redhat.com>
> Reviewed-by: Thomas Huth <thuth@redhat.com>
> Tested-by: Laurent Vivier <lvivier@redhat.com>

Reviewed-by: David Gibson <david@gibson.dropbear.id.au>

> ---
>  powerpc/run           | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++
>  powerpc/unittests.cfg | 30 +++++++++++++++++++++++++++++
>  2 files changed, 82 insertions(+)
>  create mode 100755 powerpc/run
>  create mode 100644 powerpc/unittests.cfg
> 
> diff --git a/powerpc/run b/powerpc/run
> new file mode 100755
> index 0000000000000..47aecb7600832
> --- /dev/null
> +++ b/powerpc/run
> @@ -0,0 +1,52 @@
> +#!/bin/bash
> +
> +if [ -z "$STANDALONE" ]; then
> +	if [ ! -f config.mak ]; then
> +		echo "run ./configure && make first. See ./configure -h"
> +		exit 2
> +	fi
> +	source config.mak
> +fi
> +
> +if [ -c /dev/kvm ]; then
> +	if [ "$HOST" = "ppc64" ] && [ "$ARCH" = "ppc64" ]; then
> +		kvm_available=yes
> +	fi
> +fi
> +
> +if [ "$ACCEL" = "kvm" ] && [ "$kvm_available" != "yes" ]; then
> +	echo "skip $TESTNAME (kvm only)"
> +	exit 2
> +fi
> +
> +if [ -z "$ACCEL" ]; then
> +	if [ "$kvm_available" = "yes" ]; then
> +		ACCEL="kvm"
> +	else
> +		ACCEL="tcg"
> +	fi
> +fi
> +
> +qemu="${QEMU:-qemu-system-$ARCH_NAME}"
> +qpath=$(which $qemu 2>/dev/null)
> +
> +if [ -z "$qpath" ]; then
> +	echo $qemu not found.
> +	exit 2
> +fi
> +
> +if ! $qemu -machine '?' 2>&1 | grep 'pseries' > /dev/null; then
> +	echo "$qpath doesn't support pSeries ('-machine pseries'). Exiting."
> +	exit 2
> +fi
> +
> +M='-machine pseries'
> +M+=",accel=$ACCEL"
> +command="$qemu $M -bios powerpc/boot_rom.bin"
> +command+=" -display none -serial stdio -kernel"
> +echo $command "$@"
> +
> +$command "$@"
> +ret=$?
> +echo Return value from qemu: $ret
> +exit $ret
> diff --git a/powerpc/unittests.cfg b/powerpc/unittests.cfg
> new file mode 100644
> index 0000000000000..60f9be80e8abf
> --- /dev/null
> +++ b/powerpc/unittests.cfg
> @@ -0,0 +1,30 @@
> +##############################################################################
> +# unittest configuration
> +#
> +# [unittest_name]
> +# file = <name>.flat		# Name of the flat file to be used.
> +# smp  = <num>			# Number of processors the VM will use
> +#				# during this test. Use $MAX_SMP to use
> +#				# the maximum the host supports. Defaults
> +#				# to one.
> +# extra_params = -append <params...>	# Additional parameters used.
> +# arch = ppc64				# Select one if the test case is
> +#					# specific to only one.
> +# groups = <group_name1> <group_name2> ...	# Used to identify test cases
> +#						# with run_tests -g ...
> +# accel = kvm|tcg		# Optionally specify if test must run with
> +#				# kvm or tcg. If not specified, then kvm will
> +#				# be used when available.
> +# timeout = <duration>		# Optionally specify a timeout.
> +##############################################################################
> +
> +#
> +# Test that the configured number of processors (smp = <num>), and
> +# that the configured amount of memory (-m <MB>) are correctly setup
> +# by the framework.
> +#
> +[selftest-setup]
> +file = selftest.elf
> +smp = 2
> +extra_params = -m 256 -append 'setup smp=2 mem=256'
> +groups = selftest

Patch
diff mbox

diff --git a/powerpc/run b/powerpc/run
new file mode 100755
index 0000000000000..47aecb7600832
--- /dev/null
+++ b/powerpc/run
@@ -0,0 +1,52 @@ 
+#!/bin/bash
+
+if [ -z "$STANDALONE" ]; then
+	if [ ! -f config.mak ]; then
+		echo "run ./configure && make first. See ./configure -h"
+		exit 2
+	fi
+	source config.mak
+fi
+
+if [ -c /dev/kvm ]; then
+	if [ "$HOST" = "ppc64" ] && [ "$ARCH" = "ppc64" ]; then
+		kvm_available=yes
+	fi
+fi
+
+if [ "$ACCEL" = "kvm" ] && [ "$kvm_available" != "yes" ]; then
+	echo "skip $TESTNAME (kvm only)"
+	exit 2
+fi
+
+if [ -z "$ACCEL" ]; then
+	if [ "$kvm_available" = "yes" ]; then
+		ACCEL="kvm"
+	else
+		ACCEL="tcg"
+	fi
+fi
+
+qemu="${QEMU:-qemu-system-$ARCH_NAME}"
+qpath=$(which $qemu 2>/dev/null)
+
+if [ -z "$qpath" ]; then
+	echo $qemu not found.
+	exit 2
+fi
+
+if ! $qemu -machine '?' 2>&1 | grep 'pseries' > /dev/null; then
+	echo "$qpath doesn't support pSeries ('-machine pseries'). Exiting."
+	exit 2
+fi
+
+M='-machine pseries'
+M+=",accel=$ACCEL"
+command="$qemu $M -bios powerpc/boot_rom.bin"
+command+=" -display none -serial stdio -kernel"
+echo $command "$@"
+
+$command "$@"
+ret=$?
+echo Return value from qemu: $ret
+exit $ret
diff --git a/powerpc/unittests.cfg b/powerpc/unittests.cfg
new file mode 100644
index 0000000000000..60f9be80e8abf
--- /dev/null
+++ b/powerpc/unittests.cfg
@@ -0,0 +1,30 @@ 
+##############################################################################
+# unittest configuration
+#
+# [unittest_name]
+# file = <name>.flat		# Name of the flat file to be used.
+# smp  = <num>			# Number of processors the VM will use
+#				# during this test. Use $MAX_SMP to use
+#				# the maximum the host supports. Defaults
+#				# to one.
+# extra_params = -append <params...>	# Additional parameters used.
+# arch = ppc64				# Select one if the test case is
+#					# specific to only one.
+# groups = <group_name1> <group_name2> ...	# Used to identify test cases
+#						# with run_tests -g ...
+# accel = kvm|tcg		# Optionally specify if test must run with
+#				# kvm or tcg. If not specified, then kvm will
+#				# be used when available.
+# timeout = <duration>		# Optionally specify a timeout.
+##############################################################################
+
+#
+# Test that the configured number of processors (smp = <num>), and
+# that the configured amount of memory (-m <MB>) are correctly setup
+# by the framework.
+#
+[selftest-setup]
+file = selftest.elf
+smp = 2
+extra_params = -m 256 -append 'setup smp=2 mem=256'
+groups = selftest