summaryrefslogtreecommitdiffstats
path: root/src/usr/spd/test/dimmPrestest.H
blob: 46dad62c53b45393f37eb5e8bed8346ca8d47a87 (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
//  IBM_PROLOG_BEGIN_TAG
//  This is an automatically generated prolog.
//
//  $Source: src/usr/spd/test/dimmPrestest.H $
//
//  IBM CONFIDENTIAL
//
//  COPYRIGHT International Business Machines Corp. 2012
//
//  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 other-
//  wise divested of its trade secrets, irrespective of what has
//  been deposited with the U.S. Copyright Office.
//
//  Origin: 30
//
//  IBM_PROLOG_END
#ifndef __DIMMPRESTEST_H
#define __DIMMPRESTEST_H

/**
 *  @file dimmPrestest.H
 *
 *  @brief Test cases for DIMM Presence detect
 */
#include <sys/time.h>

#include <cxxtest/TestSuite.H>
#include <errl/errlmanager.H>
#include <errl/errlentry.H>
#include <devicefw/driverif.H>
#include <targeting/predicates/predicatectm.H>

#include <spd/spdreasoncodes.H>
#include <spd/spdenums.H>
#include "spdtest.H"
#include "../spd.H"

extern trace_desc_t* g_trac_spd;

using namespace TARGETING;
using namespace SPD;

class DIMMPresTest: public CxxTest::TestSuite
{
    public:

        /**
         * @brief This test is for testing the DIMM Presence detect logic.
         */
        void testDimmPres ( void )
        {
            errlHndl_t err = NULL;
            uint64_t cmds = 0x0;
            uint64_t fails = 0x0;
            bool present = false;
            size_t presentSize = sizeof(present);

            TRACFCOMP( g_trac_spd,
                       ENTER_MRK"testDimmPres()" );

            do
            {
                TARGETING::Target * theTarget = NULL;

                // Get DIMM Targets
                TargetHandleList dimmList;
                getDIMMTargets( dimmList );

                if( ( 0 == dimmList.size() ) ||
                    ( NULL == dimmList[0] ) )
                {
                    TRACFCOMP( g_trac_spd,
                               "testDimmPres() - No DIMMs found!" );
                    break;
                }

                for( uint32_t dimm = 0; dimm < dimmList.size(); dimm++ )
                {
                    cmds++;
                    theTarget = dimmList[dimm];

                    // Check presence
                    err = deviceRead( theTarget,
                                      &present,
                                      presentSize,
                                      DEVICE_PRESENT_ADDRESS() );

                    if( err )
                    {
                        fails++;
                        TS_FAIL( "testDimmPres() - Error returned from DIMM Presence "
                                 "Detect call!" );
                        errlCommit( err,
                                    SPD_COMP_ID );
                        continue;
                    }
                    else if( presentSize != sizeof(present) )
                    {
                        fails++;
                        TS_FAIL( "testDimmPrs() - Size of Presence buffer is not size "
                                 "of boolean!" );
                        continue;
                    }
                    else
                    {
                        // Test was good.
                    }
                }

                if( err )
                {
                    break;
                }
            } while( 0 );

            TRACFCOMP( g_trac_spd,
                       "testDimmPres - %d/%d fails",
                       fails, cmds );
        }


        /**
         * @brief This test tests that invalid sizes for Presence detect
         *      return errors.
         */
        void testDimmPresInvalidSize ( void )
        {
            errlHndl_t err = NULL;
            uint64_t cmds = 0x0;
            uint64_t fails = 0x0;
            bool present = false;
            size_t presentSize = 0x0;

            TRACFCOMP( g_trac_spd,
                       ENTER_MRK"testDimmPresInvalidSize()" );

            do
            {
                TARGETING::Target * theTarget = NULL;

                // Get DIMM Targets
                TargetHandleList dimmList;
                getDIMMTargets( dimmList );

                if( ( 0 == dimmList.size() ) ||
                    ( NULL == dimmList[0] ) )
                {
                    TRACFCOMP( g_trac_spd,
                               "testDimmPresInvalidSize() - No DIMMs found!" );
                    break;
                }

                for( uint32_t dimm = 0; dimm < dimmList.size(); dimm++ )
                {
                    cmds++;
                    theTarget = dimmList[dimm];

                    // Check presence
                    err = deviceRead( theTarget,
                                      &present,
                                      presentSize,
                                      DEVICE_PRESENT_ADDRESS() );

                    if( !err )
                    {
                        fails++;
                        TS_FAIL( "testDimmPresInvalidSize() - Error not flagged for "
                                 "invalid size!" );
                        errlCommit( err,
                                    SPD_COMP_ID );
                        continue;
                    }
                    else
                    {
                        // Delete the error and continue
                        delete err;
                        err = NULL;
                        continue;
                    }
                }

                if( err )
                {
                    break;
                }
            } while( 0 );

            TRACFCOMP( g_trac_spd,
                       "testDimmPresInvalidSize() - %d/%d fails",
                       fails, cmds );
        }


};

#endif
OpenPOWER on IntegriCloud