summaryrefslogtreecommitdiffstats
path: root/src/usr/fsiscom/test/fsiscomtest.H
blob: c1d2b9168564bb3e80cfc63e628930b1a7c511b3 (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/fsiscom/test/fsiscomtest.H $                          */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* COPYRIGHT International Business Machines Corp. 2011,2014              */
/*                                                                        */
/* 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 <cxxtest/TestSuite.H>
#include <errl/errlmanager.H>
#include <errl/errlentry.H>
#include <limits.h>
#include <devicefw/driverif.H>
#include <fsiscom/fsiscom_reasoncodes.H>

extern trace_desc_t* g_trac_fsiscom;

class FsiScomTest : public CxxTest::TestSuite
{
  public:

    /**
     * @brief Test error path and recovery
     */
    void test_Error(void)
    {
        TRACFCOMP( g_trac_fsiscom, "FsiScomTest::test_Error> Start" );

        uint64_t fails = 0;
        uint64_t total = 0;
        errlHndl_t l_err = NULL;
        uint64_t regdata = 0;
        size_t op_size = sizeof(uint64_t);

        // Centaur target
        TARGETING::EntityPath epath(TARGETING::EntityPath::PATH_PHYSICAL);
        epath.addLast(TARGETING::TYPE_SYS,0);
        epath.addLast(TARGETING::TYPE_NODE,0);
        epath.addLast(TARGETING::TYPE_MEMBUF,4);
        TARGETING::Target* fsi_target =
          TARGETING::targetService().toTarget(epath);
        if( fsi_target == NULL )
        {
            TRACFCOMP( g_trac_fsiscom, "FsiScomTest::test_Error> Target is NULL" );
            TS_FAIL( "FsiScomTest::test_Error> Target is NULL" );
        }

        // Bad address read
        total++;
        l_err = DeviceFW::deviceOp(
                          DeviceFW::READ,
                          fsi_target,
                          &regdata,
                          op_size,
                          DEVICE_FSISCOM_ADDRESS(0x11111111) );
        if( l_err && (l_err->reasonCode() == FSISCOM::RC_READ_ERROR) )
        {
            delete l_err;
        }
        else
        {
            TRACFCOMP(g_trac_fsiscom, "FsiScomTest::test_Error> No/wrong error for bad address read, RC=%X", ERRL_GETRC_SAFE(l_err) );
            TS_FAIL( "FsiScomTest::test_Error> No/wrong error for bad address read" );
            fails++;
            if( l_err ) { errlCommit(l_err,FSISCOM_COMP_ID); }
        }

        // Bad address write
        total++;
        l_err = DeviceFW::deviceOp(
                          DeviceFW::WRITE,
                          fsi_target,
                          &regdata,
                          op_size,
                          DEVICE_FSISCOM_ADDRESS(0x00222222) );
        if( l_err && (l_err->reasonCode() == FSISCOM::RC_WRITE_ERROR) )
        {
            delete l_err;
        }
        else
        {
            TRACFCOMP(g_trac_fsiscom, "FsiScomTest::test_Error> No/wrong error for bad address write, RC=%X", ERRL_GETRC_SAFE(l_err) );
            TS_FAIL( "FsiScomTest::test_Error> No/wrong error for bad address write" );
            fails++;
            if( l_err ) { errlCommit(l_err,FSISCOM_COMP_ID); }
        }

        // Do a good scom to prove things are working again
        total++;
        l_err = DeviceFW::deviceOp(
                          DeviceFW::READ,
                          fsi_target,
                          &regdata,
                          op_size,
                          DEVICE_FSISCOM_ADDRESS(0x02011403) );
        if( l_err )
        {
            TRACFCOMP(g_trac_fsiscom, "FsiScomTest::test_Error> Error reading 0x02011403, RC=%X", ERRL_GETRC_SAFE(l_err) );
            TS_FAIL( "FsiScomTest::test_Error> Error reading 0x02011403" );
            fails++;
            errlCommit(l_err,FSISCOM_COMP_ID);
        }

        TRACFCOMP( g_trac_fsiscom, "FsiScomTest::test_Error> %d/%d fails", fails, total );
    };
};
OpenPOWER on IntegriCloud