summaryrefslogtreecommitdiffstats
path: root/src/usr/expaccess/test/expErrlTest.C
blob: 10f3b1189b1d08a7fcbbe8f4c9f8ea5b66d7e618 (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/expaccess/test/expErrlTest.C $                        */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 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                                                     */
/**
 *  @file expErrlTest.C
 *  @brief Tests the various ways to grab/add explorer error log data
 */
#include <rcExpLog.H>  // RC error log side
#include <fapi2.H>
#include <fapi2/plat_hwp_invoker.H>    // FAPI_INVOKE_HWP
#include <errl/errlmanager.H>
#include "../errlud_expscom.H" // HB error log side


fapi2::ReturnCode get_scom(const fapi2::Target<fapi2::TARGET_TYPE_OCMB_CHIP>& i_target,
                               const uint64_t i_address,
                               fapi2::buffer<uint64_t>& o_data)
{
  return fapi2::getScom(i_target,i_address,o_data);
}

uint32_t expErrorLogHb()
{
    uint32_t numTests = 0;
    uint32_t numFails = 0;
    errlHndl_t l_err = nullptr;

    // Create a vector of TARGETING::Target pointers
    TARGETING::TargetHandleList l_chipList;

    // Get a list of all of the functioning ocmb chips
    TARGETING::getAllChips(l_chipList, TARGETING::TYPE_OCMB_CHIP, true);

    //Verify at least one ocmb found, some systems do not have ocmb chips
    if(l_chipList.size() == 0 )
    {
        FAPI_INF("expErrorLogHb: No OCMB targets found, skipping test");
    }

    // create an error for each OCMB and grab the trace data
    for ( auto & l_ocmb : l_chipList )
    {
        //  Get a scom error with bad address
        FAPI_INF("expErrorLogHb - Get a scom error with bad address for ocmb 0x%.8X",
                  TARGETING::get_huid(l_ocmb));
        numTests++;
        fapi2::Target<fapi2::TARGET_TYPE_OCMB_CHIP> fapi2_ocmbTarget(l_ocmb);
        fapi2::buffer<uint64_t> l_scom_buffer;
        FAPI_INVOKE_HWP( l_err, get_scom, fapi2_ocmbTarget,
                         0xFFFFFFFF, l_scom_buffer );
        if (l_err)
        {
            FAPI_INF("expErrorLogHb - created error log 0x%04X, now adding explorer errors", l_err->plid());

            // Add explorer error logs to this and commit
            bool logAdded = false;
            numTests++;
            logAdded = EXPSCOM::expAddLog(EXPSCOM::ACTIVE_LOG, l_ocmb, l_err);
            if (!logAdded)
            {
                TS_FAIL("expErrorLogHb: No ACTIVE explorer logs added to 0x%04X", l_err->plid());
                numFails++;
            }

            numTests++;
            logAdded = EXPSCOM::expAddLog(EXPSCOM::SAVED_LOG, l_ocmb, l_err);
            if (!logAdded)
            {
                TS_FAIL("expErrorLogHb: No SAVED explorer logs added to 0x%04X", l_err->plid());
                numFails++;
            }
            errlCommit(l_err, CXXTEST_COMP_ID);
        }
        else
        {
            TS_FAIL("expErrorLogHb: getScom(0xFFFFFFFF) worked on 0x%.8X",
                    TARGETING::get_huid(l_ocmb));
            numFails++;
        }
    }

    FAPI_INF("expErrorLogHb Test Complete. %d/%d fails", numFails, numTests);

    return numFails;
}

uint32_t expErrorLogRc()
{
    uint32_t numTests = 0;
    uint32_t numFails = 0;
    errlHndl_t l_errl = nullptr;
    FAPI_INF("expErrorLogRc() running");
    do
    {
        // Create a vector of TARGETING::Target pointers
        TARGETING::TargetHandleList l_chipList;

        // Get a list of all of the functioning ocmb chips
        TARGETING::getAllChips(l_chipList, TARGETING::TYPE_OCMB_CHIP, true);
        TARGETING::Target * l_ocmb = nullptr;

        //Take the first ocmb and use it
        if (l_chipList.size() > 0)
        {
            l_ocmb = l_chipList[0];
        }
        else
        {
            FAPI_INF("expErrorLogRc: No OCMB targets found, skipping test");
            break;
        }

        numTests++;
        fapi2::Target<fapi2::TARGET_TYPE_OCMB_CHIP> fapi2_ocmbTarget(l_ocmb);
        // This procedure creates an RC error and then adds Explorer log data
        // to that error
        // (0x500 bytes of ACTIVE log data, 0x450 bytes of SAVED log data)
        FAPI_INVOKE_HWP(l_errl, exp_error_rc, fapi2_ocmbTarget, 0x500, 0x450);
        if(l_errl != nullptr)
        {
            // Commit this error log so it can be examined for Explorer log data
            FAPI_INF("exp_errorFfdc_fail returned expected errl");
            errlCommit(l_errl,CXXTEST_COMP_ID);
            l_errl = nullptr;
        }
        else
        {
            TS_FAIL("expErrorLogRc: No error from exp_errorFfdc_fail !!");
            numFails++;
        }
    } while (0);

    FAPI_INF("expErrorLogRc Test Complete. %d/%d fails",
        numFails , numTests);

    return numFails;
}
OpenPOWER on IntegriCloud