6
6
// / @endcond
7
7
// /
8
8
9
- #define QP_IMPL // this is QP implementation
10
- #include " qp_port.hpp" // QF port
11
- #include " qp_pkg.hpp" // QF package-scope interface
12
- #include " qsafe.h" // QP embedded systems-friendly assertions
13
- #ifdef Q_SPY // QS software tracing enabled?
9
+ #define QP_IMPL // this is QP implementation
10
+ #include " qp_port.hpp" // QF port
11
+ #include " qp_pkg.hpp" // QF package-scope interface
12
+ #include " qsafe.h" // QP embedded systems-friendly assertions
13
+ #ifdef Q_SPY // QS software tracing enabled?
14
14
#error "Q_SPY not supported in the cpputest port"
15
15
#else
16
16
#include " qs_dummy.hpp" // disable the QS software tracing
@@ -39,25 +39,42 @@ int_t QF::run()
39
39
}
40
40
#endif
41
41
42
+ /* *
43
+ * Fake cpputest event loop for QActive. Only loops
44
+ * until queue is empty, then removes it from the
45
+ * ready set.
46
+ * @param act an active object to run an event loop upon.
47
+ */
48
+ void QActive::evtLoop_ (QActive* act)
49
+ {
50
+ while (!act->m_eQueue .isEmpty ()) {
51
+ QEvt const * e = act->get_ ();
52
+ act->dispatch (e, act->m_prio );
53
+ QF::gc (e);
54
+ }
55
+
56
+ if (act->m_eQueue .isEmpty ()) {
57
+ cpputest_readySet_.remove (act->m_prio );
58
+ }
59
+ }
60
+
42
61
void RunUntilNoReadyActiveObjects ()
43
62
{
44
63
while (cpputest_readySet_.notEmpty ()) {
45
64
std::uint_fast8_t p = cpputest_readySet_.findMax ();
65
+ #if QP_VERSION > 800
66
+ QActive* a = QP::QActive::fromRegistry (p);
67
+ #elif QP_VERSION > 700
46
68
QActive* a = QP::QActive::registry_[p];
69
+ #else
70
+ #error "unsupported QP version"
71
+ #endif
47
72
48
73
// the active object 'a' must still be registered in QF
49
74
// (e.g., it must not be stopped)
50
75
Q_ASSERT_ID (320 , a != nullptr );
51
76
52
- while (!a->getEQueue ().isEmpty ()) {
53
- const auto e = a->get_ ();
54
- a->dispatch (e, 0 );
55
- QF::gc (e);
56
- }
57
-
58
- if (a->getEQueue ().isEmpty ()) { /* empty queue? */
59
- cpputest_readySet_.remove (p);
60
- }
77
+ QActive::evtLoop_ (a);
61
78
}
62
79
}
63
80
@@ -68,23 +85,22 @@ void QF::stop()
68
85
}
69
86
70
87
// ****************************************************************************
71
- void QActive::start ( QPrioSpec const prioSpec,
72
- QEvt const * * const qSto, std::uint_fast16_t const qLen,
73
- void * const stkSto, std::uint_fast16_t const stkSize,
74
- void const * const par)
88
+ void QActive::start (QPrioSpec const prioSpec, QEvt const ** const qSto,
89
+ std::uint_fast16_t const qLen, void * const stkSto,
90
+ std::uint_fast16_t const stkSize, void const * const par)
75
91
{
76
92
// unused parameters in the cpputest port
77
93
Q_UNUSED_PAR (stkSto);
78
94
Q_UNUSED_PAR (stkSize);
79
95
80
- m_prio = static_cast <std::uint8_t >(prioSpec & 0xFFU ); // QF-priority
81
- m_pthre = static_cast <std::uint8_t >(prioSpec >> 8U ); // preemption-thre.
82
- register_ (); // make QF aware of this AO
96
+ m_prio = static_cast <std::uint8_t >(prioSpec & 0xFFU ); // QF-priority
97
+ m_pthre = static_cast <std::uint8_t >(prioSpec >> 8U ); // preemption-thre.
98
+ register_ (); // make QF aware of this AO
83
99
84
100
m_eQueue.init (qSto, qLen);
85
101
86
- this ->init (par, m_prio); // execute initial transition (virtual call)
87
- QS_FLUSH (); // flush the QS trace buffer to the host
102
+ this ->init (par, m_prio); // execute initial transition (virtual call)
103
+ QS_FLUSH (); // flush the QS trace buffer to the host
88
104
}
89
105
90
106
// ............................................................................
0 commit comments