From 0175fb1b4ffaa126df516a0086e5adb51cfc94e2 Mon Sep 17 00:00:00 2001 From: Pratik Prajapati Date: Wed, 18 Nov 2015 15:02:19 -0800 Subject: util/mma: Add tools to support (semi) automation test of mma mma_automated_test.sh takes a config file (/usr/local/mma/tests) as input and executes all tests mentioned in the config file. format of the config file is one or more lines mentioned below. <#count> e.g. consider following config file. Margin1D.efi Margin1DRxVrefConfig.bin 4 RMT.efi RMTConfig.bin 1 MarginMapper.efi ScoreTxVref-TxDqDelayConfigCh1.bin 2 Margin2D.efi Margin2D_Cmd_Ch0_D1_R0_Config.bin 3 This will execute Margin1D.efi MMA test 4 times with Margin1DRxVrefConfig.bin param and results will be stored in DUT under /usr/local/mma/results_ with Margin1D_Margin1DRxVrefConfig_1.bin to Margin1D_Margin1DRxVrefConfig_4.bin name. Subsequently all tests will be executed and results will be stored. /etc/init/mma.conf invokes mma_automated_test.sh when DUT starts. And if valid test config is preset at /usr/local/mma/tests, mma_automated_test.sh will continue executing the tests. Each time DUT will be rebooted and next test in sequence will be executed. Overall follow these steps to start MMA. (1) create /usr/local/mma/tests file with the syntax mentioned above. (2) either reboot the DUT (mma.conf will be called at each boot time, which would run the mma_automated_test.sh) or execute "start mma" command (to save a reboot cycle.) (3) all test results can be found under /usr/local/mma/results_ where is YY_MM_DD_HH_mm format (YEAR_MONTH_DAY_HOUR_MINUTE) when you started the mma tests. BRANCH=none BUG=chrome-os-partner:43731 TEST=Build and Boot kunimitsu (FAB3). MMA automation tests executes and results get saved. Change-Id: I6805fdb95b7ff919f9c8e967b748e4893a3f9889 Signed-off-by: Patrick Georgi Original-Commit-Id: 68c0a531ba3fc335b92b17002e75412195b778c4 Original-Change-Id: I92db7ca47e1e3e581c3fbb413f11e2c3e6d19b6b Original-Signed-off-by: Pratik Prajapati Original-Signed-off-by: Icarus Sparry Original-Reviewed-on: https://chromium-review.googlesource.com/313180 Original-Commit-Ready: Pratikkumar V Prajapati Original-Tested-by: Pratikkumar V Prajapati Original-Reviewed-by: Aaron Durbin Original-Reviewed-by: Pratikkumar V Prajapati Reviewed-on: https://review.coreboot.org/12928 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer --- util/mma/mma.conf | 11 +++++ util/mma/mma_automated_test.sh | 93 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 104 insertions(+) create mode 100644 util/mma/mma.conf create mode 100755 util/mma/mma_automated_test.sh (limited to 'util/mma') diff --git a/util/mma/mma.conf b/util/mma/mma.conf new file mode 100644 index 0000000000..29c1f220d0 --- /dev/null +++ b/util/mma/mma.conf @@ -0,0 +1,11 @@ +# Copyright (c) 2015 The Chromium OS Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +description "Run the mma automation tests" +author "chromium-os-dev@chromium.org" + +start on started boot-services +script + bash mma_automated_test.sh +end script diff --git a/util/mma/mma_automated_test.sh b/util/mma/mma_automated_test.sh new file mode 100755 index 0000000000..0e9596245d --- /dev/null +++ b/util/mma/mma_automated_test.sh @@ -0,0 +1,93 @@ +#!/bin/bash + +# +# This file is part of the coreboot project. +# +# Copyright (C) 2015 Intel Corporation. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FIMMA_TEST_NAMEESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# + +MMA_LOCAL_DATA_STORAGE=/usr/local/mma +# +# format of MMA_AUTOMATED_TEST_CONFIG file is as below +# with 1 or more repeated lines with same format +# +# <#times to run this test> +# +# e.g. +# RMT.efi RMTConfig.bin 2 +# Margin1D.efi Margin1DCmdAllConfig.bin 1 +# +# +MMA_AUTOMATED_TEST_CONFIG="${MMA_LOCAL_DATA_STORAGE}"/tests +MMA_AUTOMATED_TEST_COUNT="${MMA_LOCAL_DATA_STORAGE}"/count +MMA_SETUP_TEST_TOOL=mma_setup_test.sh +MMA_GET_RESULT_TOOL=mma_get_result.sh +MMA_TEST_RESULTS_PATH="${MMA_LOCAL_DATA_STORAGE}/results$(date +_%y_%m_%d_%H_%M)" +# Clear MMA_TEST_NUMBER just in case it is set in environment +MMA_TEST_NUMBER= + +# Set a number of global params based on test number +# MMA_TEST_NUMBER - test number, stored in MMA_AUTOMATED_TEST_COUNT +# MMA_TEST_NAME - test name +# MMA_TEST_PARAM - test parameter +# MMA_TEST_COUNT - test count, number of times to run the test +# MMA_TEST_RESULT_NAME - filename for result +get_mma_autotest_params() { + typeset -i i=${MMA_TEST_NUMBER} + exec 9< "${MMA_AUTOMATED_TEST_CONFIG}" + while read -u9 MMA_TEST_NAME MMA_TEST_PARAM MMA_TEST_COUNT + do + case "${MMA_TEST_NAME}" in + ("#"*|"") continue;; # Allow blank lines and comments + esac + : $(( i -= MMA_TEST_COUNT )) + if (( i <= 0 )) ; then + printf -v MMA_TEST_RESULT_NAME \ + "${MMA_TEST_NAME%.efi}_${MMA_TEST_PARAM%.bin}_%d.bin" \ + $((MMA_TEST_COUNT+i)) + return + fi + done + ${MMA_SETUP_TEST_TOOL} reset + rm "${MMA_AUTOMATED_TEST_COUNT}" + mv "${MMA_AUTOMATED_TEST_CONFIG}" "${MMA_TEST_RESULTS_PATH}" + exit 0 +} + +main() { + # Exit if there are no tests + [ -e "${MMA_AUTOMATED_TEST_CONFIG}" ] || exit 0 + + if [ -e "${MMA_AUTOMATED_TEST_COUNT}" ] ; then + . "${MMA_AUTOMATED_TEST_COUNT}" + fi + + mkdir -p "${MMA_TEST_RESULTS_PATH}" + + if [ "${MMA_TEST_NUMBER}" ] ; then + get_mma_autotest_params + ${MMA_GET_RESULT_TOOL} \ + "${MMA_TEST_RESULTS_PATH}"/"${MMA_TEST_RESULT_NAME}" + fi + + : $(( MMA_TEST_NUMBER += 1 )) + printf "MMA_TEST_NUMBER=${MMA_TEST_NUMBER}\n" \ + > "${MMA_AUTOMATED_TEST_COUNT}" + printf "MMA_TEST_RESULTS_PATH=%s" "${MMA_TEST_RESULTS_PATH}" \ + >> "${MMA_AUTOMATED_TEST_COUNT}" + get_mma_autotest_params + ${MMA_SETUP_TEST_TOOL} set ${MMA_TEST_NAME} ${MMA_TEST_PARAM} + + reboot +} + +main "$@" -- cgit v1.2.3