1#!/bin/bash -f
2#----------------------------------------------------------------------------
3# Project:  Horizon
4# File:     run.sh
5#
6# Copyright (C)2009-2011 Nintendo Co., Ltd.  All rights reserved.
7#
8# These coded instructions, statements, and computer programs contain
9# proprietary information of Nintendo of America Inc. and/or Nintendo
10# Company Ltd., and are protected by Federal copyright law. They may
11# not be disclosed to third parties or copied or duplicated in any form,
12# in whole or in part, without the prior written consent of Nintendo.
13#
14# $Rev: 38282 $
15#----------------------------------------------------------------------------
16
17ROOT=`cygpath -m ${HORIZON_ROOT}`
18TIME_OUT=30
19#TEST_EXIT_STRING='(^((CU_TEST_EXIT)|(nn::svc::Break\(\d+\) called)|(KernelPanic))|(Exception =+$))'
20TEST_EXIT_STRING='(^((CU_TEST_EXIT)|(KernelPanic))|(Exception =+$))'
21LOG_DIR=${ROOT}/log
22
23WF=${ROOT}/tools/_private/wf
24PP="ruby ${ROOT}/tools/_private/partner_partner.rb"
25
26function xmlcutter(){
27    sed -e '/^<!-- begin:/, /^<!-- end:/d'
28}
29
30TARGET_HARDWARES=`${WF} PARTNER | gawk '\
31$2 ~ /PARTNER-CTR\/J_0/{ print "CTR-MG20\\\\..*\\\\.MPCore" } \
32$2 ~ /PARTNER-CTR\/J_1/{ print "CTR-MG20\\\\..*\\\\.ARM946ES" } \
33$2 ~ /PARTNER-CTR\/J_0/{ print "CTR-TEG2\\\\..*\\\\.MPCore" } \
34$2 ~ /PARTNER-CTR\/J_1/{ print "CTR-TEG2\\\\..*\\\\.ARM946ES" } \
35$2 ~ /PARTNER-CTR\/WIN_0/  { print "CTR-MG20\\\\..*\\\\.MPCore" } \
36$2 ~ /PARTNER-CTR\/WIN_1/  { print "CTR-MG20\\\\..*\\\\.ARM946ES" } \
37$2 ~ /PARTNER-Jet(ARM)\/WIN_/  { print "CTR-NE1TB\\\\..*" } \
38'`
39#echo ${TARGET_HARDWARES}
40
41function debugger_available(){
42    name=$1
43    for HARDWARE in ${TARGET_HARDWARES}
44    do
45#        echo ${HARDWARE}
46        if (echo ${name} | grep "${HARDWARE}" > /dev/null); then
47#            echo yes
48            return 0
49        fi
50    done
51    return 1
52}
53
54function do_test(){
55    echo Started
56    for mcr in $*
57    do
58        mcr=`cygpath -m ${mcr}`
59        base=`basename ${mcr} .mcr`
60        dir=`dirname ${mcr}`
61        arch=`basename \`dirname ${dir}\``
62        mcrname=...`echo ${mcr} | tail -c -65`
63        if (debugger_available ${dir}); then
64            echo
65            echo "================================================================================"
66            echo " executing: ${mcrname}"
67            echo "================================================================================"
68
69            process_list_candidate=${dir}/${base}_process.list
70            if [ -r ${process_list_candidate} ]; then
71                cp -f ${process_list_candidate} ${dir}/process.list
72            fi
73
74            echo '~~~ snip ~~~'
75            ${PP} -T ${arch} -i ${mcr} -t ${TIME_OUT} -s "${TEST_EXIT_STRING}" | grep -v '^>' | xmlcutter | sed -e '1,60d'
76        else
77            echo "No appropriate debugger is running:  ${mcr}"
78        fi
79    done
80    #ruby $(ROOT)/tools/CommandLineTools/partner_partner.rb -e exit!
81}
82
83#mkdir -p "${LOG_DIR}"
84do_test $*
85