summaryrefslogtreecommitdiffstats
path: root/src/test/testcases/testIstepAuto.py
blob: d68d2135df70efa3f1ab7f36eace5d4693d2cfc2 (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
# IBM_PROLOG_BEGIN_TAG
# This is an automatically generated prolog.
#
# $Source: src/test/testcases/testIstepAuto.py $
#
# OpenPOWER sbe Project
#
# Contributors Listed Below - COPYRIGHT 2016,2019
# [+] International Business Machines Corp.
#
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied. See the License for the specific language governing
# permissions and limitations under the License.
#
# IBM_PROLOG_END_TAG
import sys
import copy
from sim_commands import *
import imp

err = False

def getMachineName():
    try:
        sbeScriptsPath = simenv.sbe_scripts_path
        macineType = "axone"
    except:
        macineType = "nimbus"
    finally:
        return macineType

def collectFFDC():
    if getMachineName() == "axone":
        simics.SIM_run_command('sbe-trace 0')
        simics.SIM_run_command('sbe-stack 0')
        simics.SIM_run_command('sbe-regffdc 0')
        simics.SIM_run_command('backplane0.proc0.pib_cmp.sbe_ppe->ppe_state')
        simics.SIM_run_command('backplane0.proc0.cfam_cmp.sbe_fifo->upstream_hw_fifo')
        simics.SIM_run_command('backplane0.proc0.cfam_cmp.sbe_fifo->downstream_hw_fifo')

if getMachineName() == "axone":
    SBE_TOOLS_PATH = simenv.sbe_scripts_path
else:
    SBE_TOOLS_PATH = os.environ['SBE_TOOLS_PATH']
testUtil = imp.load_source("testUtil", SBE_TOOLS_PATH + "/testUtil.py")
EXPDATA = [0xc0,0xde,0xa1,0x01,
           0x0,0x0,0x0,0x0,
           0x00,0x0,0x0,0x03];
gIstepArray = {
        2:[2, 17],#istep 2.2 to 2.17
        3:[1, 22],#istep 3.1 to 3.22
        4:[1, 34],#istep 4.1 to 4.34
        5:[1, 2], #istep 5.1 to 5.2
        96:[1, 8],#istep 96.1 to 96.8
        97:[1, 7], #istep 97.1 to 97.7
        98:[1, 1] #istep 98.1 to 98.1
               }
# MAIN Test Run Starts Here...
#-------------------------------------------------
def sbe_istep_func( inum1, inum2, node=0, isfleetwood=0):
    # Convert float number to string, which would help extracting
    # decimal and integral part separately
    # Interpretation:
    # (Single iStep)    inum1=2 inum2=2     => startMajor = 2; startMinor = 2;
    #                                          endMajor = 0; endMinor = 0;
    # (Range of iSteps) inum1=2.3 inum2=3.7 => startMajor = 2; startMinor = 3;
    #                                          endMajor = 3; endMinor = 7;
    istr1 = str(inum1)
    istr2 = str(inum2)
    startMajor = 0
    startMinor = 0
    endMajor = 0
    endMinor = 0
    startMajor = int(istr1.split('.')[0])
    # Check for single istep condition, where inum1=x.0 and inum2=x.0
    # If not extract the start and end isteps range
    if(int(istr1.split('.')[1]) != 0):
        startMinor = int(istr1.split('.')[1])
    if(int(istr2.split('.')[1]) != 0):
        endMajor = int(istr2.split('.')[0])
        endMinor = int(istr2.split('.')[1])
    else:
        startMinor = int(istr2.split('.')[0])

    # Make sure array is a deep copy,
    # as we are modifying and setting up the local array
    # based on ranges requested
    lIstepArray = copy.deepcopy(gIstepArray)
    lIstepArray[startMajor][0] = startMinor
    if endMajor != 0:
        lIstepArray[endMajor][1] = endMinor
    else:
        endMajor = startMajor
        lIstepArray[startMajor][1] = lIstepArray[startMajor][0]
    for major in range(startMajor, endMajor+1):
        for minor in range(lIstepArray[major][0], lIstepArray[major][1] + 1):
            print "Running:"+str(major)+"."+str(minor)

            try:
                TESTDATA = [0,0,0,3,
                             0,0,0xA1,0x01,
                            0,major,0,minor ]
                testUtil.runCycles( 10000000 )
                testUtil.writeUsFifo( TESTDATA, node, isfleetwood )
                testUtil.writeEot( node, isfleetwood )
                testUtil.runCycles( 10000 )
                testUtil.readDsFifo( EXPDATA, node, isfleetwood )
                testUtil.runCycles( 10000 )
                testUtil.readEot( node, isfleetwood )

            except:
                print ("\nTest completed with error(s). Raise error")
                collectFFDC()
                # TODO via RTC 142706
                # Currently simics commands created using hooks always return
                # success. Need to check from simics command a way to return
                # Calling non existant command to return failure
                run_command("Command Failed");
                raise
    print ("\nTest completed with no errors")
        #sys.exit(0);



OpenPOWER on IntegriCloud