aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xtest/afb-test.sh5
-rw-r--r--test/afb-test/tests/low-can_BasicAPITest.lua31
-rw-r--r--test/afb-test/tests/low-can_FilterTest01.lua47
3 files changed, 56 insertions, 27 deletions
diff --git a/test/afb-test.sh b/test/afb-test.sh
index eaebbe08..e60f2deb 100755
--- a/test/afb-test.sh
+++ b/test/afb-test.sh
@@ -21,6 +21,7 @@ ${BINDER} --name="${PROCNAME}" \
--workdir="${BUILDDIR}/package" \
--binding="lib/afb-low-can.so" \
--binding="$AFBTEST" \
+--call="afTest/launch_all_tests:{}" \
-vvv > ${LOGPIPE} 2>&1 &
while read -r line
@@ -28,4 +29,6 @@ do
[ "$(echo "${line}" | grep 'NOTICE: Browser URL=')" ] && break
done < ${LOGPIPE}
-${CLIENT} ws://localhost:${PORT}/api?token=${TOKEN} afTest launch_all_tests
+${CLIENT} ws://localhost:${PORT}/api?token=${TOKEN} afTest exit
+
+rm -f ${LOGPIPE}
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)
-
+]]