summaryrefslogtreecommitdiffstats
path: root/conf.d/controller/lua.d/aft.lua
blob: d2587fe161af340e2be400dbe4c335b25bb25855 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46

@media only all and (prefers-color-scheme: dark) {
.highlight .hll { background-color: #49483e }
.highlight .c { color: #75715e } /* Comment */
.highlight .err { color: #960050; background-color: #1e0010 } /* Error */
.highlight .k { color: #66d9ef } /* Keyword */
.highlight .l { color: #ae81ff } /* Literal */
.highlight .n { color: #f8f8f2 } /* Name */
.highlight .o { color: #f92672 } /* Operator */
.highlight .p { color: #f8f8f2 } /* Punctuation */
.highlight .ch { color: #75715e } /* Comment.Hashbang */
.highlight .cm { color: #75715e } /* Comment.Multiline */
.highlight .cp { color: #75715e } /* Comment.Preproc */
.highlight .cpf { color: #75715e } /* Comment.PreprocFile */
.highlight .c1 { color: #75715e } /* Comment.Single */
.highlight .cs { color: #75715e } /* Comment.Special */
.highlight .gd { color: #f92672 } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .gi { color: #a6e22e } /* Generic.Inserted */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #75715e } /* Generic.Subheading */
.highlight .kc { color: #66d9ef } /* Keyword.Constant */
.highlight .kd { color: #66d9ef } /* Keyword.Declaration */
.highlight .kn { color: #f92672 } /* Keyword.Namespace */
.highlight .kp { color: #66d9ef } /* Keyword.Pseudo */
.highlight .kr { color: #66d9ef } /* Keyword.Reserved */
.highlight .kt { color: #66d9ef } /* Keyword.Type */
.highlight .ld { color: #e6db74 } /* Literal.Date */
.highlight .m { color: #ae81ff } /* Literal.Number */
.highlight .s { color: #e6db74 } /* Literal.String */
.highlight .na { color: #a6e22e } /* Name.Attribute */
.highlight .nb { color: #f8f8f2 } /* Name.Builtin */
.highlight .nc { color: #a6e22e } /* Name.Class */
.highlight .no { color: #66d9ef } /* Name.Constant */
.highlight .nd { color: #a6e22e } /* Name.Decorator */
.highlight .ni { color: #f8f8f2 } /* Name.Entity */
.highlight .ne { color: #a6e22e } /* Name.Exception */
.highlight .nf { color: #a6e22e } /* Name.Function */
.highlight .nl { color: #f8f8f2 } /* Name.Label */
.highlight .nn { color: #f8f8f2 } /* Name.Namespace */
.highlight .nx { color: #a6e22e } /* Name.Other */
.highlight .py { color: #f8f8f2 } /* Name.Property */
.highlight .nt { color: #f92672 } /* Name.Tag */
.highlight .nv { color: #f8f8f2 } /* Name.Variable */
.highlight .ow { color: #f92672 } /* Operator.Word */
.highlight .w { color: #f8f8f2 } /* Text.Whitespace */
.highlight .mb { color: #ae81ff } /* Literal.Number.Bin */
.highlight .mf { color: #ae81ff } /* Literal.Number.Float */
.highlight .mh { color: #ae81ff } /* Literal.Number.Hex */
.highlight .mi { color: #ae81ff } /* Literal.Number.Integer */
.highlight .mo { color: #ae81ff } /* Literal.Number.Oct */
.highlight .sa { color: #e6db74 } /* Literal.String.Affix */
.highlight .sb { color: #e6db74 } /* Literal.String.Backtick */
.highlight .sc { color: #e6db74 } /* Literal.String.Char */
.highlight .dl { color: #e6db74 } /* Literal.String.Delimiter */
.highlight .sd { color: #e6db74 } /* Literal.String.Doc */
.highlight .s2 { color: #e6db74 } /* Literal.String.Double */
.highlight .se { color: #ae81ff } /* Literal.String.Escape */
.highlight .sh { color: #e6db74 } /* Literal.String.Heredoc */
.highlight .si { color: #e6db74 } /* Literal.String.Interpol */
.highlight .sx { color: #e6db74 } /* Literal.String.Other */
.highlight .sr { color: #e6db74 } /* Literal.String.Regex */
.highlight .s1 { color: #e6db74 } /* Literal.String.Single */
.highlight .ss { color: #e6db74 } /* Literal.String.Symbol */
.highlight .bp { color: #f8f8f2 } /* Name.Builtin.Pseudo */
.highlight .fm { color: #a6e22e } /* Name.Function.Magic */
.highlight .vc { color: #f8f8f2 } /* Name.Variable.Class */
.highlight .vg { color: #f8f8f2 } /* Name.Variable.Global */
.highlight .vi { color: #f8f8f2 } /* Name.Variable.Instance */
.highlight .vm { color: #f8f8f2 } /* Name.Variable.Magic */
.highlight .il { color: #ae81ff } /* Literal.Number.Integer.Long */
}
@media (prefers-color-scheme: light) {
.highlight .hll { background-color: #ffffcc }
.highlight .c { color: #888888 } /* Comment */
.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
.highlight .k { color: #008800; font-weight: bold } /* Keyword */
.highlight .ch { color: #888888 } /* Comment.Hashbang */
.highlight .cm { color: #888888 } /* Comment.Multiline */
.highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */
.highlight .cpf { color: #888888 } /* Comment.PreprocFile */
.highlight .c1 { color: #888888 } /* Comment.Single */
.highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */
.highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .gr { color: #aa0000 } /* Generic.Error */
.highlight .gh { color: #333333 } /* Generic.Heading */
.highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */
.highlight .go { color: #888888 } /* Generic.Output */
.highlight .gp { color: #555555 } /* Generic.Prompt */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #666666 } /* Generic.Subheading */
.highlight .gt { color: #aa0000 } /* Generic.Traceback */
.highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */
.highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */
.highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */
.highlight .kp { color: #008800 } /* Keyword.Pseudo */
.highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */
.highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */
.highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */
.highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */
.highlight .na { color: #336699 } /* Name.Attribute */
.highlight .nb { color: #003388 } /* Name.Builtin */
.highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */
.highlight .no { color: #003366; font-weight: bold } /* Name.Constant */
.highlight .nd { color: #555555 } /* Name.Decorator */
.highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */
.highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */
.highlight .nl { color: #336699; font-style: italic } /* Name.Label */
.highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */
.highlight .py { color: #336699; font-weight: bold } /* Name.Property */
.highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */
.highlight .nv { color: #336699 } /* Name.Variable */
.highlight .ow { color: #008800 } /* Operator.Word */
.highlight .w { color: #bbbbbb } /* Text.Whitespace */
.highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */
.highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */
.highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */
.highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */
.highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */
.highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */
.highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */
.highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */
.highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */
.highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */
.highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */
.highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */
.highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */
.highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */
.highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */
.highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */
.highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */
.highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */
.highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */
.highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */
.highlight .vc { color: #336699 } /* Name.Variable.Class */
.highlight .vg { color: #dd7700 } /* Name.Variable.Global */
.highlight .vi { color: #3333bb } /* Name.Variable.Instance */
.highlight .vm { color: #336699 } /* Name.Variable.Magic */
.highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
}
SUMMARY     = "AGL demo custom QtQuickControls2 widgets"
HOMEPAGE    = "https://git.automotivelinux.org/gerrit/#/admin/projects/src/qtquickcontrols2-agl"
LICENSE     = "MPL-2.0"
LIC_FILES_CHKSUM = "file://LICENSE.txt;md5=815ca599c9df247a0c7f619bab123dad"

DEPENDS = "qtquickcontrols2"

PV = "1.0+git${SRCPV}"

SRC_URI = "git://gerrit.automotivelinux.org/gerrit/src/qtquickcontrols2-agl;protocol=https;branch=${AGL_BRANCH}"
SRCREV = "1261ac1f1f1f2e4d659159f4ce51322f1d585128"

S = "${WORKDIR}/git/"

inherit qmake5

FILES_${PN} += "${OE_QMAKE_PATH_QML}/AGL/Demo/Controls/*"

RDEPENDS_${PN} += " \
	qtquickcontrols-qmlplugins \
	qtquickcontrols2-qmlplugins \
	qtsvg-plugins \
"
391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459
--[[
    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 '_'
--]]

local lu = require('luaunit')
lu.LuaUnit:setOutputType('JUNIT')
lu.LuaUnit.fname = "var/jUnitResults.xml"

-- Use our own print function to redirect it to a file the standard output
_standard_print = print
print = function(...)
	io.write(... .. '\n')
	_standard_print(...)
end

_AFT = {
	exit = {0, code},
	context = _ctx,
	tests_list = {},
	event_history = false,
	monitored_events = {},
	beforeEach = nil,
	afterEach = nil,
	beforeAll = nil,
	afterAll = nil,
}

function _AFT.enableEventHistory()
	_AFT.event_history = true
end

function _AFT.setJunitFile(filePath)
	lu.LuaUnit.fname = filePath
end

function _AFT.setOutputFile(filePath)
	local file = assert(io.open(filePath, "w+"))
	io.output(file)
end

function _AFT.exitAtEnd(code)
	_AFT.exit = {1, code}
end

--[[
  Events listener and assertion functions to test correctness of received
  event data.

  Check are in 2 times. First you need to register the event that you want to
  monitor then you test that it has been correctly received.

  Notice that there is a difference between log and event. Logs are daemon
  messages normally handled by the host log system (journald, syslog...) and
  events are generated by the apis to communicate and send informations to the
  subscribed listeners.
]]

function _AFT.addEventToMonitor(eventName, callback)
	_AFT.monitored_events[eventName] = { cb = callback, receivedCount = 0 }
end

function _AFT.incrementCount(dict)
	if dict.receivedCount then
		dict.receivedCount = dict.receivedCount + 1
	else
		dict.receivedCount = 1
	end
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)
		else
			dict.data[1] = eventData
		end
	else
		dict.data = {}
		table.insert(dict.data, eventData)
	end
end

function _AFT.requestDaemonEventHandler(eventObj)
	local eventName = eventObj.data.message
	local log = _AFT.monitored_events[eventName]
	local api = nil

	if eventObj.daemon then
		api = eventObj.daemon.api
	elseif eventObj.request then
		api = eventObj.request.api
	end

	if log and log.api == api and log.type == eventObj.data.type then
		_AFT.incrementCount(_AFT.monitored_events[eventName])
		_AFT.registerData(_AFT.monitored_events[eventName], eventObj.data)
	end

end

function _AFT.bindingEventHandler(eventObj)
	local eventName = eventObj.event.name
	local eventListeners = eventObj.data.result

	-- Remove from event to hold the bare event data and be able to assert it
	eventObj.data.result = nil

	if type(_AFT.monitored_events[eventName]) == 'table' then
		_AFT.monitored_events[eventName].eventListeners = eventListeners

		_AFT.incrementCount(_AFT.monitored_events[eventName])
		_AFT.registerData(_AFT.monitored_events[eventName], eventObj.data)
	end
end

function _evt_catcher_ (source, action, eventObj)
	if eventObj.type == "event" then
		_AFT.bindingEventHandler(eventObj)
	elseif eventObj.type == "daemon" or eventObj.type == "request" then
		_AFT.requestDaemonEventHandler(eventObj)
	end
end

--[[
  Assert and test functions about the event part.
]]

function _AFT.assertEvtNotReceived(eventName)
	local count = 0
	if _AFT.monitored_events[eventName].receivedCount then
		count = _AFT.monitored_events[eventName].receivedCount
	end

	_AFT.assertIsTrue(count == 0, "Event '".. eventName .."' received but it shouldn't")

	if _AFT.monitored_events[eventName].cb then
		local data_n = #_AFT.monitored_events[eventName].data
		_AFT.monitored_events[eventName].cb(eventName, _AFT.monitored_events[eventName].data[data_n])
	end
end

function _AFT.assertEvtReceived(eventName)
	local count = 0
	if _AFT.monitored_events[eventName].receivedCount then
		count = _AFT.monitored_events[eventName].receivedCount
	end

	_AFT.assertIsTrue(count > 0, "No event '".. eventName .."' received")

	if _AFT.monitored_events[eventName].cb then
		local data_n = #_AFT.monitored_events[eventName].data
		_AFT.monitored_events[eventName].cb(eventName, _AFT.monitored_events[eventName].data[data_n])
	end
end

function _AFT.testEvtNotReceived(testName, eventName, timeout)
	table.insert(_AFT.tests_list, {testName, function()
		if _AFT.beforeEach then _AFT.beforeEach() end
		if timeout then sleep(timeout) end
		_AFT.assertEvtNotReceived(eventName)
		if _AFT.afterEach then _AFT.afterEach() end
	end})
end

function _AFT.testEvtReceived(testName, eventName, timeout)
	table.insert(_AFT.tests_list, {testName, function()
		if _AFT.beforeEach then _AFT.beforeEach() end
		if timeout then sleep(timeout) end
		_AFT.assertEvtReceived(eventName)
		if _AFT.afterEach then _AFT.afterEach() end
	end})
end

--[[
  Assert function meant to tests API Verbs calls
]]

local function assertVerbCallParameters(src, api, verb, args)
	_AFT.assertIsUserdata(src, "Source must be an opaque userdata pointer which will be passed to the binder")
	_AFT.assertIsString(api, "API and Verb must be string")
	_AFT.assertIsString(verb, "API and Verb must be string")
	_AFT.assertIsTable(args, "Arguments must use LUA Table (event empty)")
end

function _AFT.assertVerb(api, verb, args, cb)
	assertVerbCallParameters(_AFT.context, api, verb, args)
	local err,responseJ = AFB:servsync(_AFT.context, api, verb, args)
	_AFT.assertIsFalse(err)
	_AFT.assertStrContains(responseJ.request.status, "success", nil, nil, "Call for API/Verb failed.")

	local tcb = type(cb)
	if cb then
		if tcb == 'function' then
			cb(responseJ)
		elseif tcb == 'table' then
			_AFT.assertEquals(responseJ.response, cb)
		elseif tcb == 'string' or tcb == 'number' then
			_AFT.assertEquals(responseJ.response, cb)
		else
			_AFT.assertIsTrue(false, "Wrong parameter passed to assertion. Last parameter should be function, table representing a JSON object or nil")
		end
	end
end

function _AFT.assertVerbError(api, verb, args, cb)
	assertVerbCallParameters(_AFT.context, api, verb, args)
	local err,responseJ = AFB:servsync(_AFT.context, api, verb, args)
	_AFT.assertIsTrue(err)
	_AFT.assertNotStrContains(responseJ.request.status, "success", nil, nil, "Call for API/Verb succeed but it shouldn't.")

	local tcb = type(cb)
	if cb then
		if tcb == 'function' then
			cb(responseJ)
		elseif tcb == 'string' then
			_AFT.assertNotEquals(responseJ.request.info, cb)
		else
			_AFT.assertIsFalse(false, "Wrong parameter passed to assertion. Last parameter should be a string representing the failure informations")
		end
	end
end

function _AFT.testVerb(testName, api, verb, args, cb)
	table.insert(_AFT.tests_list, {testName, function()
		if _AFT.beforeEach then _AFT.beforeEach() end
		_AFT.assertVerb(api, verb, args, cb)
		if _AFT.afterEach then _AFT.afterEach() end
	end})
end

function _AFT.testVerbError(testName, api, verb, args, cb)
	table.insert(_AFT.tests_list, {testName, function()
		if _AFT.beforeEach then _AFT.beforeEach() end
		_AFT.assertVerbError(api, verb, args, cb)
		if _AFT.afterEach then _AFT.afterEach() end
	end})
end

function _AFT.describe(testName, testFunction, setUp, tearDown)
	sanitizedTestName = "test"..tostring(testName)
	if _AFT.beforeEach then local b = _AFT.beforeEach() end
	if _AFT.afterEach then local a = _AFT.afterEach() end
	local aTest = {}

	function aTest:sanitizedTestName() testFunction() end
	function aTest:setUp()
		if type(setUp) == 'function' then setUp() end
		b()
	end
	function aTest:tearDown()
		a()
		if type(tearDown) == 'function' then tearDown() end
	end

	table.insert(_AFT.tests_list, {testName, function()
		if type(testFunction) == 'function' then
			testFunction()
		else
			print('# ERROR: Test '.. testName .. ' is note defined as a function.')
		end
	end})
end

function _AFT.setBeforeEach(beforeEachTestFunction)
	if type(beforeEachTestFunction) == "function" then
		_AFT.beforeEach = beforeEachTestFunction
	else
		print("Wrong beforeEach function defined. It isn't detected as a function type")
	end
end

function _AFT.setAfterEach(afterEachTestFunction)
	if type(afterEachTestFunction) == "function" then
		_AFT.afterEach = afterEachTestFunction
	else
		print("Wrong beforeEach function defined. It isn't detected as a function type")
	end
end

function _AFT.setBeforeAll(beforeAllTestsFunctions)
	if type(beforeAllTestsFunctions) == "function" then
		_AFT.beforeAll = beforeAllTestsFunctions
	else
		print("Wrong beforeAll function defined. It isn't detected as a function type")
	end
end

function _AFT.setAfterAll(afterAllTestsFunctions)
	if type(afterAllTestsFunctions) == "function" then
		_AFT.afterAll = afterAllTestsFunctions
	else
		print("Wrong afterAll function defined. It isn't detected as a function type")
	end
end

--[[
	Make all assertions accessible using _AFT and declare some convenients
	aliases.
]]

local luaunit_list_of_assert = {
	--  official function name from luaunit test framework

	-- general assertions
	'assertEquals',
	'assertItemsEquals',
	'assertNotEquals',
	'assertAlmostEquals',
	'assertNotAlmostEquals',
	'assertEvalToTrue',
	'assertEvalToFalse',
	'assertStrContains',
	'assertStrIContains',
	'assertNotStrContains',
	'assertNotStrIContains',
	'assertStrMatches',
	'assertError',
	'assertErrorMsgEquals',
	'assertErrorMsgContains',
	'assertErrorMsgMatches',
	'assertIs',
	'assertNotIs',

	-- type assertions: assertIsXXX -> assert_is_xxx
	'assertIsNumber',
	'assertIsString',
	'assertIsTable',
	'assertIsBoolean',
	'assertIsNil',
	'assertIsTrue',
	'assertIsFalse',
	'assertIsNaN',
	'assertIsInf',
	'assertIsPlusInf',
	'assertIsMinusInf',
	'assertIsPlusZero',
	'assertIsMinusZero',
	'assertIsFunction',
	'assertIsThread',
	'assertIsUserdata',

	-- type assertions: assertNotIsXXX -> assert_not_is_xxx
	'assertNotIsNumber',
	'assertNotIsString',
	'assertNotIsTable',
	'assertNotIsBoolean',
	'assertNotIsNil',
	'assertNotIsTrue',
	'assertNotIsFalse',
	'assertNotIsNaN',
	'assertNotIsInf',
	'assertNotIsPlusInf',
	'assertNotIsMinusInf',
	'assertNotIsPlusZero',
	'assertNotIsMinusZero',
	'assertNotIsFunction',
	'assertNotIsThread',
	'assertNotIsUserdata',
}

local luaunit_list_of_functions = {
	"setOutputType",
}

local _AFT_list_of_funcs = {
	-- AF Binder generic assertions
	{ 'addEventToMonitor', 'resetEventReceivedCount' },
	{ 'assertVerb',      'assertVerbStatusSuccess' },
	{ 'assertVerb',      'assertVerbResponseEquals' },
	{ 'assertVerb',      'assertVerbCb' },
	{ 'assertVerbError', 'assertVerbStatusError' },
	{ 'assertVerbError', 'assertVerbResponseEqualsError' },
	{ 'assertVerbError', 'assertVerbCbError' },
	{ 'testVerb',      'testVerbStatusSuccess' },
	{ 'testVerb',      'testVerbResponseEquals' },
	{ 'testVerb',      'testVerbCb' },
	{ 'testVerbError', 'testVerbStatusError' },
	{ 'testVerbError', 'testVerbResponseEqualsError' },
	{ 'testVerbError', 'testVerbCbError' },
}

-- Import all luaunit assertion function to _AFT object
for _, v in pairs( luaunit_list_of_assert ) do
	local funcname = v
	_AFT[funcname] = lu[funcname]
end

-- Import specific luaunit configuration functions to _AFT object
for _, v in pairs( luaunit_list_of_functions ) do
	local funcname = v
	_AFT[funcname] = lu.LuaUnit[funcname]
end

-- Create all aliases in _AFT
for _, v in pairs( _AFT_list_of_funcs ) do
	local funcname, alias = v[1], v[2]
	_AFT[alias] = _AFT[funcname]
end

function _launch_test(context, args)
	_AFT.context = context

	-- Prepare the tests execution configuring the monitoring and loading
	-- lua test files to execute in the Framework.
	_AFT.setOutputFile("var/test_results.log")
	AFB:servsync(_AFT.context, "monitor", "set", { verbosity = "debug" })
	AFB:servsync(_AFT.context, "monitor", "trace", { add = { api = args.trace, request = "vverbose", event = "push_after" }})
	if args.files and type(args.files) == 'table' then
		for _,f in pairs(args.files) do
			dofile('var/'..f)
		end
	elseif type(args.files) == 'string' then
		dofile('var/'..args.files)
	end

	-- Execute the test within a context if given. We assume that the before
	-- function success returning '0' else we abort the whole test procedure
	if _AFT.beforeAll then
		if _AFT.beforeAll() == 0 then
			AFB:success(_AFT.context, { info = "Launching tests"})
			lu.LuaUnit:runSuiteByInstances(_AFT.tests_list)

			local success ="Success : "..tostring(lu.LuaUnit.result.passedCount)
			local failures="Failures : "..tostring(lu.LuaUnit.result.testCount-lu.LuaUnit.result.passedCount)

			local evtHandle = AFB:evtmake(_AFT.context, 'results')
			AFB:subscribe(_AFT.context,evtHandle)
			AFB:evtpush(_AFT.context,evtHandle,{info = success.." "..failures})
		else
			AFB:fail(_AFT.context, { info = "Can't set the context to execute the tests correctly. Look at the log and retry."})
		end
	end

	-- Keep the context unset function to be executed after all no matter if
	-- tests have been executed or not.
	if _AFT.afterAll then
		if _AFT.afterAll() ~= 0 then
			print('Unsetting the tests context failed.')
		end
	end

	if _AFT.exit[1] == 1 then os.exit(_AFT.exit[2]) end
end