diff options
author | Romain Forlot <romain.forlot@iot.bzh> | 2018-08-23 00:24:39 +0200 |
---|---|---|
committer | Romain Forlot <romain.forlot@iot.bzh> | 2018-08-23 00:27:02 +0200 |
commit | 0406deaa862dffb3527ae13198f1d0f858656c2e (patch) | |
tree | bc82b780a02bc04f8b68c9ed327164d215ef0ef3 /test | |
parent | 590e30f846481c125a62093a7472937ec30a780b (diff) |
Use separate test folder to hold test files
Also separate helloWorld example binding test from self aft tests
Change-Id: I5b7c48b38cc6629c3edc97d280d7f9228451b337
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'test')
-rw-r--r-- | test/CMakeLists.txt | 27 | ||||
-rwxr-xr-x | test/afb-test.sh | 40 | ||||
-rw-r--r-- | test/afb-test/CMakeLists.txt | 22 | ||||
-rw-r--r-- | test/afb-test/etc/CMakeLists.txt | 31 | ||||
-rw-r--r-- | test/afb-test/etc/aft-aftest-self.json | 69 | ||||
-rw-r--r-- | test/afb-test/fixtures/CMakeLists.txt | 31 | ||||
-rw-r--r-- | test/afb-test/fixtures/mapi_low-can.lua | 51 | ||||
-rw-r--r-- | test/afb-test/tests/CMakeLists.txt | 31 | ||||
-rw-r--r-- | test/afb-test/tests/aftTest.lua | 109 | ||||
-rw-r--r-- | test/afb-test/tests/helloworld.lua | 59 | ||||
-rw-r--r-- | test/afb-test/tests/mapi_tests.lua | 33 |
11 files changed, 503 insertions, 0 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 0000000..0c42261 --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,27 @@ +########################################################################### +# Copyright 2015 - 2018 IoT.bzh +# +# author: Romain Forlot <romain.forlot@iot.bzh> +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +########################################################################### + + +# Include any directory not starting with _ +# ----------------------------------------------------- +PROJECT_SUBDIRS_ADD(${PROJECT_SRC_DIR_PATTERN}) + +ADD_TEST(NAME AGL_SERVICE_CAN_LOW_LEVEL_TESTS + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + COMMAND afb-test.sh ${CMAKE_BINARY_DIR} +) diff --git a/test/afb-test.sh b/test/afb-test.sh new file mode 100755 index 0000000..d65795d --- /dev/null +++ b/test/afb-test.sh @@ -0,0 +1,40 @@ +#!/bin/sh -x + +trap cleanup SIGINT SIGTERM SIGABRT SIGHUP + +cleanup() { + rm -f $LOGPIPE + pkill $PROCNAME + exit 1 +} + +BINDER=$(command -v afb-daemon) +AFBTEST="$(pkg-config --variable libdir afb-test)/aft.so" +PROCNAME="aft-aftest" +PORT=1234 +TOKEN= +LOGPIPE="test.pipe" + +[ "$1" ] && BUILDDIR="$1" || exit 1 + +[ ! -p $LOGPIPE ] && mkfifo $LOGPIPE + +pkill $PROCNAME + +${BINDER} --name="${PROCNAME}" \ +--port="${PORT}" \ +--no-httpd \ +--tracereq=common \ +--token=${TOKEN} \ +--workdir="${BUILDDIR}/package-test" \ +--binding="$AFBTEST" \ +-vvv \ +--call="afTest/launch_all_tests:{}" \ +--call="afTest/exit:{}" > ${LOGPIPE} 2>&1 & + +while read -r line +do + [ "$(echo "${line}" | grep 'NOTICE: Browser URL=')" ] && break +done < ${LOGPIPE} + +rm -f ${LOGPIPE} diff --git a/test/afb-test/CMakeLists.txt b/test/afb-test/CMakeLists.txt new file mode 100644 index 0000000..742253c --- /dev/null +++ b/test/afb-test/CMakeLists.txt @@ -0,0 +1,22 @@ +########################################################################### +# Copyright 2015 - 2018 IoT.bzh +# +# author: Romain Forlot <romain.forlot@iot.bzh> +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +########################################################################### + + +# Include any directory not starting with _ +# ----------------------------------------------------- +PROJECT_SUBDIRS_ADD(${PROJECT_SRC_DIR_PATTERN}) diff --git a/test/afb-test/etc/CMakeLists.txt b/test/afb-test/etc/CMakeLists.txt new file mode 100644 index 0000000..cd4beb9 --- /dev/null +++ b/test/afb-test/etc/CMakeLists.txt @@ -0,0 +1,31 @@ +########################################################################### +# Copyright 2015 - 2018 IoT.bzh +# +# author: Romain Forlot <romain.forlot@iot.bzh> +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +########################################################################### + +################################################## +# Low-CAN test configuration files +################################################## +PROJECT_TARGET_ADD(afb-test-config) + + file(GLOB CONF_FILES "*.json") + + add_input_files("${CONF_FILES}") + + SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES + LABELS "TEST-CONFIG" + OUTPUT_NAME ${TARGET_NAME} + ) diff --git a/test/afb-test/etc/aft-aftest-self.json b/test/afb-test/etc/aft-aftest-self.json new file mode 100644 index 0000000..73389c5 --- /dev/null +++ b/test/afb-test/etc/aft-aftest-self.json @@ -0,0 +1,69 @@ +{ + "id": "http://iot.bzh/download/public/schema/json/ctl-schema.json#", + "$schema": "http://iot.bzh/download/public/schema/json/ctl-schema.json#", + "metadata": { + "uid": "Test", + "version": "1.0", + "api": "aft-aftest", + "info": "Binding made to test other bindings", + "require": [ + "low-can" + ] + }, + "testVerb": { + "uid": "launch_all_tests", + "info": "Launch all the tests", + "action": "lua://AFT#_launch_test", + "args": { + "trace": "low-can", + "files": [ "aftTest.lua", "mapis-tests.lua" ] + } + }, + "mapis": [{ + "uid": "low-can", + "info": "Faked low-can API", + "libs": "mapi_low-can.lua", + "verbs": [ + { + "uid": "subscribe", + "info": "Subscribe to CAN signals events", + "action": "lua://low-can#_subscribe" + }, + { + "uid": "unsubscribe", + "info": "Unsubscribe previously suscribed signals.", + "action": "lua://low-can#_unsubscribe" + }, + { + "uid": "get", + "info": "get a current value of CAN message", + "action": "lua://low-can#_get" + }, + { + "uid": "list", + "info": "get a supported CAN message list", + "action": "lua://low-can#_list" + }, + { + "uid": "auth", + "info": "Authenticate session to be raise Level Of Assurance.", + "action": "lua://low-can#_auth" + }, + { + "uid": "write", + "info": "Write a CAN messages to the CAN bus.", + "action": "lua://low-can#_write" + } + ], + "events": [{ + "uid": "low-can/diagnostic_messages", + "action": "lua://AFT#_evt_catcher_" + },{ + "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/test/afb-test/fixtures/CMakeLists.txt b/test/afb-test/fixtures/CMakeLists.txt new file mode 100644 index 0000000..c5a2915 --- /dev/null +++ b/test/afb-test/fixtures/CMakeLists.txt @@ -0,0 +1,31 @@ +########################################################################### +# Copyright 2015 - 2018 IoT.bzh +# +# author: Romain Forlot <romain.forlot@iot.bzh> +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +########################################################################### + + +################################################## +# Low-CAN Lua Scripts +################################################## +PROJECT_TARGET_ADD(fixture-files) + + file(GLOB LUA_FILES "*.lua") + add_input_files("${LUA_FILES}") + + SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES + LABELS "TEST-DATA" + OUTPUT_NAME ${TARGET_NAME} + ) diff --git a/test/afb-test/fixtures/mapi_low-can.lua b/test/afb-test/fixtures/mapi_low-can.lua new file mode 100644 index 0000000..9909492 --- /dev/null +++ b/test/afb-test/fixtures/mapi_low-can.lua @@ -0,0 +1,51 @@ +--[[ + Copyright (C) 2018 "IoT.bzh" + Author Romain Forlot <romain.forlot@iot.bzh> + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + + NOTE: strict mode: every global variables should be prefixed by '_' +--]] + +function _subscribe(source, args) + AFB:success(source) +end + +function _unsubscribe(source, args) + AFB:success(source) +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 + +function _list(source, args) + AFB:success(source) +end + +function _auth(source, args) + AFB:success(source) +end + +function _write(source, args) + AFB:success(source) +end diff --git a/test/afb-test/tests/CMakeLists.txt b/test/afb-test/tests/CMakeLists.txt new file mode 100644 index 0000000..1ca1019 --- /dev/null +++ b/test/afb-test/tests/CMakeLists.txt @@ -0,0 +1,31 @@ +########################################################################### +# Copyright 2015 - 2018 IoT.bzh +# +# author: Romain Forlot <romain.forlot@iot.bzh> +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +########################################################################### + + +################################################## +# Low-CAN Lua Scripts +################################################## +PROJECT_TARGET_ADD(test-files) + + file(GLOB LUA_FILES "*.lua") + add_input_files("${LUA_FILES}") + + SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES + LABELS "TEST-DATA" + OUTPUT_NAME ${TARGET_NAME} + ) diff --git a/test/afb-test/tests/aftTest.lua b/test/afb-test/tests/aftTest.lua new file mode 100644 index 0000000..0503ae3 --- /dev/null +++ b/test/afb-test/tests/aftTest.lua @@ -0,0 +1,109 @@ +--[[ + Copyright (C) 2018 "IoT.bzh" + Author Romain Forlot <romain.forlot@iot.bzh> + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + + NOTE: strict mode: every global variables should be prefixed by '_' +--]] + +_AFT.setBeforeEach(function() print("~~~~~ Begin Test ~~~~~") end) +_AFT.setAfterEach(function() print("~~~~~ End Test ~~~~~") end) + +_AFT.setBeforeAll(function() print("~~~~~~~~~~ BEGIN ALL TESTS ~~~~~~~~~~") return 0 end) +_AFT.setAfterAll(function() print("~~~~~~~~~~ END ALL TESTS ~~~~~~~~~~") return 0 end) + +_AFT.setBefore("testAssertNotEquals",function() print("~~~~~ Begin Test AssertNotEquals ~~~~~") end) +_AFT.setAfter("testAssertNotEquals",function() print("~~~~~ End Test AssertNotEquals ~~~~~") end) + + +local corout = coroutine.create( print ) + +_AFT.describe("testAssertEquals", function() _AFT.assertEquals(false, false) end,function() print("~~~~~ Begin Test Assert Equals ~~~~~") end,function() print("~~~~~ End Test Assert Equals ~~~~~") end) +_AFT.describe("testAssertNotEquals", function() _AFT.assertNotEquals(true,false) end) +_AFT.describe("testAssertItemsEquals", function() _AFT.assertItemsEquals({1,2,3},{3,1,2}) end) +_AFT.describe("testAssertAlmostEquals", function() _AFT.assertAlmostEquals(1.25 ,1.5,0.5) end) +_AFT.describe("testAssertNotAlmostEquals", function() _AFT.assertNotAlmostEquals(1.25,1.5,0.125) end) +_AFT.describe("testAssertEvalToTrue", function() _AFT.assertEvalToTrue(true) end) +_AFT.describe("testAssertEvalToFalse", function() _AFT.assertEvalToFalse(false) end) + +_AFT.describe("testAssertStrContains", function() _AFT.assertStrContains("Hello I'm a string","string") end) +_AFT.describe("testAssertStrContains", function() _AFT.assertStrContains("Hello I'm a second string","second",5) end) + +_AFT.describe("testAssertStrIContains", function() _AFT.assertStrIContains("Hello I'm another string","I'm") end) + +_AFT.describe("testAssertNotStrContains", function() _AFT.assertNotStrContains("Hello it's me again, the other string","banana") end) +_AFT.describe("testAssertNotStrContains", function() _AFT.assertNotStrContains("Hello it's me again, the other string","banana",8) end) + +_AFT.describe("testAssertNotStrIContains", function() _AFT.assertNotStrIContains("Hello it's not me this time !","trebuchet") end) + +_AFT.describe("testAssertStrMatches", function() _AFT.assertStrMatches("Automotive Grade Linux","Automotive Grade Linux") end) +_AFT.describe("testAssertStrMatches", function() _AFT.assertStrMatches("Automotive Grade Linux from IoT.bzh","Automotive Grade Linux",1,22) end) +_AFT.describe("testAssertError", function() _AFT.assertError(_AFT.assertEquals(true,true)) end) + +_AFT.describe("testAssertErrorMsgEquals", function() _AFT.assertErrorMsgEquals("attempt to call a nil value", + _AFT.assertStrMatches("test assertErrorMsgEquals","test",1,4)) end) +_AFT.describe("testAssertErrorMsgContains", function() _AFT.assertErrorMsgContains("attempt to call", + _AFT.assertStrMatches("test assertErrorMsgEquals","test",1,4)) end) +_AFT.describe("testAssertErrorMsgMatches", function() _AFT.assertErrorMsgMatches('attempt to call a nil value', + _AFT.assertStrMatches("test assertErrorMsgEquals","test",1,4)) end) + +_AFT.describe("testAssertIs", function() _AFT.assertIs('toto','to'..'to') end) +_AFT.describe("testAssertNotIs", function() _AFT.assertNotIs({1,2},{1,2}) end) + +_AFT.describe("testAssertIsNumber", function() _AFT.assertIsNumber(23) end) +_AFT.describe("testAssertIsString", function() _AFT.assertIsString("Lapin bihan") end) +_AFT.describe("testAssertIsTable", function() _AFT.assertIsTable({1,2,3,4}) end) +_AFT.describe("testAssertIsBoolean", function() _AFT.assertIsBoolean(true) end) +_AFT.describe("testAssertIsNil", function() _AFT.assertIsNil(nil) end) +_AFT.describe("testAssertIsTrue", function() _AFT.assertIsTrue(true) end) +_AFT.describe("testAssertIsFalse", function() _AFT.assertIsFalse(false) end) +_AFT.describe("testAssertIsNaN", function() _AFT.assertIsNaN(0/0) end) +_AFT.describe("testAssertIsInf", function() _AFT.assertIsInf(1/0) end) +_AFT.describe("testAssertIsPlusInf", function() _AFT.assertIsPlusInf(1/0) end) +_AFT.describe("testAssertIsMinusInf", function() _AFT.assertIsMinusInf(-1/0) end) +_AFT.describe("testAssertIsPlusZero", function() _AFT.assertIsPlusZero(1/(1/0)) end) +_AFT.describe("testAssertIsMinusZero", function() _AFT.assertIsMinusZero(-1/(1/0)) end) +_AFT.describe("testAssertIsFunction", function() _AFT.assertIsFunction(print) end) +_AFT.describe("testAssertIsThread", function() _AFT.assertIsThread(corout) end) +_AFT.describe("testAssertIsUserdata", function() _AFT.assertIsUserdata(_AFT.context) end) + +_AFT.describe("testAssertNotIsNumber", function() _AFT.assertNotIsNumber('a') end) +_AFT.describe("testAssertNotIsString", function() _AFT.assertNotIsString(2) end) +_AFT.describe("testAssertNotIsTable", function() _AFT.assertNotIsTable(2) end) +_AFT.describe("testAssertNotIsBoolean", function() _AFT.assertNotIsBoolean(2) end) +_AFT.describe("testAssertNotIsNil", function() _AFT.assertNotIsNil(2) end) +_AFT.describe("testAssertNotIsTrue", function() _AFT.assertNotIsTrue(false) end) +_AFT.describe("testAssertNotIsFalse", function() _AFT.assertNotIsFalse(true) end) +_AFT.describe("testAssertNotIsNaN", function() _AFT.assertNotIsNaN(1) end) +_AFT.describe("testAssertNotIsInf", function() _AFT.assertNotIsInf(2) end) +_AFT.describe("testAssertNotIsPlusInf", function() _AFT.assertNotIsPlusInf(2) end) +_AFT.describe("testAssertNotIsMinusInf", function() _AFT.assertNotIsMinusInf(2) end) +_AFT.describe("testAssertNotIsPlusZero", function() _AFT.assertNotIsPlusZero(2) end) +_AFT.describe("testAssertNotIsMinusZero", function() _AFT.assertNotIsMinusZero(2) end) +_AFT.describe("testAssertNotIsFunction", function() _AFT.assertNotIsFunction(2) end) +_AFT.describe("testAssertNotIsThread", function() _AFT.assertNotIsThread(2) end) +_AFT.describe("testAssertNotIsUserdata", function() _AFT.assertNotIsUserdata(2) end) + +function _callback(responseJ) _AFT.assertNotIsNil(responseJ) end +function _callbackError(responseJ) _AFT.assertStrContains(responseJ.request.info, "verb pingfail unknown within api afTest") end + +_AFT.describe("testAssertVerbStatusSuccess",function() _AFT.assertVerbStatusSuccess('afTest', 'ping', {}) end) +_AFT.describe("testAssertVerbResponseEquals",function() _AFT.assertVerbResponseEquals('afTest', 'ping', {}) end) +_AFT.describe("testAssertVerbCb",function() _AFT.assertVerbCb('afTest', 'ping', {},_callback) end) +_AFT.describe("testAssertVerbStatusError",function() _AFT.assertVerbStatusError('afTest', 'pingfail', {}) end) +_AFT.describe("testAssertVerbResponseEqualsError",function() _AFT.assertVerbResponseEqualsError('afTest', 'nonexistentverb', {},"Ping Binder Daemon fails") end) +_AFT.describe("testAssertVerbCbError",function() _AFT.assertVerbCbError('afTest', 'pingfail', {},_callbackError) end) + +_AFT.exitAtEnd() diff --git a/test/afb-test/tests/helloworld.lua b/test/afb-test/tests/helloworld.lua new file mode 100644 index 0000000..2e99a6e --- /dev/null +++ b/test/afb-test/tests/helloworld.lua @@ -0,0 +1,59 @@ +--[[ + Copyright (C) 2018 "IoT.bzh" + Author Romain Forlot <romain.forlot@iot.bzh> + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + + NOTE: strict mode: every global variables should be prefixed by '_' +--]] + +function _callback(responseJ) + _AFT.assertStrContains(responseJ.response, "Some String") +end + +function _callbackError(responseJ) + _AFT.assertStrContains(responseJ.request.info, "Ping Binder Daemon fails") +end +function _callbackEvent(eventName, eventData) + _AFT.assertEquals(eventData, { key = 'weird others data', another_key = 123.456 }) +end + +_AFT.addEventToMonitor("hello/anEvent") +_AFT.addEventToMonitor("hello/anotherEvent", _callbackEvent) + +_AFT.testVerbStatusSuccess('testPingSuccess','hello', 'ping', {}) +_AFT.setBefore("testPingSuccess",function() print("~~~~~ Begin testPingSuccess ~~~~~") end) +_AFT.setAfter("testPingSuccess",function() print("~~~~~ End testPingSuccess ~~~~~") end) + +_AFT.testVerbResponseEquals('testPingSuccessAndResponse','hello', 'ping', {}, "Some String") +_AFT.testVerbCb('testPingSuccessCallback','hello', 'ping', {}, _callback) + +_AFT.testVerbStatusError('testPingError', 'hello', 'pingfail', {}) +_AFT.testVerbResponseEqualsError('testPingErrorAndResponse', 'hello', 'pingfail', {}, "Ping Binder Daemon succeeds") +_AFT.testVerbCbError('testPingErrorCallback', 'hello', 'pingfail', {}, _callbackError) + +_AFT.testVerbStatusSuccess('testEventAddanEvent', 'hello', 'eventadd', {tag = 'event', name = 'anEvent'}) +_AFT.testVerbStatusSuccess('testEventSubanEvent', 'hello', 'eventsub', {tag = 'event'}) +_AFT.testVerbStatusSuccess('testEventPushanEvent', 'hello', 'eventpush', {tag = 'event', data = { key = 'some data', another_key = 123}}) + +_AFT.testVerbStatusSuccess('testEventAddanotherEvent', 'hello', 'eventadd', {tag = 'evt', name = 'anotherEvent'}) +_AFT.testVerbStatusSuccess('testEventSubanotherEvent', 'hello', 'eventsub', {tag = 'evt'}) +_AFT.testVerbStatusSuccess('testEventPushanotherEvent', 'hello', 'eventpush', {tag = 'evt', data = { key = 'weird others data', another_key = 123.456}}) + +_AFT.testVerbStatusSuccess('testGenerateWarning', 'hello', 'verbose', {level = 4, message = 'My Warning message!'}) + +_AFT.testEvtGrpReceived("testEventGroupReceived",{["hello/anEvent"]=1,["hello/anotherEvent"]=1}) + +_AFT.testEvtReceived("testanEventReceived", "hello/anEvent") +_AFT.testEvtReceived("testanotherEventReceived", "hello/anotherEvent") diff --git a/test/afb-test/tests/mapi_tests.lua b/test/afb-test/tests/mapi_tests.lua new file mode 100644 index 0000000..ced9ea0 --- /dev/null +++ b/test/afb-test/tests/mapi_tests.lua @@ -0,0 +1,33 @@ +--[[ + Copyright (C) 2018 "IoT.bzh" + Author Romain Forlot <romain.forlot@iot.bzh> + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + + NOTE: strict mode: every global variables should be prefixed by '_' +--]] + +_AFT.testVerbStatusSuccess("TestListverb", "low-can", "list", {}) +_AFT.testVerbStatusSuccess("TestGetVerb", "low-can", "get", { event = "engine.speed"}) + +_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.assertVerb("low-can", "get", {}) + + _AFT.assertEvtGrpReceived({[evt1] = 1, [evt2] = 1}) +end) |