# Installation ## Pre-requisites [Setup the pre-requisite](http://docs.automotivelinux.org/docs/devguides/en/dev/reference/host-configuration/docs/1_Prerequisites.html) then [install the Application Framework](http://docs.automotivelinux.org/docs/devguides/en/dev/reference/host-configuration/docs/2_AGL_Application_Framework.html) on your host. You will also need to install lua-devel >= 5.3 to be able to build the project. Fedora: ```bash dnf install lua-devel ``` OpenSuse: ```bash zypper install lua53-devel ``` Ubuntu (>= Xenial), Debian stable: ```bash apt-get install liblua5.3-dev ``` ## Grab source and build Download the **afb-test** binding source code using git: ```bash git clone --recurse-submodules https://github.com/iotbzh/afb-test cd afb-test mkdir build cd build cmake .. && make ``` ## Launch the example To launch the binding use the command-line provided at the end of the build. This will launch the test of an Helloworld binding example. The code of the test is available from the LUA file `conf.d/project/lua.d/helloworld.lua`. The example will run some basics tests on API verb calls and events received. ```lua 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, {data = { key = 'weird others data', another_key = 123.456 }}) end _AFT.addEventToMonitor("hello/anEvent") _AFT.addEventToMonitor("hello/anotherEvent", _callbackEvent) _AFT.addLogToMonitor("hello", "warning", "verbose called for My Warning message!") _AFT.testVerbStatusSuccess('testPingSuccess','hello', 'ping', {}) _AFT.testVerbResponseEquals('testPingSuccess','hello', 'ping', {}, "Some String") _AFT.testVerbResponseEquals('testPingSuccess','hello', 'ping', {}, "Unexpected String") _AFT.testVerbCb('testPingSuccess','hello', 'ping', {}, _callback) _AFT.testVerbStatusError('testPingError', 'hello', 'pingfail', {}) _AFT.testVerbResponseEqualsError('testPingError', 'hello', 'pingfail', {}, "Ping Binder Daemon fails") _AFT.testVerbResponseEqualsError('testPingError', 'hello', 'pingfail', {}, "Ping Binder Daemon succeed") _AFT.testVerbCbError('testPingError', 'hello', 'pingfail', {}, _callbackError) _AFT.testVerbStatusSuccess('testEventAdd', 'hello', 'eventadd', {tag = 'event', name = 'anEvent'}) _AFT.testVerbStatusSuccess('testEventSub', 'hello', 'eventsub', {tag = 'event'}) _AFT.testVerbStatusSuccess('testEventPush', 'hello', 'eventpush', {tag = 'event', data = { key = 'some data', another_key = 123}}) _AFT.testVerbStatusSuccess('testEventAdd', 'hello', 'eventadd', {tag = 'evt', name = 'anotherEvent'}) _AFT.testVerbStatusSuccess('testEventSub', 'hello', 'eventsub', {tag = 'evt'}) _AFT.testVerbStatusSuccess('testEventPush', '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.testEvtReceived("testEvent", "hello/anEvent") _AFT.testEvtReceived("testEventCb", "hello/anotherEvent") _AFT.testLogReceived("LogReceived", "verbose called for My Warning message!") _AFT.testCustom("mytest", function() _AFT.assertEquals(false, false) end) ``` > **NOTE**: I suggest you to take this lua file example to make your own test > then read the following the chapter if needed to write more complicated tests. ```bash $ afb-daemon --name afbd-test --port=1234 --workdir=package --ldpaths=/opt/AGL/lib64/afb:lib --token= --tracereq=common --verbose NOTICE: Can't connect supervision socket to @urn:AGL:afs:supervision:socket: Connection refused NOTICE: [API hello] hello binding comes to live NOTICE: [API ave] dynamic binding AVE(ave) comes to live NOTICE: [API hi] dynamic binding AVE(hi) comes to live NOTICE: [API salut] dynamic binding AVE(salut) comes to live NOTICE: [API lib/test-binding.so] Controller in afbBindingVdyn NOTICE: [API lib/test-binding.so] Controller API='test' info='Binding made to tests other bindings' NOTICE: API monitor started HOOK: [xreq-000001:monitor/set] BEGIN HOOK: [xreq-000001:monitor/set] json() -> { "verbosity": "debug" } HOOK: [xreq-000001:monitor/set] success(null, (null)) HOOK: [xreq-000001:monitor/set] END HOOK: [xreq-000002:monitor/trace] BEGIN HOOK: [xreq-000002:monitor/trace] json() -> { "add": { "event": "push_after" } } HOOK: [xreq-000002:monitor/trace] subscribe(monitor/trace:1) -> 0 HOOK: [xreq-000002:monitor/trace] success(null, (null)) HOOK: [xreq-000002:monitor/trace] END HOOK: [xreq-000003:monitor/set] BEGIN HOOK: [xreq-000003:monitor/set] json() -> { "verbosity": "debug" } HOOK: [xreq-000003:monitor/set] success(null, (null)) HOOK: [xreq-000003:monitor/set] END HOOK: [xreq-000004:monitor/trace] BEGIN HOOK: [xreq-000004:monitor/trace] json() -> { "add": { "event": "push_after" } } HOOK: [xreq-000004:monitor/trace] subscribe(monitor/trace:1) -> 0 HOOK: [xreq-000004:monitor/trace] success(null, (null)) HOOK: [xreq-000004:monitor/trace] END # XML output to var/jUnitResults.xml # Started on Thu Jun 14 18:12:33 2018 # Starting test: testPingSuccess INFO: API hello starting... NOTICE: [API hello] hello binding starting NOTICE: API hello started HOOK: [xreq-000005:hello/ping] BEGIN HOOK: [xreq-000005:hello/ping] json() -> null HOOK: [xreq-000005:hello/ping] success("Some String", Ping Binder Daemon tag=pingSample count=1 query=null) HOOK: [xreq-000005:hello/ping] END # Starting test: testPingSuccess HOOK: [xreq-000006:hello/ping] BEGIN HOOK: [xreq-000006:hello/ping] json() -> null HOOK: [xreq-000006:hello/ping] success("Some String", Ping Binder Daemon tag=pingSample count=2 query=null) HOOK: [xreq-000006:hello/ping] END # Starting test: testPingSuccess HOOK: [xreq-000007:hello/ping] BEGIN HOOK: [xreq-000007:hello/ping] json() -> null HOOK: [xreq-000007:hello/ping] success("Some String", Ping Binder Daemon tag=pingSample count=3 query=null) HOOK: [xreq-000007:hello/ping] END # Failure: var//aft.lua:127: expected: "Unexpected String" # actual: "Some String" # Starting test: testPingSuccess HOOK: [xreq-000008:hello/ping] BEGIN HOOK: [xreq-000008:hello/ping] json() -> null HOOK: [xreq-000008:hello/ping] success("Some String", Ping Binder Daemon tag=pingSample count=4 query=null) HOOK: [xreq-000008:hello/ping] END # Starting test: testPingError HOOK: [xreq-000009:hello/pingfail] BEGIN HOOK: [xreq-000009:hello/pingfail] fail(failed, Ping Binder Daemon fails) HOOK: [xreq-000009:hello/pingfail] END # Starting test: testPingError HOOK: [xreq-000010:hello/pingfail] BEGIN HOOK: [xreq-000010:hello/pingfail] fail(failed, Ping Binder Daemon fails) HOOK: [xreq-000010:hello/pingfail] END # Failure: var//aft.lua:145: Received the not expected value: "Ping Binder Daemon fails" # Starting test: testPingError HOOK: [xreq-000011:hello/pingfail] BEGIN HOOK: [xreq-000011:hello/pingfail] fail(failed, Ping Binder Daemon fails) HOOK: [xreq-000011:hello/pingfail] END # Starting test: testPingError HOOK: [xreq-000012:hello/pingfail] BEGIN HOOK: [xreq-000012:hello/pingfail] fail(failed, Ping Binder Daemon fails) HOOK: [xreq-000012:hello/pingfail] END # Starting test: testEventAdd HOOK: [xreq-000013:hello/eventadd] BEGIN HOOK: [xreq-000013:hello/eventadd] get(tag) -> { name: tag, value: event, path: (null) } HOOK: [xreq-000013:hello/eventadd] get(name) -> { name: name, value: anEvent, path: (null) } HOOK: [xreq-000013:hello/eventadd] success(null, (null)) HOOK: [xreq-000013:hello/eventadd] END # Starting test: testEventSub HOOK: [xreq-000014:hello/eventsub] BEGIN HOOK: [xreq-000014:hello/eventsub] get(tag) -> { name: tag, value: event, path: (null) } HOOK: [xreq-000014:hello/eventsub] subscribe(
## Introduction

The `meta-agl-demo` layer is the reference user interface layer for the DEMO
platform of Automotive Grade Linux (AGL).
The layer provides a reference platform and applications.
The BitBake target name for the DEMO platform is `agl-demo-platform`, which is
the full DEMO platform image.

## Layer Dependencies

This section describes dependencies for the `meta-agl-demo` layer.
Dependencies are grouped into base, hardware, and feature dependencies.

### Base Dependencies

The `meta-agl-demo` layer has the following base dependencies:

* Yocto Project Release:

  - URI: git://git.yoctoproject.org/poky
  - Branch: "dunfell"
  - Tested Revision: See the [`default.xml`](https://github.com/leon-anavi/AGL-repo/blob/master/default.xml)
    manifest file for the `AGL-repo` repository for revision
    information.<br/><br/>

* AGL `meta-agl` Layer:

  - URI: https://gerrit.automotivelinux.org/gerrit/AGL/meta-agl
  - Branch: "master"<br/><br/>

* OpenEmbedded `meta-openembedded` Layer:

  - Branch: "thud"
  - Tested Revision: See the [`default.xml`](https://github.com/leon-anavi/AGL-repo/blob/master/default.xml)
    manifest file for the `AGL-repo` repository for revision
    information.

    Specifically, out of `meta-openembedded`, these sub-layers are used:

    - `meta-oe`
    - `meta-multimedia`
    - `meta-networking`
    - `meta-python`<br/><br/>

* Yocto Project `meta-qt5` Layer from the
  [OpenEmbedded Layer Index](https://layers.openembedded.org/layerindex/branch/master/layers/):

  - URI: https://github.com/meta-qt5/meta-qt5.git
  - Branch:   "dunfell"
  - Tested Revision: See the [`default.xml`](https://github.com/leon-anavi/AGL-repo/blob/master/default.xml)
    manifest file for the `AGL-repo` repository for revision
    information.<br/><br/>


### Feature Dependencies

The `meta-agl-demo` layer has the following AGL
[feature](../getting_started/reference/getting-started/image-workflow-initialize-build-environment.html#agl-features)
dependencies:

* Yocto Project `meta-security` Layer:

  - URI: https://git.yoctoproject.org/cgit/cgit.cgi/meta-security
  - Branch: "master"
  - Tested Revision: See the [`default.xml`](https://github.com/leon-anavi/AGL-repo/blob/master/default.xml)
    manifest file for the `AGL-repo` repository for revision
    information.<br/><br/>

* AGL's `meta-app-framework` Layer within the `meta-agl` Layer:

  - URI: https://gerrit.automotivelinux.org/gerrit/gitweb?p=AGL/meta-agl.git
  - Branch: "master"<br/><br/>

**The `agl-sota` Feature:**

* Here Technologies' `meta-updater` Layer:

  - URI: https://github.com/advancedtelematic/meta-updater/
  - Branch: "dunfell"<br/><br/>

* Here Technologies' `meta-updater-qemux86-64` Layer:

  - URI: https://github.com/advancedtelematic/meta-updater-qemux86-64/
  - Branch: "dunfell"<br/><br/>

* OpenEmbedded's `meta-openembedded` Layer:

  - URI: https://github.com/openembedded/meta-openembedded
  - Branch: "dunfell"
  - Tested Revision: See the [`default.xml`](https://github.com/leon-anavi/AGL-repo/blob/master/default.xml)
    manifest file for the `AGL-repo` repository for revision
    information.

    Specifically, out of `meta-openembedded`, these sub-layers are used:

    - `meta-filesystems`
    - `meta-oe`
    - `meta-python`<br/><br/>

**The `agl-netboot` Feature:**

* AGL's `meta-netboot` Layer within the `meta-agl` Layer:

  - URI: https://gerrit.automotivelinux.org/gerrit/gitweb?p=AGL/meta-agl.git
  - Branch: "master"
hat it yields *minus infinity* . If provided, *extra_msg* is a string which will be printed along with the failure message. Be careful when dealing with *+0* and *-0* ##### String assertions Assertions related to string and patterns. * **_AFT.assertStrContains(str, sub[, useRe])** Assert that a string contains the given substring or pattern. By default, substring is searched in the string. If useRe is provided and is true, sub is treated as a pattern which is searched inside the string str . * **_AFT.assertStrIContains(str, sub)** Assert that a string contains the given substring, irrespective of the case. Not that unlike assertStrcontains(), you can not search for a pattern. * **_AFT.assertNotStrContains(str, sub, useRe)** Assert that a string does not contain a given substring or pattern. By default, substring is searched in the string. If useRe is provided and is true, sub is treated as a pattern which is searched inside the string str . * **_AFT.assertNotStrIContains(str, sub)** Assert that a string does not contain the given substring, irrespective of the case. Not that unlike assertNotStrcontains(), you can not search for a pattern. * **_AFT.assertStrMatches(str, pattern[, start[, final]])** Assert that a string matches the full pattern pattern. If start and final are not provided or are nil, the pattern must match the full string, from start to end. The functions allows to specify the expected start and end position of the pattern in the string. ##### Error assertions Error related assertions, to verify error generation and error messages. * **_AFT.assertError(func, ...)** Assert that calling functions func with the arguments yields an error. If the function does not yield an error, the assertion fails. Note that the error message itself is not checked, which means that this function does not distinguish between the legitimate error that you expect and another error that might be triggered by mistake. The next functions provide a better approach to error testing, by checking explicitly the error message content. >**Note** >When testing LuaUnit, switching from assertError() to assertErrorMsgEquals() revealed quite a few bugs! * **_AFT.assertErrorMsgEquals(expectedMsg, func, ...)** Assert that calling function func will generate exactly the given error message. If the function does not yield an error, or if the error message is not identical, the assertion fails. Be careful when using this function that error messages usually contain the file name and line number information of where the error was generated. This is usually inconvenient. To ignore the filename and line number information, you can either use a pattern with assertErrorMsgMatches() or simply check for the message containt with assertErrorMsgContains() . * **_AFT.assertErrorMsgContains(partialMsg, func, ...)** Assert that calling function func will generate an error message containing partialMsg . If the function does not yield an error, or if the expected message is not contained in the error message, the assertion fails. * **_AFT.assertErrorMsgMatches(expectedPattern, func, ...)** Assert that calling function func will generate an error message matching expectedPattern . If the function does not yield an error, or if the error message does not match the provided patternm the assertion fails. Note that matching is done from the start to the end of the error message. Be sure to escape magic all magic characters with % (like -+.?\*) . ##### Type assertions The following functions all perform type checking on their argument. If the received value is not of the right type, the failure message will contain the expected type, the received type and the received value to help you identify better the problem. * **_AFT.assertIsNumber(value)** Assert that the argument is a number (integer or float) * **_AFT.assertIsString(value)** Assert that the argument is a string. * **_AFT.assertIsTable(value)** Assert that the argument is a table. * **_AFT.assertIsBoolean(value)** Assert that the argument is a boolean. * **_AFT.assertIsFunction(value)** Assert that the argument is a function. * **_AFT.assertIsUserdata(value)** Assert that the argument is a userdata. * **_AFT.assertIsThread(value)** Assert that the argument is a coroutine (an object with type thread ). * **_AFT.assertNotIsThread(value)** Assert that the argument is a not coroutine (an object with type thread ). ##### Table assertions * **_AFT.assertItemsEquals(actual, expected)** Assert that two tables contain the same items, irrespective of their keys. This function is practical for example if you want to compare two lists but where items are not in the same order: `luaunit.assertItemsEquals( {1,2,3}, {3,2,1} ) -- assertion succeeds` The comparison is not recursive on the items: if any of the items are tables, they are compared using table equality (like as in assertEquals() ), where the key matters. `luaunit.assertItemsEquals( {1,{2,3},4}, {4,{3,2,},1} ) -- assertion fails because {2,3} ~= {3,2}`