[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kvm-ppc
Subject:    [kvm-unit-tests PATCH 14/14] mkstandalone: add support for powerpc
From:       Andrew Jones <drjones () redhat ! com>
Date:       2015-08-03 14:41:31
Message-ID: 1438612891-3718-15-git-send-email-drjones () redhat ! com
[Download RAW message or body]

PowerPC needs firmware and an exit code snooper.

Signed-off-by: Andrew Jones <drjones@redhat.com>
---
 configure               |  3 +++
 powerpc/run             |  2 +-
 scripts/mkstandalone.sh | 50 +++++++++++++++++++++++++++++++++++++++++++++----
 3 files changed, 50 insertions(+), 5 deletions(-)

diff --git a/configure b/configure
index e1f70bd79d4f7..7b332269e0d2e 100755
--- a/configure
+++ b/configure
@@ -11,6 +11,7 @@ arch=`uname -m | sed -e s/i.86/i386/ | sed -e 's/arm.*/arm/'`
 host=$arch
 cross_prefix=
 snooper=
+firmware=
 
 usage() {
     cat <<-EOF
@@ -85,6 +86,7 @@ elif [ "$arch" = "arm" ] || [ "$arch" = "arm64" ]; then
 elif [ "$arch" = "powerpc" ] || [ "$arch" = "ppc64" ]; then
     testdir=powerpc
     snooper=snoop_exitcode
+    firmware=$testdir/boot_rom.bin
 else
     testdir=$arch
 fi
@@ -140,4 +142,5 @@ AR=$cross_prefix$ar
 API=$api
 TEST_DIR=$testdir
 SNOOPER="$snooper"
+FIRMWARE=$firmware
 EOF
diff --git a/powerpc/run b/powerpc/run
index 5bc826765eff8..1d5b1c9135299 100755
--- a/powerpc/run
+++ b/powerpc/run
@@ -29,7 +29,7 @@ if ! $qemu -machine '?' 2>&1 | grep 'pseries' > /dev/null; then
 	exit 2
 fi
 
-boot_rom='powerpc/boot_rom.bin'
+boot_rom=$FIRMWARE
 if [ -f powerpc/rom/boot_rom.bin ]; then
 	boot_rom='powerpc/rom/boot_rom.bin'
 fi
diff --git a/scripts/mkstandalone.sh b/scripts/mkstandalone.sh
index 4a6e4a3ada1a3..dd10ece6940de 100755
--- a/scripts/mkstandalone.sh
+++ b/scripts/mkstandalone.sh
@@ -17,6 +17,10 @@ elif [ -n "$one_kernel" ] && [ -z "$one_testname" ]; then
 	one_testname="${one_kernel_base%.*}"
 fi
 
+if [ "$SNOOPER" ]; then
+	snooper="| $SNOOPER"
+fi
+
 unittests=$TEST_DIR/unittests.cfg
 mkdir -p tests
 
@@ -51,6 +55,22 @@ function mkstandalone()
 #!/bin/sh
 
 EOF
+if [ "$SNOOPER" = "snoop_exitcode" ]; then
+	cat <<EOF >> $standalone
+snoop_exitcode()
+{
+	while read line; do
+		if echo \$line | grep 'EXIT: STATUS=' > /dev/null; then
+			code=\`echo \$line | cut -d= -f2\`
+		fi
+		echo \$line
+	done
+	exit \$code
+}
+
+EOF
+fi
+
 if [ "$arch" ]; then
 	cat <<EOF >> $standalone
 ARCH=\`uname -m | sed -e s/i.86/i386/ | sed -e 's/arm.*/arm/'\`
@@ -82,7 +102,21 @@ exit 1
 EOF
 else
 	cat <<EOF >> $standalone
-trap 'rm -f \$bin; exit 1' HUP INT TERM
+trap 'rm -f \$fwbin \$bin; exit 1' HUP INT TERM
+
+EOF
+if [ -f "$FIRMWARE" ]; then
+	cat <<EOF >> $standalone
+fwbin=\`mktemp\`
+base64 -d << 'BIN_EOF' | zcat > \$fwbin &&
+EOF
+gzip - < $FIRMWARE | base64 >> $standalone
+	cat <<EOF >> $standalone
+BIN_EOF
+
+EOF
+fi
+	cat <<EOF >> $standalone
 bin=\`mktemp\`
 base64 -d << 'BIN_EOF' | zcat > \$bin &&
 EOF
@@ -101,9 +135,17 @@ while \$qemu \$cmdline -smp \$MAX_SMP 2>&1 | grep 'exceeds max cpus' > /dev/null
 	MAX_SMP=\`expr \$MAX_SMP - 1\`
 done
 
-cmdline="\`echo '$cmdline' | sed s%$kernel%\$bin%\`"
+cmdline='$cmdline'
+EOF
+if [ "$FIRMWARE" ]; then
+	cat <<EOF >> $standalone
+cmdline="\`echo \$cmdline | sed s%$FIRMWARE%\$fwbin%\`"
+EOF
+fi
+	cat <<EOF >> $standalone
+cmdline="\`echo \$cmdline | sed s%$kernel%\$bin%\`"
 echo \$qemu $cmdline -smp $smp $opts
-\$qemu \$cmdline -smp $smp $opts
+\$qemu \$cmdline -smp $smp $opts $snooper
 ret=\$?
 echo Return value from qemu: \$ret
 if [ \$ret -le 1 ]; then
@@ -111,7 +153,7 @@ if [ \$ret -le 1 ]; then
 else
 	echo FAIL $testname 1>&2
 fi
-rm -f \$bin
+rm -f \$fwbin \$bin
 exit 0
 EOF
 fi
-- 
2.4.3

--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic