summaryrefslogtreecommitdiffstats
path: root/src/usr/fapi2/test/fapi2CreatePlatLogTest.H
blob: 3cccd74c174b50da9ed89fbb5d8ab43e366dd5c4 (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/fapi2/test/fapi2CreatePlatLogTest.H $                 */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2018                             */
/* [+] 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                                                     */

#include <plat_utils.H>
#include <hwpf_fapi2_reasoncodes.H>
#include <cxxtest/TestSuite.H>
#include <errl/errlmanager.H>
#include <errl/hberrltypes.H>
#include <errl/errlreasoncodes.H>
#include <errl/errlentry.H>

extern trace_desc_t* g_trac_runtime;

class CreatePlatLogTest : public CxxTest::TestSuite
{
public:

    void testCreatePlatLogCreatorFapi2()
    {
        TRACFCOMP(g_trac_runtime, "testCreatePlatLogCreatorFapi2 running");

        fapi2::ReturnCode l_rc = fapi2::FAPI2_RC_INVALID_ATTR_GET;
        fapi2::errlSeverity_t l_sev = fapi2::FAPI2_ERRL_SEV_RECOVERED;
        createPlatLog(l_rc, l_sev);
        errlHndl_t l_errl = reinterpret_cast<errlHndl_t>(l_rc.getPlatDataPtr());
        if(l_errl->sev() != ERRORLOG::ERRL_SEV_RECOVERED)
        {
            TS_FAIL("testCreatePlatLogCreatorFapi2: incorrect errl severity. "
                    "Expected: %x Actual: %x",
                    ERRORLOG::ERRL_SEV_RECOVERED,
                    l_errl->sev());
        }
        else
        {
            TRACDCOMP(g_trac_runtime, "testCreatePlatLogCreatorFapi2: ERRL_SEV_RECOVERED passed");
        }
        l_rc.forgetData();


        l_sev = fapi2::FAPI2_ERRL_SEV_PREDICTIVE;
        createPlatLog(l_rc, l_sev);
        l_errl = reinterpret_cast<errlHndl_t>(l_rc.getPlatDataPtr());
        if(l_errl->sev() != ERRORLOG::ERRL_SEV_PREDICTIVE)
        {
            TS_FAIL("testCreatePlatLogCreatorFapi2: incorrect errl severity. "
                    "Expected: %x Actual: %x",
                    ERRORLOG::ERRL_SEV_PREDICTIVE,
                    l_errl->sev());
        }
        else
        {
            TRACDCOMP(g_trac_runtime, "testCreatePlatLogCreatorFapi2: ERRL_SEV_PREDICTIVE passed");
        }
        l_rc.forgetData();


        l_sev = fapi2::FAPI2_ERRL_SEV_UNRECOVERABLE;
        createPlatLog(l_rc, l_sev);
        if(l_errl->sev() != ERRORLOG::ERRL_SEV_UNRECOVERABLE)
        {
            TS_FAIL("testCreatePlatLogCreatorFapi2: incorrect errl severity. "
                    "Expected: %x Actual: %x",
                    ERRORLOG::ERRL_SEV_PREDICTIVE,
                    l_errl->sev());

        }
        else
        {
            TRACDCOMP(g_trac_runtime, "testCreatePlatLogCreatorFapi2: ERRL_SEV_UNRECOVERABLE passed");
        }
        l_rc.forgetData();

        TRACFCOMP(g_trac_runtime, "testCreatePlatLogCreatorFapi2 done");
    }

    void testCreatePlatLogCreatorPlat()
    {
        TRACFCOMP(g_trac_runtime, "testCreatePlatLogCreatorPlat running");

        fapi2::ReturnCode l_rc = fapi2::FAPI2_RC_PLAT_ERR_SEE_DATA;
        fapi2::errlSeverity_t l_sev = fapi2::FAPI2_ERRL_SEV_RECOVERED;
        // Allocate a fake error log since PLAT code path expects a non-null ptr
        errlHndl_t l_errl = new ERRORLOG::ErrlEntry(
                                ERRORLOG::ERRL_SEV_INFORMATIONAL,
                                ERRORLOG::ERRL_FIRST_MODULE_ID,
                                fapi2::RC_HWP_GENERATED_ERROR,
                                ERRORLOG::ERRL_TEST_REASON_CODE);
        l_rc.setPlatDataPtr(reinterpret_cast<void *>(l_errl));

        createPlatLog(l_rc, l_sev);
        l_errl = reinterpret_cast<errlHndl_t>(l_rc.getPlatDataPtr());
        if(l_errl->sev() != ERRORLOG::ERRL_SEV_RECOVERED)
        {
            TS_FAIL("testCreatePlatLogCreatorPlat: incorrect errl severity. "
                    "Expected: %x Actual: %x",
                    ERRORLOG::ERRL_SEV_RECOVERED,
                    l_errl->sev());
        }
        else
        {
            TRACDCOMP(g_trac_runtime, "testCreatePlatLogCreatorPlat: ERRL_SEV_RECOVERED passed");
        }

        l_sev = fapi2::FAPI2_ERRL_SEV_PREDICTIVE;
        createPlatLog(l_rc, l_sev);
        l_errl = reinterpret_cast<errlHndl_t>(l_rc.getPlatDataPtr());
        if(l_errl->sev() != ERRORLOG::ERRL_SEV_PREDICTIVE)
        {
            TS_FAIL("testCreatePlatLogCreatorPlat: incorrect errl severity. "
                    "Expected: %x Actual: %x",
                    ERRORLOG::ERRL_SEV_PREDICTIVE,
                    l_errl->sev());
        }
        else
        {
            TRACDCOMP(g_trac_runtime, "testCreatePlatLogCreatorPlat: ERRL_SEV_PREDICTIVE passed");
        }

        l_sev = fapi2::FAPI2_ERRL_SEV_UNRECOVERABLE;
        createPlatLog(l_rc, l_sev);
        l_errl = reinterpret_cast<errlHndl_t>(l_rc.getPlatDataPtr());
        if(l_errl->sev() != ERRORLOG::ERRL_SEV_UNRECOVERABLE)
        {
            TS_FAIL("testCreatePlatLogCreatorPlat: incorrect errl severity. "
                    "Expected: %x Actual: %x",
                    ERRORLOG::ERRL_SEV_PREDICTIVE,
                    l_errl->sev());

        }
        else
        {
            TRACDCOMP(g_trac_runtime, "testCreatePlatLogCreatorPlat: ERRL_SEV_UNRECOVERABLE passed");
        }
        l_rc.forgetData();

        TRACFCOMP(g_trac_runtime, "testCreatePlatLogCreatorPlat done");
    }

    void testCreatePlatLogCreatorHwp()
    {
        TRACFCOMP(g_trac_runtime, "testCreatePlatLogCreatorHwp running");

        fapi2::ReturnCode l_rc = 0x00000001; // Fake return code wit creator == HWP
        fapi2::errlSeverity_t l_sev = fapi2::FAPI2_ERRL_SEV_RECOVERED;
        createPlatLog(l_rc, l_sev);
        errlHndl_t l_errl = reinterpret_cast<errlHndl_t>(l_rc.getPlatDataPtr());
        if(l_errl->sev() != ERRORLOG::ERRL_SEV_RECOVERED)
        {
            TS_FAIL("testCreatePlatLogCreatorHwp: incorrect errl severity. "
                    "Expected: %x Actual: %x",
                    ERRORLOG::ERRL_SEV_RECOVERED,
                    l_errl->sev());
        }
        else
        {
            TRACDCOMP(g_trac_runtime, "testCreatePlatLogCreatorHwp: ERRL_SEV_RECOVERED passed");
        }
        l_rc.forgetData();

        l_sev = fapi2::FAPI2_ERRL_SEV_PREDICTIVE;
        createPlatLog(l_rc, l_sev);
        l_errl = reinterpret_cast<errlHndl_t>(l_rc.getPlatDataPtr());
        if(l_errl->sev() != ERRORLOG::ERRL_SEV_PREDICTIVE)
        {
            TS_FAIL("testCreatePlatLogCreatorHwp: incorrect errl severity. "
                    "Expected: %x Actual: %x",
                    ERRORLOG::ERRL_SEV_PREDICTIVE,
                    l_errl->sev());
        }
        else
        {
            TRACDCOMP(g_trac_runtime, "testCreatePlatLogCreatorHwp: ERRL_SEV_PREDICTIVE passed");
        }
        l_rc.forgetData();

        l_sev = fapi2::FAPI2_ERRL_SEV_UNRECOVERABLE;
        createPlatLog(l_rc, l_sev);
        l_errl = reinterpret_cast<errlHndl_t>(l_rc.getPlatDataPtr());
        if(l_errl->sev() != ERRORLOG::ERRL_SEV_UNRECOVERABLE)
        {
            TS_FAIL("testCreatePlatLogCreatorHwp: incorrect errl severity. "
                    "Expected: %x Actual: %x",
                    ERRORLOG::ERRL_SEV_PREDICTIVE,
                    l_errl->sev());

        }
        else
        {
            TRACDCOMP(g_trac_runtime, "testCreatePlatLogCreatorHwp: ERRL_SEV_UNRECOVERABLE passed");
        }
        l_rc.forgetData();

        TRACFCOMP(g_trac_runtime, "testCreatePlatLogCreatorHwp done");
    }
};

OpenPOWER on IntegriCloud