diff options
author | CorentinLGS <corentinlgs@gmail.com> | 2018-08-29 10:23:34 +0200 |
---|---|---|
committer | Jan-Simon Moeller <jsmoeller@linuxfoundation.org> | 2018-08-30 14:52:12 +0000 |
commit | d54d2b73f869e0e724689e89f1d4c10660370cf2 (patch) | |
tree | 2099ce656dcc2b13c3e243408cc1865bfc549753 /docs | |
parent | a7fecc239ad5349d99d826764a85574332e061da (diff) |
afb-test doc: Updated doc.
-Changed 0_ProjectTree.md to only show what's interesting.
-Made further explanations on how to organize and integrate test files.
-Updated 2_LaunchTheExample.md, now explains the new way to launch tests.
-Also added the result of a test launched on a target.
-Added a configuration example in 1_BindingConfiguration.md .
Change-Id: I4c4ed1cef5e914a8179a6823489791e6756106b6
Signed-off-by: CorentinLGS <corentinlgs@gmail.com>
Diffstat (limited to 'docs')
-rw-r--r-- | docs/2_LaunchTheExample.md | 89 | ||||
-rw-r--r-- | docs/WriteYourTests/0_ProjectTree.md | 133 | ||||
-rw-r--r-- | docs/WriteYourTests/1_BindingConfiguration.md | 74 |
3 files changed, 263 insertions, 33 deletions
diff --git a/docs/2_LaunchTheExample.md b/docs/2_LaunchTheExample.md index e968f9a..1ef3de7 100644 --- a/docs/2_LaunchTheExample.md +++ b/docs/2_LaunchTheExample.md @@ -1,9 +1,12 @@ # Launch The Example +## From a terminal (on your build host) + To launch your tests, enter this command. ```bash -afb-daemon --name aft-aftest --port=1234 --workdir=package --ldpaths=/opt/AGL/lib64/afb:lib --token= -vvv --tracereq=common +export BUILD_DIR_PATH = "$(pwd)/build" +./afb-test.sh <BUILD_DIR_PATH> ``` On afb-daemon startup you should have all the app-framework config displayed: @@ -144,4 +147,86 @@ HOOK: [xreq-000006:hello/ping] END ~~~~~~~~~~ END ALL TESTS ~~~~~~~~~~ HOOK: [xreq-000001:afTest/launch_all_tests] END -```
\ No newline at end of file +``` + +## On target + +If you are trying to launch your test on a target you'll have to use +a test widget which contains test files, fixture and configuration. +Then use **afm-test**: + +```bash +./afm-test <path> +``` + +By default, the test widgets should be located in /usr/AGL/apps/testwgt. +This it will install the widget, launch the tests then display the result +on standard output. After that it will kill test app and remove it. + +You can produce a widget buy entering ```make widget``` in *build/*. + +Here is an example: + +```bash + +qemux86-64:~# afm-test /usr/AGL/apps/testwgt/aftest-test.wgt +PASS: aftest-test@5.99 started with pid=3857 +null +null +1..62 +~~~~~ Begin Test ~~~~~ +~~~~~ End Test ~~~~~ +PASS: 1 TestListverb.testFunction +~~~~~ Begin Test ~~~~~ +~~~~~ End Test ~~~~~ +PASS: 2 TestGetVerb.testFunction +~~~~~ Begin Test ~~~~~ +~~~~~ End Test ~~~~~ +PASS: 3 Test_turning_on.testFunction +~~~~~ Begin Test ~~~~~ +~~~~~ Begin Test Assert Equals ~~~~~ +~~~~~ End Test Assert Equals ~~~~~ +~~~~~ End Test ~~~~~ +PASS: 4 testAssertEquals.testFunction +~~~~~ Begin Test ~~~~~ +~~~~~ End Test ~~~~~ +PASS: 5 testAssertNotEquals.testFunction +~~~~~ Begin Test ~~~~~ +~~~~~ End Test ~~~~~ +PASS: 6 testAssertItemsEquals.testFunction +~~~~~ Begin Test ~~~~~ +~~~~~ End Test ~~~~~ +PASS: 7 testAssertAlmostEquals.testFunction +~~~~~ Begin Test ~~~~~ +~~~~~ End Test ~~~~~ +PASS: 8 testAssertNotAlmostEquals.testFunction +~~~~~ Begin Test ~~~~~ +~~~~~ End Test ~~~~~ +PASS: 9 testAssertEvalToTrue.testFunction +~~~~~ Begin Test ~~~~~ +~~~~~ End Test ~~~~~ +PASS: 10 testAssertEvalToFalse.testFunction +~~~~~ Begin Test ~~~~~ +~~~~~ End Test ~~~~~ +[...] +PASS: 60 testAssertVerbStatusError.testFunction +~~~~~ Begin Test ~~~~~ +~~~~~ End Test ~~~~~ +PASS: 61 testAssertVerbResponseEqualsError.testFunction +~~~~~ Begin Test ~~~~~ +~~~~~ End Test ~~~~~ +PASS: 62 testAssertVerbCbError.testFunction +# Ran 62 tests in 0.003 seconds, 62 successes, 0 failures +~~~~~~~~~~ END ALL TESTS ~~~~~~~~~~ +PASS: aftest-test@5.99 killed and removed + +``` + +The command being : ```afm-test /usr/AGL/apps/testwgt/aftest-test.wgt``` + +You can see here that everything ran as on your pc terminal. +**Begin Test** and **End Test** are the +beforeEach and afterEach functions and +**END ALL TESTS** is the after all functions. + + **PASS :** shows the function that is or was running.
\ No newline at end of file diff --git a/docs/WriteYourTests/0_ProjectTree.md b/docs/WriteYourTests/0_ProjectTree.md index e23c834..850487c 100644 --- a/docs/WriteYourTests/0_ProjectTree.md +++ b/docs/WriteYourTests/0_ProjectTree.md @@ -1,37 +1,108 @@ -# afb-test architecture +# Test architecture + +## Files tree and organization ```tree -+-- afb_helpers -+-- app-controller-submodule -+-- build -+-- conf.d -| +-- app-templates -| +-- autobuild -| +-- cmake -| +-- controller -| | +-- etc -| | | +-- aft-mapis.json -| | | +-- aft-test.json -| | | +-- CMakeLists.txt -| | +-- lua.d -| | | +--aft.lua -| | | +--aftTest.lua -| | | ... -| | +-- CMakeLists.txt -| +--wgt -+-- src -+-- .gitignore -+-- .gitmodules -+-- .gitreview -+-- CMakeLists.txt -+-- LICENSE-2.0.txt -+-- README.md + +"test" + +-- etc + | +-- aft-aftest-self.json + | +-- CMakeLists.txt + +-- fixture + | +-- a-script.sh + | +-- any-needed.data + | +-- CMakeLists.txt + | +-- data.json + +-- tests + | +-- CMakeLists.txt + | +-- test01.lua + | +-- test02.lua + | ... + ``` -To write your tests we will only touch to the **controller** folder, specifically -to the **lua.d** and to the **etc** folders. +To integrate tests in your project, create a **test** subfolder at your project +root directory and fulfill it with appropriate files like shown as above. To make it quick you'll have to write your tests using lua language and store it -in the lua.d folder and change aft-test.json or make a new .json file to be able -to launch your tests, not that if you make a new json file, his name has to start -with "aft-" followed by the binder's name. (e.g. aft-test for the afb-test)
\ No newline at end of file +in the **tests** (with an "s") folder (as shown above) and change *aft-aftest-self.json* or make a new .json +file to be able to launch your tests. Note that if you make a new json file, +its name has to start with "aft-" followed by the binder's name. (e.g. +aft-low-can for the low-level-can-service) + +*aft-aftest-self.json* is a conguration file. You'll see in the next section +how to write a proper configuration file. + +## Integration with CMake using App-templates + +To make the link between your test files, config files, data files +and the test binding, +you will have to integrate them with CMake using the App-templates. + +First you will have to create your CMake target using **PROJECT_TARGET_ADD** +with your target name as parameter, it will include the target to +your project. + +Then add your data files using **add_input_files** with your files in +parameter. + +Use **SET_TARGET_PROPERTIES** to fit the targets properties for macros +usage. Here you have to specify what type of your targets you want to include +in the widget package using the property **LABELS**. It will most likely either +be *TEST-DATA* or *TEST-CONFIG*. + +Here is the LABELS list: + +- **TEST-CONFIG**: JSON configuration files that will be used by the afb-test + binding to know how to execute tests. +- **TEST-DATA**: Resources used to test your binding. It is at least your test + plan and also could be fixtures and any files needed by your tests. These files + will appear in a separate test widget. +- **TEST-PLUGIN**: Shared library meant to be used as a binding + plugin. Binding would load it as a plugin to extend its functionalities. It + should be named with a special extension that you choose with SUFFIX cmake + target property or it'd be **.ctlso** by default. +- **TEST-HTDOCS**: Root directory of a web app. This target has to build its + directory and put its files in the ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME} +- **TEST-EXECUTABLE**: Entry point of your application executed by the AGL + Application Framework +- **TEST-LIBRARY**: An external 3rd party library bundled with the binding for its + own use in case the platform doesn't provide it. + +Here is a mapping between LABELS and directories where files will be placed in +the widget: + +- **EXECUTABLE** : \<wgtrootdir\>/bin +- **BINDING-CONFIG** : \<wgtrootdir\>/etc +- **BINDING** | **BINDINGV2** | **BINDINGV3** | **LIBRARY** : \<wgtrootdir\>/lib +- **PLUGIN** : \<wgtrootdir\>/lib/plugins +- **HTDOCS** : \<wgtrootdir\>/htdocs +- **BINDING-DATA** : \<wgtrootdir\>/var +- **DATA** : \<wgtrootdir\>/var + +And about test dedicated **LABELS**: + +- **TEST-EXECUTABLE** : \<TESTwgtrootdir\>/bin +- **TEST-CONFIG** : \<TESTwgtrootdir\>/etc +- **TEST-PLUGIN** : \<TESTwgtrootdir\>/lib/plugins +- **TEST-HTDOCS** : \<TESTwgtrootdir\>/htdocs +- **TEST-DATA** : \<TESTwgtrootdir\>/var + +> **TIP** you should use the prefix _afb-_ with your **BINDING* targets which +> stand for **Application Framework Binding**. + +You will find in depth explanations about it [here](http://docs.automotivelinux.org/docs/devguides/en/dev/reference/sdk-devkit/docs/part-2/2_4-Use-app-templates.html#targets-properties). + +Here is an example of a proper CMake file: + +```CMake +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} + ) +```
\ No newline at end of file diff --git a/docs/WriteYourTests/1_BindingConfiguration.md b/docs/WriteYourTests/1_BindingConfiguration.md index 9980357..90b7e8d 100644 --- a/docs/WriteYourTests/1_BindingConfiguration.md +++ b/docs/WriteYourTests/1_BindingConfiguration.md @@ -35,4 +35,78 @@ Here is an example: } } } +``` + +and another example which tests the low-can api: + +```json +{ + "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_" + }] + }] +} ```
\ No newline at end of file |