summaryrefslogtreecommitdiffstats
path: root/src/test/testcases/testMemPBA.py
blob: ab3db87e6aad5eaaf8f1f5c009a9836a09db9b24 (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
# IBM_PROLOG_BEGIN_TAG
# This is an automatically generated prolog.
#
# $Source: src/test/testcases/testMemPBA.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
from __future__ import print_function
import sys
sys.path.append("targets/p9_nimbus/sbeTest" )
sys.path.append("targets/p9_axone/sbeTest" )
import testUtil
import testMemUtil
err = False

# MAIN Test Run Starts Here...
#-------------------------------------------------
def main( ):
# First Case without Fast Mode without LCO
    testUtil.runCycles( 10000000 )
    # Put mem PBA
    data = os.urandom(128*2)
    data = [ord(c) for c in data]
    testMemUtil.putmem(0x08000000, data, 0x02)
    # Get mem PBA - WO FMODE, WO LCO
    readData = testMemUtil.getmem(0x08000000, 128*2, 0x02)
    if(data == readData):
        print ("Success - Write-Read PBA - WO FMODE, WO LCO")
    else:
        print(data)
        print(readData)
        raise Exception('data mistmach')
    # Partial Write test
    readData = testMemUtil.getmem(0x08000000, 128*3, 0x02)
    data = os.urandom(128)
    data = [ord(c) for c in data]
    testMemUtil.putmem(0x08000000+128, data, 0x02)
    readBackData = testMemUtil.getmem(0x08000000, 128*3, 0x02)
    sandwichData = readData[:128]+data+readData[len(data)+128:]
    if(sandwichData == readBackData):
        print ("Success - Write_Part-Read PBA - WO FMODE, WO LCO")
    else:
        print(readData)
        print(data)
        print(readBackData)
        print(sandwichData)
        raise Exception('data mistmach')

# Second Case with Fast Mode without LCO
    testUtil.runCycles( 10000000 )
    # Put mem PBA - W FMODE, WO LCO
    data = os.urandom(128*2)
    data = [ord(c) for c in data]
    testMemUtil.putmem(0x08000000, data, 0x22)
    # Get mem PBA
    readData = testMemUtil.getmem(0x08000000, 128*2, 0x22)
    if(data == readData):
        print ("Success - Write-Read PBA - W FMODE, WO LCO")
    else:
        print(data)
        print(readData)
        raise Exception('data mistmach')
    # Partial Write test
    readData = testMemUtil.getmem(0x08000000, 128*3, 0x22)
    data = os.urandom(128)
    data = [ord(c) for c in data]
    testMemUtil.putmem(0x08000000+128, data, 0x22)
    readBackData = testMemUtil.getmem(0x08000000, 128*3, 0x22)
    sandwichData = readData[:128]+data+readData[len(data)+128:]
    if(sandwichData == readBackData):
        print ("Success - Write_Part-Read PBA - W FMODE, WO LCO")
    else:
        print(readData)
        print(data)
        print(readBackData)
        print(sandwichData)
        raise Exception('data mistmach')

# Third Case with Fast Mode with LCO
    testUtil.runCycles( 10000000 )
    # Put mem PBA - W FMODE, W LCO
    data = os.urandom(128*2)
    data = [ord(c) for c in data]
    testMemUtil.putmem(0x08000000, data, 0x62)
    # Get mem PBA
    readData = testMemUtil.getmem(0x08000000, 128*2, 0x62)
    if(data == readData):
        print ("Success - Write-Read PBA - W FMODE, W LCO")
    else:
        print(data)
        print(readData)
        raise Exception('data mistmach')
    # Partial Write test
    readData = testMemUtil.getmem(0x08000000, 128*3, 0x62)
    data = os.urandom(128)
    data = [ord(c) for c in data]
    testMemUtil.putmem(0x08000000+128, data, 0x62)
    readBackData = testMemUtil.getmem(0x08000000, 128*3, 0x62)
    sandwichData = readData[:128]+data+readData[len(data)+128:]
    if(sandwichData == readBackData):
        print ("Success - Write_Part-Read PBA - W FMODE, W LCO")
    else:
        print(readData)
        print(data)
        print(readBackData)
        print(sandwichData)
        raise Exception('data mistmach')

#-------------------------------------------------
# Calling all test code
#-------------------------------------------------
if testUtil.getMachineName() == "axone":
    try:
        main()
    except:
        print ( "\nTest Suite completed with error(s)" )
        testUtil.collectFFDC()
        raise()

    print ( "\nTest Suite completed with no errors" )
else:
    main()

    if err:
        print ("\nTest Suite completed with error(s)")
        #sys.exit(1)
    else:
        print ("\nTest Suite completed with no errors")
        #sys.exit(0);

OpenPOWER on IntegriCloud