[Fuego] [PATCH 2/7] reboot: fix the reboot test

Daniel Sangorrin daniel.sangorrin at toshiba.co.jp
Wed Nov 2 06:29:06 UTC 2016


This patch fixes the reboot test:
  - tests.info: reboot has only a time plot at the moment. The
    memory and disk plots are not available so remove them
    until implemented.
    TODO: why are there two tests.info files?
  - functions.sh: instead of using a magic number it's better
    to let the user choose the maximum tries depending on the
    board
  - parser.py: adapt regex patterns to current kernels where
    the typical message is:
    [  timestamp] Freeing unused kernel memory
    In fact the current search pattern included 264K so probably
    it only worked for oneboard.
    The key time.init is changed to 'time' in order to
    match tests.info.
  - reboot: dmesg is more common than logread, so choose that.
    And search for 'Freeing' only because new kernels show
    a sligthly different message (Freeing unused kernel ..)
  - reference.log: a kernel should usually boot in less than
    10s not 1000s.

Signed-off-by: Daniel Sangorrin <daniel.sangorrin at toshiba.co.jp>
---
 engine/scripts/functions.sh                 | 27 +++++++++++++++++++--------
 engine/tests/Benchmark.reboot/parser.py     | 14 +++++++-------
 engine/tests/Benchmark.reboot/reboot        |  9 +++------
 engine/tests/Benchmark.reboot/reboot.sh     |  5 ++++-
 engine/tests/Benchmark.reboot/reference.log |  6 ++----
 jobs/tests.info                             |  2 +-
 6 files changed, 36 insertions(+), 27 deletions(-)

diff --git a/engine/scripts/functions.sh b/engine/scripts/functions.sh
index fd86d41..ef8c62e 100755
--- a/engine/scripts/functions.sh
+++ b/engine/scripts/functions.sh
@@ -391,16 +391,27 @@ function target_cleanup {
   cmd "rm -rf $FUEGO_HOME/* /tmp/* $FUEGO_HOME/.local"
 }
 
+# Reboot the target and wait until we reconnect to it
+#
+# Usage: target_reboot MAX_REBOOT_RETRIES
+#
+# [Note] retries are used instead of a simple timeout because 
+# 'cmd' may have an underlying timeout (e.g.: ConnectTimeout=15
+# for ssh).
 function target_reboot {
   ov_rootfs_reboot
-
-  sleep 30 # This magic number required as we need to wait until device reboots
-  cmd "true"
-  if [ $? ]; then
-   true
-  else
-   false
-  fi
+  # set +e because cmd will fail during the boot process
+  set +e
+  retries=0
+  while [ $retries -le $1 ]
+  do
+    cmd "true"
+    if [ $? -eq 0 ]; then return 0; fi
+    sleep 1
+    retries=$((retries+1));
+  done
+  set -e
+  abort_job "FAIL: reboot retries exhausted\n"
 }
 
 # $1 - tarball template
diff --git a/engine/tests/Benchmark.reboot/parser.py b/engine/tests/Benchmark.reboot/parser.py
index 9b0a6a3..14c893e 100755
--- a/engine/tests/Benchmark.reboot/parser.py
+++ b/engine/tests/Benchmark.reboot/parser.py
@@ -5,17 +5,17 @@ import os, re, sys
 sys.path.insert(0, os.environ['FUEGO_PARSER_PATH'])
 import common as plib
 
+# pattern that matches reference.log
+ref_section_pat = "^\[[\w]+.[gle]{2}\]"
 
-ref_section_pat = "^\[[\w\d_ ./]+.[gle]{2}\]"
-	
-# Jan  6 09:55:31 2013 (none) user.notice bootlog: [     2.227600] bootlogd.
-
-cur_search_pat = re.compile(" user.info kernel: \[ *([\d.]+)\] Freeing init memory: 264K\n")
+# pattern that matches 'reboot' (requires CONFIG_PRINTK_TIME=y)
+cur_search_pat = re.compile("\[\s*(.*)\] Freeing")
 
 cur_dict = {}
 pat_result = plib.parse(cur_search_pat)
 if pat_result:
 	for item in pat_result:
-		cur_dict["time.init"] = item[0]
+		cur_dict["time"] = item
+
+sys.exit(plib.process_data(ref_section_pat, cur_dict, 's', 'Kernel boot time (seconds)'))
 
-sys.exit(plib.process_data(ref_section_pat, cur_dict, 'm', ' '))
diff --git a/engine/tests/Benchmark.reboot/reboot b/engine/tests/Benchmark.reboot/reboot
index 40dfce2..4d4ad33 100755
--- a/engine/tests/Benchmark.reboot/reboot
+++ b/engine/tests/Benchmark.reboot/reboot
@@ -1,9 +1,6 @@
 #!/bin/sh
 
-# Bootlogd stop time (i.e. firmware startup time),
-# and X Server start time (i.e. minimum time before software can draw on the screen)
-/sbin/logread |grep -E 'Freeing init memory'
-
-# Memory usage in KiB
-#top -b -n 1 |grep '^Mem:'
+# Assume that the kernel boot ends when the last
+# message containing 'Freeing' appears.
+dmesg | grep -E 'Freeing'
 
diff --git a/engine/tests/Benchmark.reboot/reboot.sh b/engine/tests/Benchmark.reboot/reboot.sh
index 3fc682f..179dd8d 100644
--- a/engine/tests/Benchmark.reboot/reboot.sh
+++ b/engine/tests/Benchmark.reboot/reboot.sh
@@ -9,7 +9,10 @@ function test_deploy {
 }
 
 function test_run {
-	target_reboot
+	# MAX_REBOOT_RETRIES can be defined in the board's file. 
+	# Otherwise, the default is 10 retries
+	retries=${MAX_REBOOT_RETRIES:-10}
+	target_reboot $retries
 	report "cd $FUEGO_HOME/fuego.$TESTDIR; ./reboot"  
 }
 
diff --git a/engine/tests/Benchmark.reboot/reference.log b/engine/tests/Benchmark.reboot/reference.log
index 3c8e159..7504269 100755
--- a/engine/tests/Benchmark.reboot/reference.log
+++ b/engine/tests/Benchmark.reboot/reference.log
@@ -1,4 +1,2 @@
-# Automatically generated on fuego host by thresholds.awk based on
-# 7 results of 0\.18\.04\. firmware regexp crossed with [652, 658] build range
-[time.init|le]
-10000
+[time|le]
+10
diff --git a/jobs/tests.info b/jobs/tests.info
index 1eb7ec9..7cda77a 100644
--- a/jobs/tests.info
+++ b/jobs/tests.info
@@ -20,7 +20,7 @@
 	"linpack":["linpack"],
 	"nbench-byte":["INDEX","TEST_GROUP1","TEST_GROUP2"],
 	"netperf":["MIGRATED_TCP_MAERTS","MIGRATED_TCP_STREAM"],
-	"reboot":["time", "mem", "disk"],
+	"reboot":["time"],
 	"Stream":["Add","Copy","Scale","Triad"],
 	"unixbench":["System_Index","Test"],
 	"Whetstone":["Whetstone"],
-- 
2.7.4




More information about the Fuego mailing list