summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLokesh B V <lokesh.bv@arm.com>2018-10-28 01:12:54 +0530
committerThomas Abraham <thomas.abraham@arm.com>2018-12-27 16:04:39 +0530
commit4e1ada99c0fb565e88b8578781720d34e1ca87db (patch)
tree33198789acad87fd8ac0b24a5dc7055e06c7b59c
parent74c66d29d654749face079ebaa65fe57a6f6fe5b (diff)
sgi/common: rename check_boot_complete to parse_log_file
The 'check_boot_complete' function is renamed as 'parse_log_file' and modified to make it usable by multiple test scripts. It now accepts three parameters - log file name, search string and timeout value. It waits until the search string is found in the log file or the timeout occurs. It returns '0' on success and '-1' on failure. Change-Id: I90956c109bfd028606490781744a21009a1b8bdb Signed-off-by: Lokesh B V <lokesh.bv@arm.com>
-rwxr-xr-xsgi/busybox_boot.sh13
-rw-r--r--sgi/sgi_common_util.sh36
2 files changed, 37 insertions, 12 deletions
diff --git a/sgi/busybox_boot.sh b/sgi/busybox_boot.sh
index 514cd14..1fef222 100755
--- a/sgi/busybox_boot.sh
+++ b/sgi/busybox_boot.sh
@@ -119,7 +119,18 @@ if [ "$MODEL_PID" == "0" ] ; then
fi
# wait for boot to complete and the model to be killed
-check_boot_complete "$PWD/$platform/$UART0_ARMTF_OUTPUT_FILE_NAME" "/ #"
+parse_log_file "$PWD/$platform/$UART0_ARMTF_OUTPUT_FILE_NAME" "/ #" 7200
+ret=$?
+
kill_model
+sleep 3
+
+if [ "$ret" != "0" ]; then
+ echo "[ERROR]: Busybox boot test failed or timedout!"
+ exit 1
+else
+ echo "[SUCCESS]: Busybox boot test completed!"
+fi
+
popd
exit 0
diff --git a/sgi/sgi_common_util.sh b/sgi/sgi_common_util.sh
index 234f850..1effec4 100644
--- a/sgi/sgi_common_util.sh
+++ b/sgi/sgi_common_util.sh
@@ -34,7 +34,7 @@
# This script is contains different utility method to run validation tests #
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
-TEST_HARD_TIMEOUT=7200
+SGI_TEST_MAX_TIMEOUT=7200
CURRENT_DATE_TIME=`date +%Y-%m-%d_%H.%M.%S`
# search all the available network interfaces and find an available tap
@@ -102,24 +102,38 @@ kill_model () {
fi
}
-# wait for boot to complete by parsing UART log
-check_boot_complete ()
+# parse_log_file: waits until the search string is found in the log file
+# or timeout occurs
+# Arguments: 1. log file name
+# 2. search string
+# 3. timeout
+# Return Value: 0 -> Success
+# -1 -> Failure
+parse_log_file ()
{
local testdone=1
local cnt=0
+ local logfile=$1
+ local search_str=$2
+ local timeout=$3
+
+ if [ "$timeout" -le 0 ] || [ "$timeout" -gt $SGI_TEST_MAX_TIMEOUT ]; then
+ echo -e "\n[WARN] timeout value $timeout is invalid. Setting" \
+ "timeout to $SGI_TEST_MAX_TIMEOUT seconds."
+ timeout=$SGI_TEST_MAX_TIMEOUT;
+ fi
while [ $testdone -ne 0 ]; do
sleep 1
- if ls $1 1> /dev/null 2>&1; then
- tail $1 | grep -q -s -e "$2" > /dev/null 2>&1
+ if ls $logfile 1> /dev/null 2>&1; then
+ tail $logfile | grep -q -s -e "$search_str" > /dev/null 2>&1
testdone=$?
- if [ "$cnt" -ge "$TEST_HARD_TIMEOUT" ];then
- echo -e "\n[ERROR] The model took longer than expected to boot, terminating the test..."
- return 1
- fi
- cnt=$((cnt+1))
fi
+ if [ "$cnt" -ge "$timeout" ]; then
+ echo -e "\n[ERROR]: ${FUNCNAME[0]}: Timedout or $logfile may not found!\n"
+ return -1
+ fi
+ cnt=$((cnt+1))
done
- echo -e "\n[INFO] Boot complete!"
return 0
}