summaryrefslogtreecommitdiffstats
path: root/src/usr/hwpf/test/hwpisteperrortest.H
blob: f6fbd1faf673cf911fcc9731a1bb9ec0ba56d985 (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/hwpf/test/hwpisteperrortest.H $                       */
/*                                                                        */
/* IBM CONFIDENTIAL                                                       */
/*                                                                        */
/* COPYRIGHT International Business Machines Corp. 2012,2013              */
/*                                                                        */
/* p1                                                                     */
/*                                                                        */
/* Object Code Only (OCO) source materials                                */
/* Licensed Internal Code Source Materials                                */
/* IBM HostBoot Licensed Internal Code                                    */
/*                                                                        */
/* The source code for this program is not published or otherwise         */
/* divested of its trade secrets, irrespective of what has been           */
/* deposited with the U.S. Copyright Office.                              */
/*                                                                        */
/* Origin: 30                                                             */
/*                                                                        */
/* IBM_PROLOG_END_TAG                                                     */
#ifndef __HWPIstepErrorTest_H
#define __HWPIstepErrorTest_H

#include <cxxtest/TestSuite.H>
#include <errl/errlentry.H>
#include <hwpisteperror.H>
#include <istepdispatcher.H>

using namespace ISTEP;
using namespace ISTEP_ERROR;

class HwpIStepErrorTest: public CxxTest::TestSuite
{
public:
    /**
     * @brief Test IStepError class
     */
    void testIstepError1(void)
    {
        uint8_t l_iStep = 0;
        uint8_t l_subStep =0;
        const uint16_t MY_REASON_CODE = 0xC0DE;
        const uint8_t  MY_MODULE_ID = 0xBB;

        TS_TRACE("testIStepError1: entry");

        // Get the expected iStep and subStep. Likely the last valid values
        // since the test case is running after the iSteps.
        INITSERVICE::IStepDispatcher::
                getTheInstance().getIstepInfo(l_iStep,l_subStep);

        // Create an error log
        errlHndl_t l_errl = new ERRORLOG::ErrlEntry(
                                ERRORLOG::ERRL_SEV_INFORMATIONAL,
                                MY_MODULE_ID,
                                MY_REASON_CODE,
                                TWO_UINT32_TO_UINT64( 0xDE, 0xAD),
                                TO_UINT64(0xBEEF) );
        do {

            IStepError l_stepError;

            l_stepError.addErrorDetails( l_errl );

            TS_TRACE("testIStepError1: original elog eid is %d",
                          l_errl->eid() );

            TS_TRACE("testIStepError1: original elog reasoncode is %d",
                          l_errl->reasonCode() );

            // grab the values from the original errorlog for use later
            uint64_t test_data0 = l_errl->eid();
            test_data0 <<= 32;

            test_data0 |= l_errl->reasonCode();

            // this call to get resets the error handle
            errlHndl_t new_errl = l_stepError.getErrorHandle();

            uint64_t l_data0 = new_errl->getUserData1();

            uint32_t eid = ( l_data0  & 0xFFFFFFFF00000000) >> 32;
            uint32_t reason = (uint32_t)(l_data0 & 0x00000000FFFFFFFF);

            // Verify the reference to the added error log.
            // Added log id is in bytes 0-3 of userdata 1.
            // Reason code is in bytes 4-6 of userdata 1.
            if( eid != l_errl->eid() )
            {
                TS_FAIL("testIstepError1: expected"
                            "eid[0x%.8x] == l_errl->eid()[0x%.8x] "
                            "eid rebuilt from user data of "
                            "IStepError did not match original error eid",
                            eid, l_errl->eid());
            }
            else
            {
                TS_TRACE("testIstepError1: passed: eid == l_errl->eid()");
            }

            if( reason != l_errl->reasonCode() )
            {
                TS_FAIL("testIstepError1: "
                        "expected reasonCode == l_errl->reasonCode() \
                          reasonCode rebuilt from user data of \
                          IStepError did not match original reasoncode");

            }
            else
            {
                TS_TRACE("testIstepError1: passed: "
                         "reason == l_errl->reasonCode()");
            }

            // Verify that we counted the error we added.
            // Count is in bytes 0-3 of userdata 2.
            // iStep and subStep in bytes 4-6 of userdata 2.
            uint64_t l_data1 = new_errl->getUserData2();

            uint32_t l_count  = ( l_data1&0xFFFFFFFF00000000 ) >> 32;
            uint32_t l_errlStepSubStep =
                            (uint32_t)(l_data1&0x00000000FFFFFFFF);
            uint32_t l_expectedStepSubStep =
                            (uint32_t)(l_subStep | (l_iStep<<8));

            if( l_count != 1 )
            {
                TS_FAIL("error count in IStepError not correct,"
                        " should be 1, is %d",l_count);
            }
            else
            {
                TS_TRACE("passed: error count = 1");
            }

            if( l_errlStepSubStep != l_expectedStepSubStep )
            {
                TS_FAIL("Step/SubStep in IStepError not correct,"
                        " should be 0x%08x, is 0x%08x ",
                        l_expectedStepSubStep,
                        l_errlStepSubStep);
            }
            else
            {
                TS_TRACE("passed: step/subStep correct");
            }

            errlCommit( l_errl, CXXTEST_COMP_ID );
            errlCommit( new_errl, CXXTEST_COMP_ID );

        }while(0);
    }

    void testIstepError2(void)
    {
        uint8_t l_iStep = 0;
        uint8_t l_subStep =0;
        const uint16_t MY_REASON_CODE = 0xC0DE;
        const uint8_t  MY_MODULE_ID = 0xBB;

        TS_TRACE("testIStepError2: entry");

        // Get the expected iStep and subStep. Likely the last valid values
        // since the test case is running after the iSteps.
        INITSERVICE::IStepDispatcher::
                getTheInstance().getIstepInfo(l_iStep,l_subStep);

        // Create an error log
        errlHndl_t l_errl = new ERRORLOG::ErrlEntry(
                                ERRORLOG::ERRL_SEV_INFORMATIONAL,
                                MY_MODULE_ID,
                                MY_REASON_CODE,
                                TWO_UINT32_TO_UINT64( 0xDE, 0xAD),
                                TO_UINT64(0xBEEF) );
        do {

            IStepError l_stepError;

            l_stepError.addErrorDetails( l_errl );

            TS_TRACE("testIStepError2: original elog eid is %d",
                      l_errl->eid() );

            TS_TRACE("testIStepError2: original elog reasoncode is %d",
                      l_errl->reasonCode() );

            // grab the values from the original errorlog for use later
            uint64_t test_data0 = l_errl->eid();
            test_data0 <<= 32;

            test_data0 |= l_errl->reasonCode();

            // add a new elog in three more times..
            // Create an error log -- junk data
            errlHndl_t l_errl2 = new ERRORLOG::ErrlEntry(
                                ERRORLOG::ERRL_SEV_INFORMATIONAL,
                                0x05,
                                0xcafe,
                                TWO_UINT32_TO_UINT64( 0xDE, 0xAD),
                                TO_UINT64(0xBEEF) );

            l_stepError.addErrorDetails( l_errl2 );
            l_stepError.addErrorDetails( l_errl2 );
            l_stepError.addErrorDetails( l_errl2 );

            // count should be 4 and the data0 and data 1 values of the
            // istep error should be the same as before

            // this call to get resets the error handle
            errlHndl_t new_errl = l_stepError.getErrorHandle();

            uint64_t l_data0 = new_errl->getUserData1();

            uint32_t eid = ( l_data0  & 0xFFFFFFFF00000000) >> 32;
            uint32_t reason = (uint32_t)(l_data0 & 0x00000000FFFFFFFF);

            if( eid != l_errl->eid() )
            {
                TS_FAIL("testIStepError2: expected "
                        "eid[0x%.8x] == l_errl->eid()[0x%.8x] "
                        "eid rebuilt from user data of "
                        "IStepError did not match original error eid",
                        eid, l_errl->eid());
            }
            else
            {
                TS_TRACE("testIStepError2: passed: eid == l_errl->eid()");
            }

            if( reason != l_errl->reasonCode() )
            {
                TS_FAIL("testIStepError2: "
                        "expected reasonCode == l_errl->reasonCode()"
                        "reasonCode rebuilt from user data of"
                        "IStepError did not match original reasoncode");

            }
            else
            {
                TS_TRACE("testIStepError2: passed: "
                         "reason == l_errl->reasonCode()");
            }

            // Verify that 4 logs have been added.
            // Count is in bytes 0-3 of userdata 2.
            // iStep and subStep in bytes 4-6 of userdata 2.
            uint64_t l_data1 = new_errl->getUserData2();

            uint32_t l_count  = ( l_data1&0xFFFFFFFF00000000 ) >> 32;
            uint32_t l_errlStepSubStep =
                            (uint32_t)(l_data1&0x00000000FFFFFFFF);
            uint32_t l_expectedStepSubStep =
                            (uint32_t)(l_subStep | (l_iStep<<8));

            if( l_count != 4 )
            {
                TS_FAIL("error count in IStepError not correct,"
                        " should be 4, is %d",l_count);
            }
            else
            {
                TS_TRACE("passed: error count = 4");
            }

            if( l_errlStepSubStep != l_expectedStepSubStep )
            {
                TS_FAIL("Step/SubStep in IStepError not correct,"
                        " should be 0x%08x, is 0x%08x ",
                        l_expectedStepSubStep,
                        l_errlStepSubStep);
            }
            else
            {
                TS_TRACE("passed: step/subStep correct");
            }

            errlCommit( l_errl, CXXTEST_COMP_ID );
            errlCommit( new_errl, CXXTEST_COMP_ID );
            errlCommit( l_errl2, CXXTEST_COMP_ID );

        }while(0);
    }

};
#endif
OpenPOWER on IntegriCloud