diff options
author | Romain Forlot <romain.forlot@iot.bzh> | 2018-07-26 11:21:54 +0200 |
---|---|---|
committer | Romain Forlot <romain.forlot@iot.bzh> | 2018-08-02 16:50:49 +0200 |
commit | 121ac1676034f10454190638c2590014dff3941c (patch) | |
tree | 26853f42456b635d4accd190e8f7f3cef560fba7 /conf.d/controller | |
parent | 3487157e3c71f089d9ff4ff555a893f2cdb066a3 (diff) |
Some fixes
Fix: No events defined in the mock apis
Fix: new_api function has changed in binder
Using the dynapi new_api function returned 0 in case of success
and -1 on failure. New function since v3 returned NULL in case of
failure or the api struct in case of success.
Fix: wrong install_prefix variable used in CMake config file
Fix: wrong variable used
Typo after a copy/paste from event group handling.
- Wrong use of table.insert
- Wrong variable name used
- only pass the data table, which is embed in another data
table...
- Fix aftereach and beforeeach function's call
Change-Id: I9523ae50c170a3cdb9e5c3bc2b9e923c30f6ba39
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'conf.d/controller')
-rw-r--r-- | conf.d/controller/lua.d/aft.lua | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/conf.d/controller/lua.d/aft.lua b/conf.d/controller/lua.d/aft.lua index b229e39..4161183 100644 --- a/conf.d/controller/lua.d/aft.lua +++ b/conf.d/controller/lua.d/aft.lua @@ -96,7 +96,7 @@ end function _AFT.registerData(dict, eventData) if dict.data and type(dict.data) == 'table' then if _AFT.event_history == true then - table.insert(dict.data, eventData, 1) + table.insert(dict.data, 1, eventData) else dict.data[1] = eventData end @@ -111,9 +111,9 @@ function _AFT.triggerEvtCallback(eventName) if _AFT.monitored_events[eventName].data ~= nil then local data_n = table_size(_AFT.monitored_events[eventName].data) if _AFT.event_history == true then - _AFT.monitored_events[eventName].cb(v.name, _AFT.monitored_events[eventName].data[data_n], _AFT.monitored_events[eventName].data) + _AFT.monitored_events[eventName].cb(eventName, _AFT.monitored_events[eventName].data[data_n], _AFT.monitored_events[eventName].data) else - _AFT.monitored_events[eventName].cb(v.name, _AFT.monitored_events[eventName].data[data_n]) + _AFT.monitored_events[eventName].cb(eventName, _AFT.monitored_events[eventName].data[data_n]) end end end @@ -132,7 +132,7 @@ function _AFT.bindingEventHandler(eventObj, uid) eventListeners = eventObj.data.result -- Remove from event to hold the bare event data and be able to assert it eventObj.data.result = nil - data = eventObj.data + data = eventObj.data.data end if type(_AFT.monitored_events[eventName]) == 'table' then @@ -274,7 +274,7 @@ function _AFT.assertEvtNotReceived(eventName, timeout) _AFT.assertIsTrue(count == 0, "Event '".. eventName .."' received but it shouldn't") - _AFT.triggerEvtCallback(event.name) + _AFT.triggerEvtCallback(eventName) end function _AFT.assertEvtReceived(eventName, timeout) @@ -285,7 +285,7 @@ function _AFT.assertEvtReceived(eventName, timeout) _AFT.assertIsTrue(count > 0, "No event '".. eventName .."' received") - _AFT.triggerEvtCallback(event.name) + _AFT.triggerEvtCallback(eventName) end function _AFT.testEvtNotReceived(testName, eventName, timeout, setUp, tearDown) @@ -371,8 +371,6 @@ function _AFT.testVerbError(testName, api, verb, args, cb, setUp, tearDown) end function _AFT.describe(testName, testFunction, setUp, tearDown) - if _AFT.beforeEach then local b = _AFT.beforeEach() end - if _AFT.afterEach then local a = _AFT.afterEach() end local aTest = {} if type(testFunction) == 'function' then @@ -382,12 +380,12 @@ function _AFT.describe(testName, testFunction, setUp, tearDown) os.exit(1) end function aTest:setUp() + if _AFT.beforeEach then _AFT.beforeEach() end if type(setUp) == 'function' then setUp() end - if b then b() end end function aTest:tearDown() - if a then a() end if type(tearDown) == 'function' then tearDown() end + if _AFT.afterEach then _AFT.afterEach() end end table.insert(_AFT.tests_list, {testName, aTest}) @@ -569,10 +567,10 @@ local function call_tests() local failures="Failures : "..tostring(lu.LuaUnit.result.testCount-lu.LuaUnit.result.passedCount) local evtHandle = AFB:evtmake(_AFT.context, 'results') - if type(evtHandle) == "userdata" then - AFB:subscribe(_AFT.context,evtHandle) - AFB:evtpush(_AFT.context,evtHandle,{info = success.." "..failures}) - end + --if type(evtHandle) == "userdata" then + -- AFB:subscribe(_AFT.context,evtHandle) + -- AFB:evtpush(_AFT.context,evtHandle,{info = success.." "..failures}) + --end end function _launch_test(context, args) |