summaryrefslogtreecommitdiffstats
path: root/src/usr/targeting/test/testattrsync.H
blob: 673c2260dd3d9229670a30a2608858403ceffa69 (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/targeting/test/testattrsync.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 __TARGETING_TESTATTRSYNC_H
#define __TARGETING_TESTATTRSYNC_H

/**
 *  @file targeting/test/testattrsync.H
 *
 *  @brief All unit tests which test attribute sync
 */

//******************************************************************************
// Includes
//******************************************************************************

// STD
#include <stdio.h>
#include <sys/time.h>

// CXXTEST
#include <cxxtest/TestSuite.H>
#include <errl/errlmanager.H>

// This component
#include <targeting/common/attributes.H>
#include <targeting/common/entitypath.H>
#include <targeting/common/target.H>
#include <targeting/common/targetservice.H>
#include <targeting/common/iterators/rangefilter.H>
#include <targeting/common/predicates/predicatectm.H>
#include <targeting/common/predicates/predicatepostfixexpr.H>
#include <targeting/attrsync.H>
#include <errl/errludtarget.H>
#include <targeting/common/trace.H>
#include <kernel/console.H>
#include <initservice/initserviceif.H>

class AttrSyncTestSuite : public CxxTest::TestSuite
{
  public:

    /**
     *  @brief Test sync of targeting attributes to FSP
     */
    void testAttributeSync()
    {
        TS_TRACE(ENTER_MRK "testAttributeSync" );

        using namespace TARGETING;

        AttributeSync l_attrSync;

        TS_TRACE( "Sync PNOR RW" );

        errlHndl_t err = l_attrSync.syncSectionToFsp(
                                    TARGETING::SECTION_TYPE_PNOR_RW );

        if( err )
        {
            if( INITSERVICE::spBaseServicesEnabled() )
            {
                TS_FAIL(" Error returned when syncing SECTION_TYPE_PNOR_RW");
            }
            delete err;
            err = NULL;
        }

        TS_TRACE("Sync PNOR INIT " );

        err = l_attrSync.syncSectionToFsp(
                TARGETING::SECTION_TYPE_HEAP_PNOR_INIT );

        if( err )
        {
            if( INITSERVICE::spBaseServicesEnabled() )
            {
                TS_FAIL(" Error returned when syncing SECTION_TYPE_HEAP_PNOR_INIT"); 
            }
            delete err;
            err = NULL;
        }

        TS_TRACE( "Sync PNOR ZERO INIT" );

        err = l_attrSync.syncSectionToFsp(  
                TARGETING::SECTION_TYPE_HEAP_ZERO_INIT );

        if( err )
        {
           if( INITSERVICE::spBaseServicesEnabled() )
           {
               TS_FAIL(" Error returned when syncing SECTION_TYPE_HEAP_ZERO_INIT"); 
           }
           delete err;
           err = NULL;
        }

    }

    /**
     *  @brief Test sync of targeting attributes from FSP
     */
    void testAttributeSyncFromFsp()
    {
        TS_TRACE(ENTER_MRK "testAttributeSyncFromFsp" );

        using namespace TARGETING;

        AttributeSync l_attrSync;

        errlHndl_t l_errl = NULL;

        do
        {

            // create Hostboot message queue
            msg_q_t l_hbMsgQ = msg_q_create();

            // register Hostboot message queue with mailbox to receive messages
            l_errl = MBOX::msgq_register(MBOX::HB_ATTR_SYNC_MSGQ, l_hbMsgQ);
            if (l_errl)
            {
                TS_FAIL( "Error registering the Hostboot message queue with "
                    "mailbox service."); 
                delete l_errl;
                l_errl = NULL;
                break;
            }

            // these are the sections we want to sync
            SECTION_TYPE section_type[] ={SECTION_TYPE_PNOR_RW,
                                          SECTION_TYPE_HEAP_PNOR_INIT,
                                          SECTION_TYPE_HEAP_ZERO_INIT};

            size_t section_count = sizeof(section_type)/sizeof(section_type[0]);

            // pull all attributes from FSP
            AttributeSync l_Sync;

            for(uint8_t i = 0; i < section_count; i++)
            {
                TS_TRACE( "Syncing section type %d", section_type[i] );

                l_errl = l_Sync.syncSectionFromFsp( section_type[i], l_hbMsgQ );

                if (l_errl)
                {
                    if( INITSERVICE::spBaseServicesEnabled() )
                    {
                        TS_FAIL( "Error returned when syncing section type %d "
                        "from FSP", section_type[i]);
                    }

                    delete l_errl;
                    l_errl = NULL;
                }
            }

            // unregister the Hosboot message queue from the mailbox service.
            MBOX::msgq_unregister(MBOX::HB_ATTR_SYNC_MSGQ);

        } while (0);

        TS_TRACE(EXIT_MRK "testAttributeSyncFromFsp" );
    }
};

#endif // End __TARGETING_TESTTARGETING_H
OpenPOWER on IntegriCloud