From 7950f2b7d47dc8921cbdfa52cb549f4d59aa5d1d Mon Sep 17 00:00:00 2001
From: Jerome Forissier <jerome.forissier@linaro.org>
Date: Thu, 3 Sep 2015 10:35:29 +0200
Subject: [PATCH] qemu-check.exp: fixes/improvements for Travis CI environment

* Detect kernel rcu_sched stall + cosmetic improvements
* Start QEMU with options '-nographic -monitor none'. Without this,
QEMU cannot be run on the Travis servers which have no display.
'-monitor none' is needed when '-nographic' is set and one wants to
redirect serial port 0 (first occurrence of '-serial stdio'), otherwise
a conflict occurs and the following message is shown:
    qemu-system-arm: -serial stdio: cannot use stdio by multiple character
    devices
* Fix undefined variable error on timeout
* Set LD_LIBRARY_PATH. The libraries that come with the compiler
sometimes end up under /lib, or under /lib/arm-linx-gnueabihf. By setting
LD_LIBRARY_PATH we support both.
* Catch kernel panic/timeout on boot to make the script more robust.

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: Joakim Bech <joakim.bech@linaro.org>
---
 qemu-check.exp | 27 +++++++++++++++++++++++----
 1 file changed, 23 insertions(+), 4 deletions(-)

diff --git a/qemu-check.exp b/qemu-check.exp
index eb78650..cff9ba5 100644
--- a/qemu-check.exp
+++ b/qemu-check.exp
@@ -38,11 +38,24 @@ log_user 0
 # Save guest console output to a file
 log_file -a -noappend "serial0.log"
 info "Starting QEMU..."
-spawn ../qemu/arm-softmmu/qemu-system-arm -machine virt -cpu cortex-a15 -m 1057 -serial stdio -serial file:serial1.log -bios $bios
-expect "*Please press Enter to activate this console. "
+spawn ../qemu/arm-softmmu/qemu-system-arm -nographic -monitor none -machine virt -cpu cortex-a15 -m 1057 -serial stdio -serial file:serial1.log -bios $bios
+expect {
+	"Kernel panic" {
+		info "!!! Kernel panic\n"
+		exit 1
+	}
+	timeout {
+		info "!!! Timeout\n"
+		exit 1
+	}
+	"Please press Enter to activate this console. "
+}
 send -- "\r"
 expect "root@Vexpress:/ "
 info " done, guest is booted.\nLoading OP-TEE driver and tee-supplicant..."
+# Toolchain libraries might be here or there
+send -- "export LD_LIBRARY_PATH=/lib:/lib/arm-linux-gnueabihf\r"
+expect "root@Vexpress:/ "
 send -- "modprobe optee_armtz\r"
 expect "root@Vexpress:/ "
 sleep 1
@@ -51,10 +64,15 @@ expect "root@Vexpress:/ "
 sleep 1
 info " done.\nRunning: $cmd...\n"
 send -- "$cmd\r"
+set casenum "none"
 expect {
 	# Exit with error status as soon as a test fails
 	-re {  XTEST_TEE_([^ ]+) FAIL} {
-		info "$expect_out(1,string) FAIL"
+		info " $expect_out(1,string) FAIL\n"
+		exit 1
+	}
+	-re {rcu_sched detected stalls} {
+		info " Kernel error: '$expect_out(0,string)'\n"
 		exit 1
 	}
 	# Crude progress indicator: print one # when each test [sub]case starts
@@ -72,13 +90,14 @@ expect {
 		}
 		info "#"
 		incr ncases
+		if {$ncases % 50 == 0} { info "\n" }
 		exp_continue
 	}
 	# Exit when result separator is seen
 	"+-----------------------------------------------------\r\r" {}
 	timeout {
 		info "!!! Timeout\n"
-		info "TIMEOUT - test case too long or hung? ($casenum)\n"
+		info "TIMEOUT - test case too long or hung? (last test started: $casenum)\n"
 		exit 2
 	}
 }
-- 
GitLab