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
|
/* IBM_PROLOG_BEGIN_TAG */
/* This is an automatically generated prolog. */
/* */
/* $Source: src/usr/scom/test/ibscom_retry_test.H $ */
/* */
/* OpenPOWER HostBoot Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2017 */
/* [+] 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 */
#ifndef __SCOM_IBSCOM_RETRY_TEST
#define __SCOM_IBSCOM_RETRY_TEST
#include "../ibscom_retry.H"
#include <ibscom/ibscomreasoncodes.H>
#include <errl/errlreasoncodes.H>
#include <cxxtest/TestSuite.H>
#include <trace/interface.H>
// Tracing is disabled by default.
// To turn on tracing, build the tests as shown below:
// TRACE_SCOM_UNIT_TEST=1 make -j32
#ifdef TRACE_SCOM_UNIT_TEST
extern trace_desc_t* g_trac_scom;
#define SCOM_IBSCOM_TRACF(printf_string,args...) \
TRACFCOMP(g_trac_scom,"IbScomRetryTest::" printf_string,##args)
#else
#define SCOM_IBSCOM_TRACF(printf_string,args...)
#endif
//Package the TS_FAIL macro with TRACFCOMP error reporting.
//The TS_FAIL macro output seems to be separated from
//TRACFCOMP output. This can be confusing when adding
//trace statements to the tests while debugging. The failure
//message from the SCOM_IBSCOM_TRACF macro will
//appear inline and in the proper context to other trace
//statements which may be added during debugging.
#define FAIL_IBSCOM_TEST(printf_string,args...) \
SCOM_IBSCOM_TRACF(printf_string, ##args); \
TS_FAIL("IbScomRetryTest::" printf_string, ##args)
using namespace SCOM;
using namespace ERRORLOG;
class IbScomRetryTest: public CxxTest::TestSuite
{
public:
//--------------------------------------------
// The IbscomRetry workaround will request a
// retry if an error occurred with a result code
// of IBSCOM::IBSCOM_RETRY_DUE_TO_ERROR.
//
// requestRetry parameters retry Conditions
// 1) errlHndl_t - Not Null and Reason Code is
// IBSCOM::IBSCOM_RETRY_DUE_TO_ERROR
// 2) uint32_t i_retryCount - Must be 0.
// 3) DeviceFW::OperationType - Not Used
// 4) TARGETING::Target* i_target - Not Used
// 5) void* i_buffer - Not Used
// 6) size_t i_buflen - Not Used
// 7) int64_t i_accessType - Not Used
// 8) uint64_t i_addr - Not Used
//
void test_lbscom_retry()
{
bool l_result{true};
do
{
//Get the single IbscomRetry instance.
std::shared_ptr<const PostOpRetryCheck> l_wrkaround =
IbscomRetry::theInstance();
if(not l_wrkaround)
{
FAIL_IBSCOM_TEST("test_lbscom_retry: "
"IbscomRetry::theInstance returned a "
"nullptr!"
);
l_result = false;
break;
}
uint16_t l_reasonCodeForTrue{IBSCOM::IBSCOM_RETRY_DUE_TO_ERROR};
uint16_t l_reasonCodeForFalse{
static_cast<uint16_t>(l_reasonCodeForTrue + 1)};
uint32_t l_retryCount{0};
std::shared_ptr<ErrlEntry> l_errl;
// Test 1
// Use a successful error entry (nullptr).
//
// 1) errlHndl_t - NULL <--- causes false result
//
// 2) uint32_t i_retryCount - 0.
//
// Expected return: FALSE.
//
bool l_retval = l_wrkaround->requestRetry(l_errl.get(),
l_retryCount,
DeviceFW::READ,
nullptr,
nullptr,
0,
0,
0
);
if(l_retval)
{
FAIL_IBSCOM_TEST("test_lbscom_retry: "
"requestRetry unexpectedly returned true "
"for a nullptr errlHndl_t."
);
l_result = false;
break;
}
l_errl.reset(new ErrlEntry(ERRL_SEV_INFORMATIONAL,
ERRL_TEST_MOD_ID,
l_reasonCodeForTrue,
0,
0,
false
)
);
// Test 2
// A non-nullptr error with reason code
// IBSCOM::IBSCOM_RETRY_DUE_TO_ERROR and
// Retry Count equal to 0.
//
// 1) errlHndl_t - Not Null and Reason Code is
// IBSCOM::IBSCOM_RETRY_DUE_TO_ERROR
// 2) uint32_t i_retryCount - 0.
//
// Expected result: TRUE
//
l_retval = l_wrkaround->requestRetry(l_errl.get(),
l_retryCount,
DeviceFW::READ,
nullptr,
nullptr,
0,
0,
0
);
if(not l_retval)
{
FAIL_IBSCOM_TEST("test_lbscom_retry: "
"requestRetry unexpectedly returned false "
"for reson code "
"IBSCOM::IBSCOM_RETRY_DUE_TO_ERROR and retry "
"attempts %d.",
l_retryCount
);
l_result = false;
break;
}
// Test 3
// A non-nullptr error with reason code
// IBSCOM::IBSCOM_RETRY_DUE_TO_ERROR and
// Retry Count equal to 1.
//
// 1) errlHndl_t - Not Null and Reason Code is
// IBSCOM::IBSCOM_RETRY_DUE_TO_ERROR
// 2) uint32_t i_retryCount - 1 <--- Causes False Result
//
// Expected result: FALSE
//
++l_retryCount;
l_retval = l_wrkaround->requestRetry(l_errl.get(),
l_retryCount,
DeviceFW::READ,
nullptr,
nullptr,
0,
0,
0
);
if(l_retval)
{
FAIL_IBSCOM_TEST("test_lbscom_retry: "
"requestRetry unexpectedly returned true "
"for reson code "
"IBSCOM::IBSCOM_RETRY_DUE_TO_ERROR and retry "
"attempts %d. The requestRetry should not "
"request more than one retry.",
l_retryCount
);
l_result = false;
break;
}
l_retryCount = 0;
l_errl.reset(new ErrlEntry(ERRL_SEV_INFORMATIONAL,
ERRL_TEST_MOD_ID,
l_reasonCodeForFalse,
0,
0,
false
)
);
// Test 4
// A non-nullptr error with reason code NOT
// IBSCOM::IBSCOM_RETRY_DUE_TO_ERROR and
// Retry Count equal to 0.
//
// 1) errlHndl_t - Not Null and Reason Code is NOT <-- Causes False
// IBSCOM::IBSCOM_RETRY_DUE_TO_ERROR
// 2) uint32_t i_retryCount - 0.
//
// Expected result: FALSE
//
l_retval = l_wrkaround->requestRetry(l_errl.get(),
l_retryCount,
DeviceFW::READ,
nullptr,
nullptr,
0,
0,
0
);
if(l_retval)
{
FAIL_IBSCOM_TEST("test_lbscom_retry: "
"requestRetry unexpectedly returned true "
"for reson code NOT equal to "
"IBSCOM::IBSCOM_RETRY_DUE_TO_ERROR. "
"A retry should only happen if the reason "
"code for the passed in error is equal to "
"IBSCOM::IBSCOM_RETRY_DUE_TO_ERROR."
);
l_result = false;
break;
}
}
while(0);
if(l_result)
{
SCOM_IBSCOM_TRACF("IbScomRetryTest: Test Passed!");
}
else
{
SCOM_IBSCOM_TRACF("IbScomRetryTest: Test Failed!");
}
}
};
#endif
|