diff options
-rw-r--r-- | conf.d/project/etc/test-config.json | 19 | ||||
-rw-r--r-- | src/test-binding.c | 26 |
2 files changed, 28 insertions, 17 deletions
diff --git a/conf.d/project/etc/test-config.json b/conf.d/project/etc/test-config.json index 2afd85d..cf53b96 100644 --- a/conf.d/project/etc/test-config.json +++ b/conf.d/project/etc/test-config.json @@ -5,14 +5,11 @@ "uid": "Test", "version": "1.0", "api": "test", - "info": "Binding made to tests other bindings" + "info": "Binding made to tests other bindings", + "require": [ + "hello" + ] }, - "resources": [{ - "uid": "AFT", - "info": "Binder test framework", - "spath": "var/", - "libs": [ "aft.lua"] - }], "onload": { "uid": "launch_all_tests", "info": "Launch all the tests", @@ -20,11 +17,5 @@ "args": { "files": ["helloworld.lua"] } - }, - "events":[ - { - "uid": "monitor/trace", - "action": "lua://low-can-test#_evt_catcher_" - } - ] + } } diff --git a/src/test-binding.c b/src/test-binding.c index d1c6c1f..33a8807 100644 --- a/src/test-binding.c +++ b/src/test-binding.c @@ -100,21 +100,25 @@ static int CtrlLoadOneApi(void *cbdata, AFB_ApiT apiHandle) { int afbBindingVdyn(afb_dynapi *apiHandle) { int status, err = 0; + const char *dirList = NULL, *configPath = NULL; + json_object *resourcesJ = NULL, *eventsJ = NULL; + CtlConfigT *ctrlConfig = NULL; AFB_default = apiHandle; + AFB_ApiNotice(apiHandle, "Controller in afbBindingVdyn"); - const char *dirList = getenv("CONTROL_CONFIG_PATH"); + dirList = getenv("CONTROL_CONFIG_PATH"); if (!dirList) dirList = CONTROL_CONFIG_PATH; - const char *configPath = CtlConfigSearch(apiHandle, dirList, ""); + configPath = CtlConfigSearch(apiHandle, dirList, ""); if (!configPath) { AFB_ApiError(apiHandle, "CtlPreInit: No %s* config found in %s ", GetBinderName(), dirList); return ERROR; } // load config file and create API - CtlConfigT *ctrlConfig = CtlLoadMetaData(apiHandle, configPath); + ctrlConfig = CtlLoadMetaData(apiHandle, configPath); if (!ctrlConfig) { AFB_ApiError(apiHandle, "CtrlBindingDyn No valid control config file in:\n-- %s", @@ -132,6 +136,22 @@ int afbBindingVdyn(afb_dynapi *apiHandle) { AFB_ApiNotice(apiHandle, "Controller API='%s' info='%s'", ctrlConfig->api, ctrlConfig->info); + err = wrap_json_pack(&resourcesJ, "{s[{ss, ss, ss, s[s]}]}", "resources", + "uid", "AFT", + "info", "LUA Binder test framework", + "spath", "var/", + "libs", "aft.lua" ); + err += wrap_json_pack(&eventsJ, "{s[{ss, ss}]}", "events", + "uid", "monitor/trace", + "action", "lua://AFT#_evt_catcher_" ); + + if(err) { + AFB_ApiError(apiHandle, "Error at Controller configuration editing."); + return err; + } + wrap_json_object_add(ctrlConfig->configJ, resourcesJ); + wrap_json_object_add(ctrlConfig->configJ, eventsJ); + // create one API per config file (Pre-V3 return code ToBeChanged) status = afb_dynapi_new_api(apiHandle, ctrlConfig->api, ctrlConfig->info, 1, CtrlLoadOneApi, ctrlConfig); |