summaryrefslogtreecommitdiffstats
path: root/src/usr/hwas/test/hwas1test.H
blob: 2ee64815860c7e823610a685a46f59a7c5151a2f (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
//  IBM_PROLOG_BEGIN_TAG
//  This is an automatically generated prolog.
//
//  $Source: src/usr/targeting/test/targetingtest.H $
//
//  IBM CONFIDENTIAL
//
//  COPYRIGHT International Business Machines Corp. 2011
//
//  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 __TESTTARGETING_H
#define __TESTTARGETING_H

/**
 *  @file testtargeting.H
 *
 *  @brief Unit tests for HWAS (ISTEP 4)
 */

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

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

// CXXTEST
#include <cxxtest/TestSuite.H>
#include <hwpf/plat/fapiPlatAttributeService.H>
#include <fapiReturnCode.H>
#include <fapiAttributeIds.H>
#include <fapiAttributeService.H>
#include <errl/errlmanager.H>

// This component
#include <targeting/attributes.H>
#include <targeting/entitypath.H>
#include <targeting/target.H>
#include <targeting/targetservice.H>
#include <targeting/iterators/rangefilter.H>
#include <targeting/predicates/predicatectm.H>
#include <targeting/predicates/predicatepostfixexpr.H>

class HWAS1test: public CxxTest::TestSuite
{
public:

    /**
     *  @brief Walk all the targets and verify that HWAS_STATE is set
     *      correctly.
     *
     *  @note  Results of this test will change as more stuff gets added to
     *  HWAS - how to fix?
     */
    void testHWASdefaultPresence()
    {

        nanosleep(1,0);
        TS_TRACE(ENTER_MRK "testHWASdefaultPresence" );

        using namespace TARGETING;

        TargetService& l_targetService = targetService();

        l_targetService.init();


        // get top level
        // Post init
        // Test: void getTopLevelTarget(Target*& o_targetHandle) const;

        Target* l_pTopLevel = NULL;
        (void) l_targetService.getTopLevelTarget(l_pTopLevel);
        if (l_pTopLevel == NULL)
        {
            TS_FAIL("Top level handle was NULL when initialization complete");
        }

        // Post init
        // Test: void getAssociated(
        // const Target*           i_pTarget,
        //      ASSOCIATION_TYPE  i_type,
        //      RECURSION_LEVEL   i_recursionLevel,
        //      TargetHandleList& o_list) const;

        TargetHandleList l_list;
        (void) l_targetService.getAssociated(
                l_list,
                l_pTopLevel,
                TARGETING::TargetService::CHILD,
                TARGETING::TargetService::ALL);

        TS_TRACE("Child list size is 0x%x", l_list.size() );
        for (uint64_t i=0; i<l_list.size(); i++ )
        {
            //  2011-10-19  all attribute fields should be 0 at this point.
            if (    ( l_list[i]->getAttr<ATTR_HWAS_STATE>().poweredOn)
                 || ( l_list[i]->getAttr<ATTR_HWAS_STATE>().present)
                 || ( l_list[i]->getAttr<ATTR_HWAS_STATE>().functional)
                 || ( l_list[i]->getAttr<ATTR_HWAS_STATE>().changedSinceLastIPL)
                 || ( l_list[i]->getAttr<ATTR_HWAS_STATE>().gardLevel)
            )
            {
                l_list[i]->getAttr<ATTR_PHYS_PATH>().dump();
                TS_TRACE( " poweredOn = 0x%x",
                        l_list[i]->getAttr<ATTR_HWAS_STATE>().poweredOn );
                TS_TRACE( " present   = 0x%x",
                        l_list[i]->getAttr<ATTR_HWAS_STATE>().present   );
                TS_TRACE( " l_functional = 0x%x",
                        l_list[i]->getAttr<ATTR_HWAS_STATE>().functional );
                TS_TRACE( " l_changedSinceLastIPL = 0x%x",
                        l_list[i]->getAttr<ATTR_HWAS_STATE>().changedSinceLastIPL );
                TS_TRACE( " l_gardLevel = 0x%x",
                        l_list[i]->getAttr<ATTR_HWAS_STATE>().gardLevel );

                TS_FAIL( "Attribute fields not correct: ");
            }
        }

        TS_TRACE(EXIT_MRK "testHWASdefaultPresence" );
    }

};

#endif //
OpenPOWER on IntegriCloud