3 Copyright (C) 2018 "IoT.bzh"
4 Author Romain Forlot <romain.forlot@iot.bzh>
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
10 http://www.apache.org/licenses/LICENSE-2.0
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 See the License for the specific language governing permissions and
16 limitations under the License.
19 NOTE: strict mode: every global variables should be prefixed by '_'
22 _AFT.setBeforeAll(function()
23 local can = io.open("/sys/class/net/can0")
25 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 ")
31 _AFT.setAfterEach(function()
32 os.execute("pkill canplayer")
33 os.execute("pkill linuxcan-canpla")
36 _AFT.setAfterAll( function()
37 os.execute("pkill canplayer")
38 os.execute("pkill linuxcan-canpla")
42 _AFT.testVerbStatusError("low-can_write_wo_auth", "low-can", "write", { signal_name = "engine.speed", signal_value = 1234})
43 _AFT.testVerbStatusSuccess("low-can_auth", "low-can", "auth", {})
44 _AFT.testVerbStatusError("low-can_write_unwritable_signal", "low-can", "write", { signal_name = "engine.speed", signal_value = 1234})
45 _AFT.testVerbStatusSuccess("low-can_write", "low-can", "write", { signal_name = "hvac.temperature.left", signal_value = 21})
46 _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}}})
48 _AFT.testVerbStatusSuccess("low-can_list", "low-can", "list", {})
49 _AFT.testVerbStatusSuccess("low-can_get", "low-can", "get", { event = "engine.speed"})
51 _AFT.describe("Diagnostic_engine_speed_simulation", function()
54 local evt = "diagnostic_messages.engine.speed"
55 _AFT.assertVerbStatusSuccess(api,"subscribe", { event = evt })
57 _AFT.addEventToMonitor(api .."/diagnostic_messages", function(eventName, data)
58 _AFT.assertIsTrue(data.name == "diagnostic_messages.engine.speed")
61 local ret = os.execute("./var/replay_launcher.sh ./var/test1.canreplay")
62 _AFT.assertIsTrue(ret)
64 _AFT.assertEvtReceived(api .."/diagnostic_messages", 1000000)
66 _AFT.assertVerbStatusSuccess("low-can","unsubscribe", { event = evt })
70 _AFT.describe("Subscribe_all", function()
72 local evt = "messages.vehicle.average.speed"
74 _AFT.addEventToMonitor(api .."/".. evt, function(eventName, data)
75 _AFT.assertEquals(eventName, api .."/".. evt)
78 _AFT.assertVerbStatusSuccess(api,"subscribe", { event = "*" })
80 local ret = os.execute("./var/replay_launcher.sh ./var/test2-3.canreplay")
81 _AFT.assertIsTrue(ret)
83 _AFT.assertEvtReceived(api .."/".. evt, 5000000);
85 _AFT.assertVerbStatusSuccess(api,"unsubscribe", { event = "*" })