summaryrefslogtreecommitdiffstats
path: root/test/afb-test/tests
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2018-11-29 19:00:02 +0100
committerRomain Forlot <romain.forlot@iot.bzh>2018-12-14 08:59:47 +0000
commit9cef9811c615df506807f405eb2de3c1a9268fba (patch)
tree159bb138034f2dfefe4e356b5590815e054e7727 /test/afb-test/tests
parentff089ab8b009c81bcf92abf181faa00348eb62cd (diff)
Filter tests improvements
- Unsubscribe using the tear down feature instead of invoking it inside a test which could not be called if a previous assertion failed. - Always use the same event so make the 'api' and 'evt' variables at file scope. - Asserting the bash script's return launcher execution Change-Id: I6be151d07f890aef053a5ada06216aac7941c165 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'test/afb-test/tests')
-rw-r--r--test/afb-test/tests/low-can_BasicAPITest.lua2
-rw-r--r--test/afb-test/tests/low-can_FilterTest01.lua45
2 files changed, 27 insertions, 20 deletions
diff --git a/test/afb-test/tests/low-can_BasicAPITest.lua b/test/afb-test/tests/low-can_BasicAPITest.lua
index c59b1a70..bebf057a 100644
--- a/test/afb-test/tests/low-can_BasicAPITest.lua
+++ b/test/afb-test/tests/low-can_BasicAPITest.lua
@@ -66,7 +66,7 @@ _AFT.describe("Diagnostic_engine_speed_simulation", function()
_AFT.assertVerbStatusSuccess(api,"subscribe", { event = evt })
_AFT.addEventToMonitor(api .."/diagnostic_messages", function(eventName, data)
- _AFT.assertIsTrue(data.name == "diagnostic_messages.engine.speed")
+ _AFT.assertIsTrue(data.name == evt)
end)
local ret = os.execute("bash ".._AFT.bindingRootDir.."/var/replay_launcher.sh ".._AFT.bindingRootDir.."/var/test1.canreplay")
diff --git a/test/afb-test/tests/low-can_FilterTest01.lua b/test/afb-test/tests/low-can_FilterTest01.lua
index fac56950..32e3c288 100644
--- a/test/afb-test/tests/low-can_FilterTest01.lua
+++ b/test/afb-test/tests/low-can_FilterTest01.lua
@@ -18,6 +18,9 @@
NOTE: strict mode: every global variables should be prefixed by '_'
--]]
+local api = "low-can"
+local evt = "messages.engine.speed"
+
_AFT.setBeforeAll(function()
local can = io.open("/sys/class/net/can0")
if can == nil then
@@ -39,39 +42,39 @@ _AFT.setAfterAll( function()
end)
_AFT.describe("Filter_Test_01/Step_1", function()
- local api = "low-can"
- local evt = "engine.speed"
-
_AFT.addEventToMonitor(api .. "/" ..evt, function(eventname,data)
_AFT.assertEquals(data.name,evt)
end)
_AFT.assertVerbStatusSuccess(api ,"subscribe", { event = evt, filter = { min = 30, max = 100}})
- os.execute("bash ".._AFT.bindingRootDir.."/var/replay_launcher.sh ".._AFT.bindingRootDir.."/var/testFilter01filteredOut.canreplay");
+ local ret = os.execute("bash ".._AFT.bindingRootDir.."/var/replay_launcher.sh ".._AFT.bindingRootDir.."/var/testFilter01filteredOut.canreplay");
+ _AFT.assertIsTrue(ret)
_AFT.assertEvtNotReceived(api .. "/" ..evt, 1000000)
+end,
+nil,
+function()
+ _AFT.callVerb(api, "unsubscribe", { event = evt, filter = {min = 30, max = 100} })
end)
_AFT.describe("Filter_Test_01/Step_2", function()
- local api = "low-can"
- local evt = "messages.engine.speed"
-
_AFT.addEventToMonitor(api .. "/" ..evt, function(eventname,data)
_AFT.assertEquals(eventname, api.."/"..evt)
_AFT.assertIsTrue(data.value > 30 and data.value < 100)
end)
_AFT.assertVerbStatusSuccess(api ,"subscribe", { event = evt, filter = {min = 30, max = 100}})
- os.execute("bash ".._AFT.bindingRootDir.."/var/replay_launcher.sh ".._AFT.bindingRootDir.."/var/testFilter01pass.canreplay");
+ local ret = os.execute("bash ".._AFT.bindingRootDir.."/var/replay_launcher.sh ".._AFT.bindingRootDir.."/var/testFilter01pass.canreplay");
+ _AFT.assertIsTrue(ret)
_AFT.assertEvtReceived(api .. "/" ..evt, 1000000)
- _AFT.assertVerbStatusSuccess(api,"unsubscribe", { event = evt, filter = {min = 30, max = 100} })
+end,
+nil,
+function()
+ _AFT.callVerb(api, "unsubscribe", { event = evt, filter = {min = 30, max = 100} })
end)
---[[
-_AFT.describe("Filter_Test_01/Step_3", function()
- local api = "low-can"
- local evt = "messages.engine.speed"
+_AFT.describe("Filter_Test_01/Step_3", function()
_AFT.enableEventHistory() -- You will need this to check for time intervals between two events
_AFT.addEventToMonitor(api .. "/" ..evt, function(eventname,data,dataH)
@@ -79,13 +82,17 @@ _AFT.describe("Filter_Test_01/Step_3", function()
_AFT.assertIsTrue(dataH[1].value > 30 and dataH[1].value < 100 )
_AFT.assertEquals(dataH[2].name,evt)
_AFT.assertIsTrue(dataH[2].value > 30 and dataH[2].value < 100 )
- _AFT.assertIsTrue(dataH[2].timestamp-dataH[1].timestamp > 1000000000) --This is in nano-seconds as it fetchs the low-can timestamp from the data field
+ _AFT.assertIsTrue(dataH[2].timestamp - dataH[1].timestamp >= 1000000)
end)
_AFT.assertVerbStatusSuccess(api ,"subscribe", { event = evt, filter = { frequency = 1 , min = 30, max = 100}})
- os.execute("bash ".._AFT.bindingRootDir.."/var/replay_launcher.sh ".._AFT.bindingRootDir.."/var/testFilter01pass.canreplay");
-
- _AFT.assertEvtGrpReceived({[api .."/"..evt]= 2}, 5000000)
- _AFT.assertVerbStatusSuccess(api,"unsubscribe", { event = evt, filter = { frequency = 1 , min = 30, max = 100}})
+ local ret = os.execute("bash ".._AFT.bindingRootDir.."/var/replay_launcher.sh ".._AFT.bindingRootDir.."/var/testFilter01pass.canreplay");
+ _AFT.assertIsTrue(ret)
+
+ _AFT.assertEvtGrpReceived({[api .."/"..evt]= 2}, 3000000)
+end,
+nil,
+function()
+ _AFT.callVerb(api, "unsubscribe", { event = evt, filter = { frequency = 1 , min = 30, max = 100}})
end)
-]]
+