Skip to content

Commit f07091e

Browse files
nattgrishefloryd
authored andcommitted
Fix error behaviour tests
Use an EMCY code that is mandatory to trigger the error behaviour. Check that another EMCY code does not trigger the behaviour. Also check the 1029h=1 setting where the current NMT state should be kept. Remove the test that uses an invalid NMT state. Change-Id: Iffeec6f0b7c1cab98bf5a05f139c6abf333ac850
1 parent bcee891 commit f07091e

File tree

1 file changed

+43
-14
lines changed

1 file changed

+43
-14
lines changed

test/test_emcy.cpp

Lines changed: 43 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -207,26 +207,51 @@ TEST_F (EmcyTest, NMTErrorBehavior)
207207
EXPECT_EQ (0u, result);
208208
EXPECT_EQ (0u, value);
209209

210-
co_emcy_tx (&net, 1, 0x1234, msef);
210+
co_emcy_tx (&net, 0x8130, 0x1234, msef);
211211
EXPECT_EQ (STATE_INIT, net.state);
212212

213-
net.state = STATE_LAST;
214-
co_emcy_tx (&net, 1, 0x1234, msef);
215-
EXPECT_EQ (STATE_LAST, net.state);
216-
217213
net.state = STATE_OFF;
218-
co_emcy_tx (&net, 1, 0x1234, msef);
214+
co_emcy_tx (&net, 0x8130, 0x1234, msef);
219215
EXPECT_EQ (STATE_OFF, net.state);
220216

221217
net.state = STATE_STOP;
222-
co_emcy_tx (&net, 1, 0x1234, msef);
218+
co_emcy_tx (&net, 0x8130, 0x1234, msef);
223219
EXPECT_EQ (STATE_STOP, net.state);
224220

225221
net.state = STATE_OP;
226-
co_emcy_tx (&net, 1, 0x1234, msef);
222+
co_emcy_tx (&net, 0x8130, 0x1234, msef);
223+
EXPECT_EQ (STATE_PREOP, net.state);
224+
225+
co_emcy_tx (&net, 0x8130, 0x1234, msef);
227226
EXPECT_EQ (STATE_PREOP, net.state);
228227

228+
net.state = STATE_OP;
229229
co_emcy_tx (&net, 1, 0x1234, msef);
230+
EXPECT_EQ (STATE_OP, net.state);
231+
232+
value = 1;
233+
result = co_od1029_fn (&net, OD_EVENT_WRITE, obj1029, NULL, 1, &value);
234+
EXPECT_EQ (0u, result);
235+
EXPECT_EQ (1, net.error_behavior);
236+
237+
net.state = STATE_INIT;
238+
co_emcy_tx (&net, 0x8130, 0x1234, msef);
239+
EXPECT_EQ (STATE_INIT, net.state);
240+
241+
net.state = STATE_OFF;
242+
co_emcy_tx (&net, 0x8130, 0x1234, msef);
243+
EXPECT_EQ (STATE_OFF, net.state);
244+
245+
net.state = STATE_STOP;
246+
co_emcy_tx (&net, 0x8130, 0x1234, msef);
247+
EXPECT_EQ (STATE_STOP, net.state);
248+
249+
net.state = STATE_OP;
250+
co_emcy_tx (&net, 0x8130, 0x1234, msef);
251+
EXPECT_EQ (STATE_OP, net.state);
252+
253+
net.state = STATE_PREOP;
254+
co_emcy_tx (&net, 0x8130, 0x1234, msef);
230255
EXPECT_EQ (STATE_PREOP, net.state);
231256

232257
value = 2;
@@ -235,27 +260,31 @@ TEST_F (EmcyTest, NMTErrorBehavior)
235260
EXPECT_EQ (2, net.error_behavior);
236261

237262
net.state = STATE_INIT;
238-
co_emcy_tx (&net, 1, 0x1234, msef);
263+
co_emcy_tx (&net, 0x8130, 0x1234, msef);
239264
EXPECT_EQ (STATE_INIT, net.state);
240265

241266
net.state = STATE_OFF;
242-
co_emcy_tx (&net, 1, 0x1234, msef);
267+
co_emcy_tx (&net, 0x8130, 0x1234, msef);
243268
EXPECT_EQ (STATE_OFF, net.state);
244269

245270
net.state = STATE_STOP;
246-
co_emcy_tx (&net, 1, 0x1234, msef);
271+
co_emcy_tx (&net, 0x8130, 0x1234, msef);
247272
EXPECT_EQ (STATE_STOP, net.state);
248273

249274
net.state = STATE_OP;
250-
co_emcy_tx (&net, 1, 0x1234, msef);
275+
co_emcy_tx (&net, 0x8130, 0x1234, msef);
251276
EXPECT_EQ (STATE_STOP, net.state);
252277

253278
net.state = STATE_PREOP;
254-
co_emcy_tx (&net, 1, 0x1234, msef);
279+
co_emcy_tx (&net, 0x8130, 0x1234, msef);
255280
EXPECT_EQ (STATE_STOP, net.state);
256281

257-
co_emcy_tx (&net, 1, 0x1234, msef);
282+
co_emcy_tx (&net, 0x8130, 0x1234, msef);
258283
EXPECT_EQ (STATE_STOP, net.state);
284+
285+
net.state = STATE_OP;
286+
co_emcy_tx (&net, 1, 0x1234, msef);
287+
EXPECT_EQ (STATE_OP, net.state);
259288
}
260289

261290
TEST_F (EmcyTest, EmcyOverrun)

0 commit comments

Comments
 (0)