summaryrefslogtreecommitdiffstats
path: root/src/usr/cxxtest/autosample
blob: d5f19c63bc6986841dd61720550840fe4e120ede (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
#!/bin/bash
################################################################################
#  Simics automation using autosim
##  2011-05-23  mww modified to run hostboot in simics
##  2011-06-02  mww check in first working version.
##                  Profuse thanks to Patrick Williams for getting this going
##                  on the Gerrit server!!
################################################################################
function    waitkb()
{

    ##  wait for kbhit to continue
    ## echo "Hit any key to continue"
    ## read kb
    echo "."
}

function   usage()
{

    echo    "usage:"
    echo    "$0 [--quiet]  backing_tree_dir  sandbox_name  path_to_hbicore_test_img    "

}


function    stopsim()
{
    # Stop simics
    echo "Stopping simics"
    autosim $NOWIN $VERBOSE --stopsim
    if [ $? -ne 0 ] ; then
        echo "WARNING: Unable to stop simics cleanly"
    fi
}


function    stopserver()
{
    # Stop simics server
    echo "Stopping simics server"
    autosim $NOWIN $VERBOSE --stopserver
    if [ $? -ne 0 ] ; then
        echo "WARNING: Unable to stop simics server cleanly"
    fi
}



##  mww verbose is the default.
VERBOSE=" --verbose"
if [ "$1" = "--quiet" ] ; then
        VERBOSE=""
        shift
fi

##
##  set up
##
DRIVER="$1"                         ##  backing tree
TEST_SANDBOX="$2"                   ##  test sandbox
HBICORE_TEST="$3"                   ##  path to hbicore_test.img

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...

MACHINE="SALERNO"
HBOT_SIMICS_SETUP="/gsa/ausgsa/home/a/n/andrewg/web/public/hostboot/simics/hbot_simics_setup.pl"

##  gerrit creates a new workspace for every compile.
##     cxxtest-start.sh will verify this and then export WORKSPACE_DIR for us.
SBXDIR=$WORKSPACE_DIR

##  autosim, mksb, workon, etc should look in $SANDBOXRC for the location of the sandbox.
##  this is more effective than using -rc option (autosim has no option for this anyway)
LOCAL_SANDBOXRC="$WORKSPACE_DIR/my.sandboxrc"


if [ "$DRIVER" = "" ] ; then
        echo "ERROR: you must specify a driver (backing tree) to run the tests with"
        usage
        exit 1
fi

if [ "$TEST_SANDBOX" = "" ] ; then
        echo "ERROR: must specify a TEST_SANDBOX="
        usage
        exit 1
fi

if [ ! -f "$HBICORE_TEST" ] ; then
        echo "ERROR: you must specify a valid hbicore_test.bin file."
        usage
        exit 1
fi

##  extract the pathname of hbicore_test.* from $HBICORE_TEST
##  parse out the dir and file names for hbicore_test
HBICORE_TEST_DIR=${HBICORE_TEST%/*}
HBICORE_TEST_FILE=${HBICORE_TEST##*/}



## let's get set up
cd $WORKSPACE_DIR

echo    "$0"
echo    "VERBOSE            = $VERBOSE"
echo    "NOWIN              = $NOWIN"
echo    "BACKING_TREE       = $DRIVER"
echo    "TEST_SANDBOX       = $TEST_SANDBOX"
echo    "HBICORE_TEST       = $HBICORE_TEST"
echo    "HBICORE_TEST_DIR   = $HBICORE_TEST_DIR"
echo    "LOCAL_SANDBOXRC    = $LOCAL_SANDBOXRC"
echo    "SBXDIR             = $SBXDIR"
echo    "current directory is " `pwd`
# echo    "env vars are " `env`



waitkb


timestamp=`date +'%H:%M:%S'`
echo "$timestamp Starting autosample test..."


# Set up the test sandbox backed to the specified build
##  Assumption here is that we will always run inside the workspace created by gerrit,
##  so we always create a new sandbox
##

echo "Setting up sandbox environment..."


##  mksb fills the log with "please type backing tree file" if it can't find
##  the -back file.   We wish to avoid this.
if [ ! -d "$DRIVER" ] ; then
        echo "cannot access the backing tree $DRIVER , aborting"
        exit 1
fi


##  set $SANDBOXRC to the local one, this should cause this to make and run in a new sandbox
export SANDBOXRC=$LOCAL_SANDBOXRC


##      at the base workspace dir.
if [ ! -d "$SBXDIR/$TEST_SANDBOX" ] ; then
        echo "run mksb to create the sandbox "
        mksb  -rc $LOCAL_SANDBOXRC -dir $SBXDIR -back $DRIVER -sb $TEST_SANDBOX -m ppc
        if [ $? -ne 0 ] ; then
            echo "ERROR: mksb failed: $?"
            exit 1
        fi
else
        echo "$SBXDIR/$TEST_SANDBOX already exists, " `ls -la`
        `usrsbinfo -s`
        chkdrv=`usrsbinfo -s | grep " $TEST_SANDBOX "| awk '{ print $2 }'`
        if [ "$chkdrv" != "$DRIVER" ] ; then
                resb $DRIVER -sb $TEST_SANDBOX
        fi
fi

waitkb

# Run set up in current shell
echo    "run autosimsetup.."
. autosimsetup

waitkb

# Start the simics server
echo "Starting simics server in sandbox $TEST_SANDBOX on machine $MACHINE"
autosim $NOWIN $VERBOSE --startserver --wp --sandbox $TEST_SANDBOX --machine $MACHINE
if [ $? -ne 0 ] ; then
        echo "ERROR: Unable to start simics server $?"
        exit 1
fi


waitkb

##  under normal circumstances $sb would be set by start_simics
export sb=$SBXDIR/$TEST_SANDBOX/src
echo $sb

echo "** Set up simics directories **"
echo "start_simics -no_start -machine $MACHINE" > $sb/my_simics_env_setup
chmod 775 $sb/my_simics_env_setup
workon -sb $TEST_SANDBOX -mppc -c ./my_simics_env_setup

echo "** Run workaround from Ched **"
/afs/rchland/usr2/ched/public/hostboot/fix_ph110510.sh

echo " Create required config directory and copy in required file (make L3 8MB for now) **"
mkdir -p $sb/simu/configs/ && cp /gsa/ausgsa/home/a/n/andrewg/web/public/hostboot/simics/P8_SALERNO.config $sb/simu/configs/

echo "** Copy in the P8 scomdef **"
mkdir -p $sb/src/engd/scomdef && cp /gsa/ausgsa/home/a/n/andrewg/web/public/hostboot/simics/p8_910400.scomdef $sb/src/engd/scomdef/

echo "** Create img directory for hbicore.bin **"
mkdir -p $sb/../img


waitkb


##  According to the new directions, the hbicore_test.bin file now needs to be
##  copied to $sb/../img/hbicore.bin .  This works out to $TEST_SANDBOX/img/hbicore.bin
##  Note the name change; thus we are always pretty safe in always doing this.
##
echo    "copy $HBICORE_TEST to $WORKSPACE_DIR/$TEST_SANDBOX/img/hbicore.bin"
cp $HBICORE_TEST $WORKSPACE_DIR/$TEST_SANDBOX/img/hbicore.bin
if [ $? -ne 0 ] ; then
        echo "ERROR: Copy of $HBICORE_TEST to $TEST_SANDBOX/../img failed: $?"
        exit 1
fi

##  we also need the hbicore_test.syms file.  Assume that it is the same dir as the .bin file.
##  NOTE:  it may already be there.
##
echo    "copy hbicore_test.syms file to $WORKSPACE_DIR/img/hbicore_test.syms"
if [ ! -f "$WORKSPACE_DIR/img/hbicore_test.syms" ]; then
    cp $HBICORE_TEST_DIR/hbicore_test.syms $WORKSPACE_DIR/img/hbicore_test.syms
    if [ $? -ne 0 ] ; then
        echo "ERROR: Copy of hbicore_test.syms to $WORKSPACE_DIR/img/ failed: $?"
        exit 1
    fi
fi



waitkb


# Start simics and wait for it to reach standby
echo "Starting simics"
#autosim $VERBOSE --startsim --chkpt standby <<< chkpt not working yet
autosim $NOWIN $VERBOSE --startsim
if [ $? -ne 0 ] ; then
        echo "ERROR: Unable to start simics $?"
        stopserver      ##  kill the server again.
        exit 1
fi


waitkb


##  $$TODO Need to wait here for hostboot to finish
##  for now just sleep for 20 seconds
sleep 20


waitkb

##  grep for totaltests, etc.  These will appear in the hbicore_test.syms file and
## look like the following:
##      V,000292b8,00000000,00000008,CxxTest::totaltests
##      V,000292c0,00000000,00000008,CxxTest::tracecalls
##      V,000292c8,00000000,00000008,CxxTest::warnings
##      V,000292d0,00000000,00000008,CxxTest::failedtests

##      V,00017888,00000000,00004000,kernel_printk_buffer


##  grep for the globals
echo "find totaltests, etc in $HBICORE_TEST_DIR/hbicore_test.syms"
printk_buffer_addr=`grep "kernel_printk_buffer" $HBICORE_TEST_DIR/hbicore_test.syms | awk '{split($0,a,","); print a[2]}'`
printk_buffer_size=`grep "kernel_printk_buffer" $HBICORE_TEST_DIR/hbicore_test.syms | awk '{split($0,a,","); print a[4]}'`
totaltests_addr=`grep "CxxTest::g_TotalTests" $HBICORE_TEST_DIR/hbicore_test.syms | awk '{split($0,a,","); print a[2]}'`
failedtests_addr=`grep "CxxTest::g_FailedTests" $HBICORE_TEST_DIR/hbicore_test.syms | awk '{split($0,a,","); print a[2]}'`
warnings_addr=`grep "CxxTest::g_Warnings" $HBICORE_TEST_DIR/hbicore_test.syms  | awk '{split($0,a,","); print a[2]}'`
tracecalls_addr=`grep "CxxTest::g_TraceCalls" $HBICORE_TEST_DIR/hbicore_test.syms | awk '{split($0,a,","); print a[2]}'`



##  note, don't use $VERBOSE here or you get all sorts of extra junk in the output file.
echo "====> dump totaltests..."
autosim $NOWIN --simcmd   "phys_mem.x 0x$totaltests_addr 0x08"     1> $WORKSPACE_DIR/totaltests.log  2> /dev/null
if [ $? -ne 0 ] ; then
        echo "ERROR: Unable to run $?"
        stopsim
        stopserver
        exit 1
fi
totaltests=`cat $WORKSPACE_DIR/totaltests.log | awk '{ print $5 }'`


echo "====> dump failedtests..."
autosim $NOWIN --simcmd   "phys_mem.x 0x$failedtests_addr 0x08"     1> $WORKSPACE_DIR/failedtests.log  2> /dev/null
if [ $? -ne 0 ] ; then
        echo "ERROR: Unable to run $?"
        stopsim
        stopserver
        exit 1
fi
failedtests=`cat $WORKSPACE_DIR/failedtests.log | awk '{ print $5 }'`


echo "====> dump warnings..."
autosim $NOWIN --simcmd   "phys_mem.x 0x$warnings_addr 0x08"     1> $WORKSPACE_DIR/warnings.log  2> /dev/null
if [ $? -ne 0 ] ; then
        echo "ERROR: Unable to run $?"
        stopsim
        stopserver
        exit 1
fi
warnings=`cat $WORKSPACE_DIR/warnings.log | awk '{ print $5 }'`


echo "====> dump tracecalls..."
autosim $NOWIN --simcmd   "phys_mem.x 0x$tracecalls_addr 0x08"     1> $WORKSPACE_DIR/tracecalls.log  2> /dev/null
if [ $? -ne 0 ] ; then
        echo "ERROR: Unable to run $?"
        stopsim
        stopserver
        exit 1
fi
tracecalls=`cat $WORKSPACE_DIR/tracecalls.log | awk '{ print $5 }'`



echo "====> dump printk buffer..."
autosim $NOWIN --simcmd   "memory_image_ln0.save $WORKSPACE_DIR/testprintk.log 0x$printk_buffer_addr 0x$printk_buffer_size"  1> /dev/null 2> /dev/null
if [ $? -ne 0 ] ; then
echo "ERROR: Unable to run $?"
       stopsim
       stopserver
exit 1
fi


##  done.  Stop the simulation
stopsim


## now stop the server.
stopserver



##  print out ending.
timestamp=`date +'%H:%M:%S'`

echo    "----------------- Printk Buffer -------------------"
cat $WORKSPACE_DIR/testprintk.log

echo
echo    "==================================================="
echo    "$timestamp Finished autosample test with no errors."
echo    "    total tests:   $totaltests"
echo    "    failed tests:  $failedtests"
echo    "    warnings:      $warnings"
echo    "    trace calls:   $tracecalls"
echo    "==================================================="
echo


exit 0




OpenPOWER on IntegriCloud