summaryrefslogtreecommitdiffstats
path: root/test/afb-test
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2018-07-27 20:02:56 +0200
committerRomain Forlot <romain.forlot@iot.bzh>2018-07-28 02:31:40 +0200
commit88281216540f5f61bcee7076259a25573c1cb50e (patch)
treee5ee4ee963de23972aca9e45b4bad7e905721bfe /test/afb-test
parentab1adbd3a5d69dced58ef2a37d5defea600452e9 (diff)
Several tests improvements and fixes
- New tests about authenticate and write on CAN bus. - Fixes diagnostic messages handling, all diagnostic messages are received through the same handle then in its data there is the detailled message name. - Set after and before method the same between the both file then they could be played separately. About now setting multiple times those methods will override them and the latest set wins - Disable the Step3 for now because of segfault - Fix unsubscribe argument to match the previous subscription else it doesn't match and verb call fails - Fix: typo,wrong variable Change-Id: I2f4c2873e57611c946a99d4313021bb7bfea679c Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'test/afb-test')
-rw-r--r--test/afb-test/tests/low-can_BasicAPITest.lua31
-rw-r--r--test/afb-test/tests/low-can_FilterTest01.lua47
2 files changed, 52 insertions, 26 deletions
diff --git a/test/afb-test/tests/low-can_BasicAPITest.lua b/test/afb-test/tests/low-can_BasicAPITest.lua
index 5dddb55e..bda5bf0e 100644
--- a/test/afb-test/tests/low-can_BasicAPITest.lua
+++ b/test/afb-test/tests/low-can_BasicAPITest.lua
@@ -33,35 +33,46 @@ _AFT.setAfterEach(function()
os.execute("pkill linuxcan-canpla")
end)
+_AFT.setAfterAll( function()
+ os.execute("pkill canplayer")
+ os.execute("pkill linuxcan-canpla")
+ return 0
+end)
+
+_AFT.testVerbStatusError("low-can_write_wo_auth", "low-can", "write", { signal_name = "engine.speed", signal_value = 1234})
+_AFT.testVerbStatusSuccess("low-can_auth", "low-can", "auth", {})
+_AFT.testVerbStatusError("low-can_write_unwritable_signal", "low-can", "write", { signal_name = "engine.speed", signal_value = 1234})
+_AFT.testVerbStatusSuccess("low-can_write", "low-can", "write", { signal_name = "hvac.temperature.left", signal_value = 21})
+_AFT.testVerbStatusSuccess("low-can_write_raw", "low-can", "write", { bus_name= "hs", frame= { can_id= 1568, can_dlc=8, can_data= {255,255,255,255,255,255,255,255}}})
+
_AFT.testVerbStatusSuccess("low-can_list", "low-can", "list", {})
_AFT.testVerbStatusSuccess("low-can_get", "low-can", "get", { event = "engine.speed"})
_AFT.describe("Diagnostic_engine_speed_simulation", function()
-
+
local api = "low-can"
local evt = "diagnostic_messages.engine.speed"
_AFT.assertVerbStatusSuccess(api,"subscribe", { event = evt })
- _AFT.addEventToMonitor(api .. "/" .. evt ,function(eventName, data)
- _AFT.assertIsTrue(data.name == "diagnostic_messages.engine.speed")
+ _AFT.addEventToMonitor(api .."/diagnostic_messages", function(eventName, data)
+ _AFT.assertIsTrue(data.name == "diagnostic_messages.engine.speed")
end)
local ret = os.execute("./var/replay_launcher.sh ./var/test1.canreplay")
_AFT.assertIsTrue(ret)
- _AFT.assertEvtReceived(api .. "/" .. evt, 1000000)
+ _AFT.assertEvtReceived(api .."/diagnostic_messages", 1000000)
- _AFT.assertVerbStatusSuccess("low-can","unsubscribe", { event = "diagnostic_messages.engine.speed" })
+ _AFT.assertVerbStatusSuccess("low-can","unsubscribe", { event = evt })
end)
_AFT.describe("Subscribe_all", function()
local api = "low-can"
- local evt = "messages.vehicle.average.speed"
+ local evt = "messages.vehicle.average.speed"
-
- _AFT.addEventToMonitor(api .. "/" .. evt, function(eventName, data)
- _AFT.assertEquals(data.name,"messages.vehicle.average.speed")
+ _AFT.addEventToMonitor(api .."/".. evt, function(eventName, data)
+ _AFT.assertEquals(eventName, api .."/".. evt)
end)
_AFT.assertVerbStatusSuccess(api,"subscribe", { event = "*" })
@@ -69,7 +80,7 @@ _AFT.describe("Subscribe_all", function()
local ret = os.execute("./var/replay_launcher.sh ./var/test2-3.canreplay")
_AFT.assertIsTrue(ret)
- _AFT.assertEvtReceived(api .. "/" .. evt, 5000000);
+ _AFT.assertEvtReceived(api .."/".. evt, 5000000);
_AFT.assertVerbStatusSuccess(api,"unsubscribe", { event = "*" })
diff --git a/test/afb-test/tests/low-can_FilterTest01.lua b/test/afb-test/tests/low-can_FilterTest01.lua
index 888b44d4..10e870e2 100644
--- a/test/afb-test/tests/low-can_FilterTest01.lua
+++ b/test/afb-test/tests/low-can_FilterTest01.lua
@@ -18,9 +18,24 @@
NOTE: strict mode: every global variables should be prefixed by '_'
--]]
-_AFT.setAfterEach( function()
+_AFT.setBeforeAll(function()
+ local can = io.open("/sys/class/net/can0")
+ if can == nil then
+ print("# You do not have 'can0' device set. Please run the following command:\n### sudo modprobe vcan; sudo ip link add can0 type vcan; sudo ip link set can0 up ")
+ return -1
+ end
+ return 0
+end)
+
+_AFT.setAfterEach(function()
+ os.execute("pkill canplayer")
+ os.execute("pkill linuxcan-canpla")
+end)
+
+_AFT.setAfterAll( function()
os.execute("pkill canplayer")
os.execute("pkill linuxcan-canpla")
+ return 0
end)
_AFT.describe("Filter_Test_01/Step_1", function()
@@ -33,6 +48,7 @@ _AFT.describe("Filter_Test_01/Step_1", function()
_AFT.assertVerbStatusSuccess(api ,"subscribe", { event = evt, filter = { min = 30, max = 100}})
os.execute("./var/replay_launcher.sh ./var/testFilter01filteredOut.canreplay");
+
_AFT.assertEvtNotReceived(api .. "/" ..evt, 1000000)
end)
@@ -41,16 +57,17 @@ _AFT.describe("Filter_Test_01/Step_2", function()
local evt = "messages.engine.speed"
_AFT.addEventToMonitor(api .. "/" ..evt, function(eventname,data)
- _AFT.assertEquals(data.name,evt)
- _AFT.assertIsTrue(data.value > min and data.value < max )
+ _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("./var/replay_launcher.sh ./var/testFilter01pass.canreplay");
_AFT.assertEvtReceived(api .. "/" ..evt, 1000000)
- _AFT.assertVerbStatusSuccess(api,"unsubscribe", { event = evt })
+ _AFT.assertVerbStatusSuccess(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"
@@ -58,19 +75,17 @@ _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)
- local first = dataH[1];
- local second = dataH[2];
-
- _AFT.assertEquals(first.name,evt)
- _AFT.assertIsTrue(first.value > 30 and first.value < 100 )
- _AFT.assertEquals(second.name,evt)
- _AFT.assertIsTrue(second.value > 30 and second.value < 100 )
- assertIsTrue(second.timestamp-first.timestamp > 1000000000) --This is in nano-seconds as it fetchs the low-can timestamp from the data field
+ _AFT.assertEquals(dataH[1].name,evt)
+ _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
end)
+
_AFT.assertVerbStatusSuccess(api ,"subscribe", { event = evt, filter = { frequency = 1 , min = 30, max = 100}})
os.execute("./var/replay_launcher.sh ./var/testFilter01pass.canreplay");
- _AFT.assertEvtGrpReceived({api .. "/" ..evt,api .. "/" ..evt}, 10000000)
- _AFT.assertVerbStatusSuccess(api,"unsubscribe", { event = evt })
+ _AFT.assertEvtGrpReceived({[api .."/"..evt]= 2}, 5000000)
+ _AFT.assertVerbStatusSuccess(api,"unsubscribe", { event = evt, filter = { frequency = 1 , min = 30, max = 100}})
end)
-
+]]