summaryrefslogtreecommitdiffstats
path: root/src/usr/diag/mdia/test/mdiafakesm.H
blob: 61947736ad98be09b1b87258c2213bec88987205 (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
/*  IBM_PROLOG_BEGIN_TAG
 *  This is an automatically generated prolog.
 *
 *  $Source: src/usr/diag/mdia/test/mdiafakesm.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_TAG
 */
#ifndef __TEST_MDIAFAKESM_H
#define __TEST_MDIAFAKESM_H

#include "../mdiasm.H"

namespace MDIA
{
/**
 * @brief FakeStateMachine1
 *
 * Used to test processing a maint command timeout
 * from the CommandMonitor perspective
 */
class FakeStateMachine1 : public StateMachine
{
    public:
        /**
         * @brief processCommandTimeout
         *
         * Verifies if the vector of monitorIDs(i_monitorIDs) passed in
         * is the expected vector of timed out monitorIDs(iv_monitors)
         *
         * @param[in] i_monitorIDs Vector of monitorIDs that have timed out
         */
        void processCommandTimeout(const std::vector<uint64_t> & i_monitorIDs);

        /**
         * @brief addMonitor
         *
         * Add a monitor to the vector of iv_monitors
         *
         * @param[in] i_mon Monitor ID of target
         */
        void addMonitor(uint64_t i_mon);

        /**
         * @brief removeMonitor
         *
         * Removes the monitor at position 'i_position' from iv_monitors
         *
         * @param[in] i_position Position of monitor ID in vector iv_monitors
         */
        void removeMonitor(const uint64_t i_position);

        /**
         * @brief isTimeoutProcessed
         *
         * Is the timeout processed
         *
         * @retval true if processed
         *         false is not processed
         */
        bool isTimeoutProcessed() const;

        /**
         * @brief isContentsEqual
         *
         * Are the contents of vector of monitorIDs sent from
         * CommandMonitor equal to the expected value
         *
         * @retval true if equal
         *         false if not equal
         */
        bool isContentsEqual() const;

        /**
         * @brief setTotalExpectedMons
         *
         * Sets the expected number of monitor IDs that timeout
         *
         * @param[in] i_count Total number of expected timeouts
         */
        void setTotalExpectedMons(const uint64_t i_count);

        /**
         * @brief setSyncVars
         *
         * Sets the sync variables to be in-sync with the unit test
         *
         * @param[in] i_mutex Serialization Mutex
         * @param[in] i_cond  Synchronization condition
         */
        void setSyncVars(mutex_t *i_mutex, sync_cond_t *i_cond);

        /**
         * @brief ctor
         */
        FakeStateMachine1();

        /**
         * @brief dtor
         */
        ~FakeStateMachine1(){}

    private:
        /**
         * @brief isEqual
         *
         * Compares two sets of vectors of monitorIDs
         *
         * @param[in] i_monitorIDs Vector of monitorIDs
         */
        bool isEqual(const std::vector<uint64_t> & i_monitorIDs) const;

        /**
         * @brief Processed timeout indicator
         */
        bool iv_processedTimeout;

        /**
         * @brief Contents of expected and real timeouts equality indicator
         */
        bool iv_contentsEqual;

        /**
         * @brief Vector of expected monitor IDs to timeout
         */
        std::vector<uint64_t> iv_expectedMonitors;

        /**
         * @brief Expected number to monitor IDs to timeout
         */
        uint64_t iv_totalExpectedMons;

        /**
         * @brief Processed timeout condition
         */
        sync_cond_t *iv_cond;

        /**
         * @brief serialization mutex
         */
        mutex_t *iv_mutex;
};
}
#endif
OpenPOWER on IntegriCloud