From 88f4efefa579dc33953936817b3e8d6ddf1d651f Mon Sep 17 00:00:00 2001 From: Sachin Gupta Date: Wed, 23 Sep 2015 05:09:17 -0500 Subject: CI Test infrastructure support RTC: 123606 Change-Id: Icf1410c21a9b5691d3b6ea9b54e2507acef61a5d Reviewed-on: http://gfw160.aus.stglabs.ibm.com:8080/gerrit/20724 Tested-by: Jenkins Server Reviewed-by: Basabjit Sengupta Reviewed-by: Amit J. Tendolkar --- sbe/build/citest/autocitest | 70 +++++++++++++++++++++++++++ sbe/build/citest/build-script | 58 ++++++++++++++++++++++ sbe/build/citest/create-sandbox | 48 ++++++++++++++++++ sbe/build/citest/etc/patches/patchlist.txt | 6 +++ sbe/build/citest/etc/workarounds.postsimsetup | 11 +++++ sbe/build/citest/etc/workarounds.presimsetup | 9 ++++ sbe/build/citest/populate-sandbox | 21 ++++++++ sbe/build/citest/sbetest-start.sh | 15 ++++++ sbe/build/citest/setup-env | 63 ++++++++++++++++++++++++ sbe/test/ffdc.xml | 7 ++- sbe/test/simics-debug-framework.py | 60 +++++++++++++++++++++++ sbe/test/test.xml | 17 ++----- sbe/test/testIstepAuto.py | 27 +++++++++++ sbe/test/testIstepSuccess.py | 2 +- 14 files changed, 399 insertions(+), 15 deletions(-) create mode 100755 sbe/build/citest/autocitest create mode 100755 sbe/build/citest/build-script create mode 100755 sbe/build/citest/create-sandbox create mode 100644 sbe/build/citest/etc/patches/patchlist.txt create mode 100755 sbe/build/citest/etc/workarounds.postsimsetup create mode 100755 sbe/build/citest/etc/workarounds.presimsetup create mode 100755 sbe/build/citest/populate-sandbox create mode 100755 sbe/build/citest/sbetest-start.sh create mode 100755 sbe/build/citest/setup-env create mode 100755 sbe/test/simics-debug-framework.py create mode 100755 sbe/test/testIstepAuto.py (limited to 'sbe') diff --git a/sbe/build/citest/autocitest b/sbe/build/citest/autocitest new file mode 100755 index 00000000..9197fb70 --- /dev/null +++ b/sbe/build/citest/autocitest @@ -0,0 +1,70 @@ +#!/bin/bash +################################################################################ +## Simics automation using run-fsp-it +################################################################################ + +## verbose is the default. +VERBOSE=" --verbose" +if [ "$1" = "--quiet" ] ; then + VERBOSE="" + shift +fi + +## +## set up +## +DRIVER="$1" ## backing tree +export bb=$DRIVER ## simulate a workon + +export SHELL="/bin/bash" ## Needed to fool workon to launch a bash + ## shell, which autosim expects. +NOWIN="--nowin" ## remote execution does not have a display + +## jenkins creates a new workspace for every compile. +## sbetest-start.sh will verify this and then export WORKSPACE_DIR for us. +SBXHOME=$SBEROOT + +if [ "$DRIVER" = "" ] ; then + echo "ERROR: you must specify a driver (backing tree) to run the tests with" + usage + exit 1 +fi + +## let's get set up +cd $SANDBOXROOT + +echo "$0" +echo "VERBOSE = $VERBOSE" +echo "NOWIN = $NOWIN" +echo "BACKING_TREE = $DRIVER" +echo "SANDBOXRC = $SANDBOXRC" +echo "SBXHOME = $SBXHOME" +echo "AUTOSIM_FFDC_XML = $AUTOSIM_FFDC_XML" +echo "current directory is " `pwd` + + +timestamp=`date +'%H:%M:%S'` +echo "$timestamp Starting SBE test..." + +# Check preconditions for run-fsp-it +mkdir -p ~/private +if [ ! -f ~/private/.p ]; then + echo "Creating p file" + touch ~/private/.p +fi + +if [ ! -f ~/private/password ]; then + echo "Creating passwd file" + touch ~/private/password + # This is just workaround. It is expected + # that user already either have this file + # or tokens have been taken by klog command. + # This is just to make run-fsp-it work in user + # sandbox + echo "dummy" > ~/private/password +fi + +execute_in_sandbox "run-fsp-it $NOWIN --machine $MACHINE $SBE_TEST_XML" "ppc" || exit -1 + +exit 0 + diff --git a/sbe/build/citest/build-script b/sbe/build/citest/build-script new file mode 100755 index 00000000..4d6775b9 --- /dev/null +++ b/sbe/build/citest/build-script @@ -0,0 +1,58 @@ +#!/bin/sh + +if [ -z $WORKSPACE ]; then + export WORKSPACE=`pwd` +fi + +if [ -z $SBEROOT ]; then + source "$WORKSPACE/env.bash" +fi + +source "$SBEROOT/sbe/build/citest/setup-env" + +# @TODO via RTC 140875 +#Enable it once SBE copyright script is ready +# Check copyright. +#check-copyright > copyright.log 2>&1 & +#COPYRIGHT_PID=$! + + +# Build . +cd sbe/image +scl enable devtoolset-2 " bash -c \"make all\"" || exit -1 +make tracehash || exit -1 +cd - + +#@ TODO via RTC 123606 +# Enable this in another case +# Create simics sandbox. +#create-sandbox > create-sandbox.log 2>&1 & +#CREATESANDBOX_PID=$! + +# Check sandbox create completion. +#wait $CREATESANDBOX_PID +#if [ $? -eq 0 ]; then +# cat create-sandbox.log +#else +# echo "----Sandbox creation failed." +# cat create-sandbox.log +# exit -1 +#fi + +# Add SBE files to simics sandbox. +#populate-sandbox || exit -1 + +#sbetest-start.sh || exit -1 + +# @TODO via RTC 140875 +#Enable it once SBE copyright script is ready +# Check copyright completion. +#wait $COPYRIGHT_PID +#if [ $? -eq 0 ]; then +# cat copyright.log +#else +# echo "----Copyright check failed." +# cat copyright.log +# exit -1 +#fi + diff --git a/sbe/build/citest/create-sandbox b/sbe/build/citest/create-sandbox new file mode 100755 index 00000000..98e59afd --- /dev/null +++ b/sbe/build/citest/create-sandbox @@ -0,0 +1,48 @@ +#!/bin/sh + +echo "Creating ODE sandbox..." + +# Ensure backing build is accessible. +if [ ! -d "$BACKING_BUILD" ]; +then + echo "Cannot access the backing build: $BACKING_BUILD" + exit -1 +fi + +# Delete existing sandbox if it exists. +if [ -d "$SANDBOXBASE" ]; +then + echo "----Removing old sandbox." + mksb -undo -auto -rc $SANDBOXRC -dir $SANDBOXROOT -sb $SANDBOXNAME +fi +if [ -d "$SANDBOXBASE" ]; +then + rm -rf $SANDBOXBASE +fi + +# Create sandbox. +mksb -rc $SANDBOXRC -dir $SANDBOXROOT -back $BACKING_BUILD -sb $SANDBOXNAME \ + -m ppc -auto || exit -1 + +# workaround scripts expect $sb variable to be populated. +export sb=$SANDBOXBASE/src + +# Run presimsetup workarounds. +echo "----Running presimsetup workarounds." +if [ -f ${CITESTPATH}/etc/workarounds.presimsetup ]; +then + ${CITESTPATH}/etc/workarounds.presimsetup || exit -1 +fi + +# Run start_simics to populate simics directories. +echo "----Setting up simics." +execute_in_sandbox "start_simics -no_start -machine $MACHINE -batch_mode" \ + "ppc" || exit -1 + +# Run postsimsetup workarounds. +echo "----Running postsimsetup workarounds." +if [ -f ${CITESTPATH}/etc/workarounds.postsimsetup ]; +then + ${CITESTPATH}/etc/workarounds.postsimsetup || exit -1 +fi + diff --git a/sbe/build/citest/etc/patches/patchlist.txt b/sbe/build/citest/etc/patches/patchlist.txt new file mode 100644 index 00000000..5bf8c309 --- /dev/null +++ b/sbe/build/citest/etc/patches/patchlist.txt @@ -0,0 +1,6 @@ +# Example Format +Brief description of the problem or reason for patch +-RTC: Task/Story used to remove this patch +-CQ: Defect/Req for checking the changes into fips910 +-Files: list of files +-Coreq: list of associated changes, e.g. workarounds.presimsetup diff --git a/sbe/build/citest/etc/workarounds.postsimsetup b/sbe/build/citest/etc/workarounds.postsimsetup new file mode 100755 index 00000000..e19a6c02 --- /dev/null +++ b/sbe/build/citest/etc/workarounds.postsimsetup @@ -0,0 +1,11 @@ +#!/bin/sh +## Workarounds that are run after start_simics is executed for the first time +## to setup the sandbox +## + +### Example applying a patch to cec-chip files +#echo "+++ Updating something wonderful in a simics file" +#mkdir -p $sb/simu/data/cec-chip/ +#cp $BACKING_BUILD/src/simu/data/cec-chip/base_cec_chip_file $sb/simu/data/cec-chip +#patch -p0 $sb/simu/data/cec-chip/base_cec_chip_file $HOSTBOOTROOT/src/build/citest/etc/patches/my_patch_File + diff --git a/sbe/build/citest/etc/workarounds.presimsetup b/sbe/build/citest/etc/workarounds.presimsetup new file mode 100755 index 00000000..b1db34de --- /dev/null +++ b/sbe/build/citest/etc/workarounds.presimsetup @@ -0,0 +1,9 @@ +#!/bin/sh + +#### Examples #### +#echo "+++ Some message about why you need to do this." +#mkdir -p $sb/simu/data +#egrep -v "WSALIAS DEFAULT FIPSLEVEL|WSALIAS DEFAULT SIMICSLEVEL" $BACKING_BUILD/src/simu/data/simicsInfo > $sb/simu/data/simicsInfo +#echo "WSALIAS DEFAULT FIPSLEVEL env/gfwb/simics-4.2.0/simics-4.2.83/fips/fld36/fi120201a700.42" >> $sb/simu/data/simicsInfo +#echo "WSALIAS DEFAULT SIMICSLEVEL env/vtechb/simics-4.2.0/simics-4.2.83/bin" >> $sb/simu/data/simicsInfo + diff --git a/sbe/build/citest/populate-sandbox b/sbe/build/citest/populate-sandbox new file mode 100755 index 00000000..4af967d5 --- /dev/null +++ b/sbe/build/citest/populate-sandbox @@ -0,0 +1,21 @@ +#!/bin/sh + +# Ensure sandbox exists (create-sandbox has been called). +if [ -z $SANDBOXBASE ]; +then + echo "SANDBOXBASE variable uninitialized.." + exit -1 +fi + +if [ ! -d "$SANDBOXBASE" ]; +then + echo "Cannot find sandbox: $SANDBOXBASE" + exit -1 +fi + +# Create img directory. +mkdir -p $SBETESTDIR || exit -1 + +# Copy files. + +cp $SBEROOT/sbe/test/* $SBETESTDIR/ || exit -1 diff --git a/sbe/build/citest/sbetest-start.sh b/sbe/build/citest/sbetest-start.sh new file mode 100755 index 00000000..24e661e1 --- /dev/null +++ b/sbe/build/citest/sbetest-start.sh @@ -0,0 +1,15 @@ +#!/bin/sh +if [ -z $SBE_CI_ENV_SETUP ]; +then + unset $SANDBOXBASE + unset $SANDBOXNAME + source "$SBEROOT/sbe/build/citest/setup-env" +fi + +# Front end to autocitest - script to execute unit tests under simics. +# +## when jenkins runs it will create a workspace with the built code tree +## and drop us into it. +autocitest ${BACKING_BUILD} + +exit $? diff --git a/sbe/build/citest/setup-env b/sbe/build/citest/setup-env new file mode 100755 index 00000000..4d458700 --- /dev/null +++ b/sbe/build/citest/setup-env @@ -0,0 +1,63 @@ +#!/bin/sh + +export CITESTPATH=${SBEROOT}/sbe/build/citest +export PATH=${CITESTPATH}:${PATH} +export SBE_IMG_OUT_LOC=${SBEROOT}/sbe/obj; +export SBE_IMG_BIN_LOC=${SBEROOT}/sbe/obj; +# If we are running under Jenkins we need to pick a random-ish sandbox name +# so that the autoipl tools do not have a /tmp name collision. +if [ -z $JOB_NAME -o -z $BUILD_NUMBER ]; +then + SBECI_SANDBOX="test_sb" +else + export RUNNING_UNDER_JENKINS=1 + SBECI_SANDBOX=`echo $JOB_NAME $BUILD_NUMBER | md5sum | head -c10` +fi + +# Setup sandbox location variables. +if [ -z $SANDBOXROOT ]; +then + export SANDBOXROOT=${SBEROOT} +fi + +if [ -z $SANDBOXNAME ]; +then + export SANDBOXNAME=${SBECI_SANDBOX} +fi +if [ -z $SANDBOXBASE ]; +then + export SANDBOXBASE=${SANDBOXROOT}/${SANDBOXNAME} +fi + +if [ -z $SANDBOXRC ]; +then + export SANDBOXRC=${SANDBOXROOT}/sbesandboxrc +fi + +# Useful utility function. +execute_in_sandbox() +{ + WORKON_CMD="workon -rc ${SANDBOXRC} -sb ${SANDBOXNAME} -m $2 " + echo $1 > ${SANDBOXBASE}/src/sandbox_execute_cmd + chmod 700 ${SANDBOXBASE}/src/sandbox_execute_cmd + + TEST="${WORKON_CMD} -c ./sandbox_execute_cmd " + echo $TEST + ${WORKON_CMD} -c ./sandbox_execute_cmd + + if [ $? -ne 0 ]; then + return 1 + fi + + rm ${SANDBOXBASE}/src/sandbox_execute_cmd +} +export -f execute_in_sandbox + +# Setup machine type. +export MACHINE=${MACHINE:-$DEFAULT_MACHINE} + +export SBETESTDIR=$SANDBOXBASE/simics/targets/p9_nimbus/sbeTest +export AUTOSIM_FFDC_XML=$SBETESTDIR/ffdc.xml +export SBE_TEST_XML=$SBETESTDIR/test.xml +# Indicate we setup the CI environment. +export SBE_CI_ENV_SETUP=1 diff --git a/sbe/test/ffdc.xml b/sbe/test/ffdc.xml index 1218f35d..e98a110c 100755 --- a/sbe/test/ffdc.xml +++ b/sbe/test/ffdc.xml @@ -1,9 +1,12 @@ - + - pipe \"p9Proc0.sbe.mibo_space.x (p9Proc0.sbe.ppe.sym g_pk_trace_buf_ptr) 0x2028\" \"sed 's/^p:0x........ //g' | sed 's/ ................$//g' | sed 's/ //g' | xxd -r -p> ppetrace.bin\" + sbe-trace + + + p9Proc0.sbe.ppe->ppe_state p9Proc0.proc_fifo->upstream_hw_fifo diff --git a/sbe/test/simics-debug-framework.py b/sbe/test/simics-debug-framework.py new file mode 100755 index 00000000..a96e891f --- /dev/null +++ b/sbe/test/simics-debug-framework.py @@ -0,0 +1,60 @@ +import os +import subprocess +import re +import random +import sys +sys.path.append("targets/p9_nimbus/sbeTest" ) +import testIstepAuto +err = False + +syms = {}; + + +# @fn register_hb_debug_framework_tools +# @brief Create a simics command wrapper for each debug tool module. +def register_sbe_debug_framework_tools(): + fillSymTable() + # Create command hook. + new_command("sbe-istep", testIstepAuto.sbe_istep_func, + args = [arg(int_t, "major"), arg(int_t, "minor")], + alias = "istep", + type = ["sbe-commands"], + short = "Runs the debug framework for istep ", + doc = "") + new_command("sbe-trace", collectTrace, + args = [], + alias = "strace", + type = ["sbe-commands"], + short = "Runs the debug framework for istep ", + doc = "") + print "SBE Debug Framework: Registered tool:", "sbe-istep" + print "SBE Debug Framework: Registered tool:", "sbe-trace" + + +def fillSymTable(): + symFile = os.environ['SBE_IMG_OUT_LOC'] + "/sbe.syms" + f = open( symFile, 'r') + for line in f: + words = line.split() + if( len(words) == 3): + syms[words[2]] = words[0] + +def collectTrace(): + cmd1 = "pipe \"p9Proc0.sbe.mibo_space.x 0x" + syms['g_pk_trace_buf'] + " 0x2028\" \"sed 's/^p:0x........ //g' | sed 's/ ................$//g' | sed 's/ //g' | xxd -r -p> ppetrace.bin\"" + toolPath = os.environ['SBE_IMG_OUT_LOC'] + "/../../tools/ppetracepp/" + cmd2 = "shell \"" + toolPath + "ppe2fsp ppetrace.bin sbetrace.bin \"" + cmd3 = "shell \"" + toolPath + "fsp-trace -s " + os.environ['SBE_IMG_OUT_LOC'] + "/trexStringFile sbetrace.bin > tracMERG \"" + cmd4 = "shell \"" + "cat tracMERG \"" + + ( rc, out ) = quiet_run_command( cmd1, output_modes.regular ) + if ( rc ): + print "simics ERROR running %s: %d "%( cmd1, rc ) + + SIM_run_alone( run_command, cmd2 ) + SIM_run_alone( run_command, cmd3 ) + SIM_run_alone( run_command, cmd4 ) + + +# Run the registration automatically whenever this script is loaded. +register_sbe_debug_framework_tools() + diff --git a/sbe/test/test.xml b/sbe/test/test.xml index 434a6df8..9433ba87 100755 --- a/sbe/test/test.xml +++ b/sbe/test/test.xml @@ -5,18 +5,11 @@ %%machine%% - + + + run-python-file targets/p9_nimbus/sbeTest/simics-debug-framework.py + yes + ../simics/targets/p9_nimbus/sbeTest/testIstep.xml ../simics/targets/p9_nimbus/sbeTest/testScom.xml ../simics/targets/p9_nimbus/sbeTest/testGeneric.xml diff --git a/sbe/test/testIstepAuto.py b/sbe/test/testIstepAuto.py new file mode 100755 index 00000000..25b9d206 --- /dev/null +++ b/sbe/test/testIstepAuto.py @@ -0,0 +1,27 @@ +import sys +sys.path.append("targets/p9_nimbus/sbeTest" ) +import testUtil +err = False + +EXPDATA = [0xc0,0xde,0xa1,0x01, + 0x0,0x0,0x0,0x0, + 0x00,0x0,0x0,0x03]; + +# MAIN Test Run Starts Here... +#------------------------------------------------- +def sbe_istep_func( major, minor ): + TESTDATA = [0,0,0,3, + 0,0,0xA1,0x01, + 0,major,0,minor ] + testUtil.runCycles( 10000000 ) + testUtil.writeUsFifo( TESTDATA ) + testUtil.writeEot( ) + testUtil.readDsFifo( EXPDATA ) + testUtil.readEot( ) + if err: + print ("\nTest completed with error(s)") + #sys.exit(1) + else: + print ("\nTest completed with no errors") + #sys.exit(0); + diff --git a/sbe/test/testIstepSuccess.py b/sbe/test/testIstepSuccess.py index 14d2e545..8c42a504 100755 --- a/sbe/test/testIstepSuccess.py +++ b/sbe/test/testIstepSuccess.py @@ -6,7 +6,7 @@ err = False TESTDATA = [0,0,0,3, 0,0,0xA1,0x01, - 0,0x02,0x00,0x3] + 0,0x02,0x00,0x2] EXPDATA = [0xc0,0xde,0xa1,0x01, 0x0,0x0,0x0,0x0, -- cgit v1.2.1