diff options
author | Romain Forlot <romain.forlot@iot.bzh> | 2018-07-19 14:09:59 +0200 |
---|---|---|
committer | Romain Forlot <romain.forlot@iot.bzh> | 2018-07-23 16:12:13 +0000 |
commit | 55673d50338f041763e6e38f38ea3fc311f2bdc1 (patch) | |
tree | 9187738d00354dd3d33f62f9f5114c7704a28d42 | |
parent | f80ab1e0739a5e8694537c4d44b5ab568fa235b4 (diff) |
Add simple tests about waiting a group of events.flounder_5.99.2flounder/5.99.25.99.2
Change-Id: I409f8a07806f613e74cf86d6d001f7762eab7f96
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
-rw-r--r-- | CMakeLists.txt | 8 | ||||
-rw-r--r-- | conf.d/controller/etc/aft-mapis.json | 3 | ||||
-rw-r--r-- | conf.d/controller/lua.d/mapi_low-can.lua | 8 | ||||
-rw-r--r-- | conf.d/controller/lua.d/mapi_tests.lua | 32 |
4 files changed, 26 insertions, 25 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 6f19ba5..c533f0e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,4 +18,12 @@ CMAKE_MINIMUM_REQUIRED(VERSION 3.7) +include(CTest) +enable_testing() + include(${CMAKE_CURRENT_SOURCE_DIR}/conf.d/cmake/config.cmake) + +ADD_TEST(NAME AFT_TESTS + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + COMMAND afb-test -v test +) diff --git a/conf.d/controller/etc/aft-mapis.json b/conf.d/controller/etc/aft-mapis.json index 4aeeb74..c61aaba 100644 --- a/conf.d/controller/etc/aft-mapis.json +++ b/conf.d/controller/etc/aft-mapis.json @@ -61,6 +61,9 @@ },{ "uid": "low-can/messages_engine_speed", "action": "lua://AFT#_evt_catcher_" + },{ + "uid": "low-can/messages_vehicle_speed", + "action": "lua://AFT#_evt_catcher_" }] }] } diff --git a/conf.d/controller/lua.d/mapi_low-can.lua b/conf.d/controller/lua.d/mapi_low-can.lua index f7cd99a..9909492 100644 --- a/conf.d/controller/lua.d/mapi_low-can.lua +++ b/conf.d/controller/lua.d/mapi_low-can.lua @@ -27,6 +27,14 @@ function _unsubscribe(source, args) end function _get(source, args) + local evtHandle1 = AFB:evtmake(source, 'messages_engine_speed') + local evtHandle2 = AFB:evtmake(source, 'messages_vehicle_speed') + if type(evtHandle1) == "userdata" and type(evtHandle2) == "userdata" then + AFB:subscribe(source, evtHandle1) + AFB:evtpush(source,evtHandle1,{value = 1234}) + AFB:subscribe(source, evtHandle2) + AFB:evtpush(source,evtHandle2,{value = 5678}) + end AFB:success(source) end diff --git a/conf.d/controller/lua.d/mapi_tests.lua b/conf.d/controller/lua.d/mapi_tests.lua index 1111a2d..abd65cb 100644 --- a/conf.d/controller/lua.d/mapi_tests.lua +++ b/conf.d/controller/lua.d/mapi_tests.lua @@ -21,31 +21,13 @@ _AFT.testVerbStatusSuccess("TestListverb", "low-can", "list", {}) _AFT.testVerbStatusSuccess("TestGetVerb", "low-can", "get", { event = "engine.speed"}) -_AFT.testCustom("Test_detection_is_off", function() - local logMsg = "signal: Engine is off, diagnostic_messages.engine.speed won't received responses until it's on" - _AFT.addLogToMonitor("low-can", "warning", logMsg) +_AFT.describe("Test_turning_on", function() + local evt1 = "low-can/messages_engine_speed" + local evt2 = "low-can/messages_vehicle_speed" + _AFT.addEventToMonitor(evt1) + _AFT.addEventToMonitor(evt2) - _AFT.assertVerbStatusSuccess("low-can","subscribe", { event = "diagnostic_messages.engine.speed" }) - _AFT.assertLogReceived(logMsg) - _AFT.assertVerbStatusSuccess("low-can","unsubscribe", { event = "diagnostic_messages.engine.speed" }) -end) - -_AFT.testCustom("Test_turning_on", function() - _AFT.assertVerbStatusSuccess("low-can","subscribe", { event = "diagnostic_messages.engine.speed" }) - - local evt = "low-can/diagnostic_messages" - local logMsg = "signal: Engine is off, diagnostic_messages.engine.speed won't received responses until it's on" - _AFT.addLogToMonitor("low-can", "warning", logMsg) - _AFT.addEventToMonitor(evt) - - local ret = os.execute("./var/replay_launcher.sh ./var/test1.canreplay") - _AFT.assertIsTrue(ret) - - _AFT.assertEvtReceived(evt, function(eventName, data) - _AFT.assertIsTrue(data.name == "diagnostic_messages.engine.speed") - end) - - _AFT.assertLogNotReceived(logMsg) + _AFT.assertVerb("low-can", "get", {}) - _AFT.assertVerbStatusSuccess("low-can","unsubscribe", { event = "diagnostic_messages.engine.speed" }) + _AFT.assertEvtGrpReceived({evt1, evt2}) end) |