@@ -30,12 +30,8 @@ class MockPRUInterface : public PruHardwareInterface {
30
30
public:
31
31
MockPRUInterface () : execution_index_(QUEUE_LEN - 1 ) {
32
32
mmap = NULL ;
33
- ON_CALL (*this , Init).WillByDefault ([]() {
34
- return true ;
35
- });
36
- ON_CALL (*this , Shutdown).WillByDefault ([]() {
37
- return true ;
38
- });
33
+ ON_CALL (*this , Init).WillByDefault ([]() { return true ; });
34
+ ON_CALL (*this , Shutdown).WillByDefault ([]() { return true ; });
39
35
}
40
36
~MockPRUInterface () override { free (mmap); }
41
37
@@ -45,6 +41,7 @@ class MockPRUInterface : public PruHardwareInterface {
45
41
MOCK_METHOD (bool , Shutdown, (), ());
46
42
47
43
bool AllocateSharedMem (void **pru_mmap, const size_t size) final {
44
+ if (mmap != NULL ) return true ;
48
45
mmap = (struct MockPRUCommunication *)malloc (size);
49
46
*pru_mmap = (void *)mmap;
50
47
memset (*pru_mmap, 0x00 , size);
@@ -141,9 +138,8 @@ TEST(PruMotionQueue, one_round_queue) {
141
138
EXPECT_EQ (motion_backend.GetPendingElements (NULL ), QUEUE_LEN);
142
139
}
143
140
144
- // Check emergency reset shutsdowns the motors and
145
- // the PRU and sets to zero the whole queue.
146
- TEST (PruMotionQueue, emergency_stop) {
141
+ // Check the PRU is reset and no elements are pending.
142
+ TEST (PruMotionQueue, clear_queue) {
147
143
MotorsRegister absolute_pos_loops;
148
144
NiceMock<MockPRUInterface> pru_interface;
149
145
HardwareMapping hmap = HardwareMapping ();
@@ -164,11 +160,9 @@ TEST(PruMotionQueue, emergency_stop) {
164
160
EXPECT_CALL (pru_interface, Shutdown ())
165
161
.Times (1 )
166
162
.WillRepeatedly (testing::Return (true ));
167
- EXPECT_CALL (pru_interface, Init ())
168
- .Times (1 )
169
- .WillOnce (testing::Return (true ));
163
+ EXPECT_CALL (pru_interface, Init ()).Times (1 ).WillOnce (testing::Return (true ));
170
164
}
171
- EXPECT_TRUE (motion_backend.EmergencyReset ());
165
+ EXPECT_TRUE (motion_backend.Clear ());
172
166
EXPECT_EQ (motion_backend.GetPendingElements (NULL ), 0 );
173
167
}
174
168
0 commit comments