diff options
author | Corentin Le Gall <corentinlgs@gmail.com> | 2018-07-19 15:57:30 +0200 |
---|---|---|
committer | Corentin Le Gall <corentinlgs@gmail.com> | 2018-07-24 14:42:12 +0200 |
commit | c96df58a88b60c7501b3c8a758c0277c17088371 (patch) | |
tree | 1e982c565a4fd0ba65a382cc1cba97efe891c34b /docs | |
parent | 55673d50338f041763e6e38f38ea3fc311f2bdc1 (diff) |
Changed doc to GitBook format + added doc
-Changed README.md to a complet GitBook doc.
-Added explanations about EvtGrpReceived functions.
-Corrected mistakes + reduced lines length.
Change-Id: I1a077ddf6acb520a9158de658d3c09b12a2029d4
Signed-off-by: Corentin Le Gall <corentinlgs@gmail.com>
Diffstat (limited to 'docs')
31 files changed, 1739 insertions, 0 deletions
diff --git a/docs/0_Installation.md b/docs/0_Installation.md new file mode 100644 index 0000000..e81c718 --- /dev/null +++ b/docs/0_Installation.md @@ -0,0 +1,37 @@ +# 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: + +```shell +git clone --recurse-submodules https://gerrit.automotivelinux.org/gerrit/apps/app-afb-test +cd afb-test +mkdir build +cd build +cmake .. && make +```
\ No newline at end of file diff --git a/docs/1_TestExample.md b/docs/1_TestExample.md new file mode 100644 index 0000000..6522def --- /dev/null +++ b/docs/1_TestExample.md @@ -0,0 +1,108 @@ +# Test example + +To launch the binding use the command-line provided at the end of the build, +and the afb-daemon-demo just like in the example below. This will launch the +test of an Helloworld binding example. Tests's codes are available in the LUA +files `conf.d/controller/lua.d/helloworld.lua` and +`conf.d/controller/lua.d/aftTest.lua`. + +The example will run some basics tests on API verb calls and events received. + +## helloworld.lua + +```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.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.testEvtGrpReceived("TestEventGroupReceived",{"hello/anEvent","hello/anotherEvent"},300000) + _AFT.testEvtGrpNotReceived("TestEventGroupNotReceived",{"hello/anEvent","hello/anotherEvent"},300000) + + _AFT.testEvtReceived("testEvent", "hello/anEvent",300000) + _AFT.testEvtReceived("testEventCb", "hello/anotherEvent",300000) + + _AFT.testCustom("mytest", function() + _AFT.assertEquals(false, false) + end) +``` + +## aftTest.lua + +```lua + +_AFT.setBeforeEach(function() print("~~~~~ Begin Test ~~~~~") end) +_AFT.setAfterEach(function() print("~~~~~ End Test ~~~~~") end) + +_AFT.setBeforeAll(function() print("~~~~~~~~~~ BEGIN ALL TESTS ~~~~~~~~~~") return 0 end) +_AFT.setAfterAll(function() print("~~~~~~~~~~ END ALL TESTS ~~~~~~~~~~") return 0 end) + + +local corout = coroutine.create( print ) + +_AFT.describe("testAssertEquals", function() _AFT.assertEquals(false, false) end, + function() print("~~~~~ Begin Test Assert Equals ~~~~~") end, + function() print("~~~~~ End Test Assert Equals ~~~~~") end) + +_AFT.describe("testAssertNotEquals", function() _AFT.assertNotEquals(true,false) end) +_AFT.describe("testAssertItemsEquals", function() _AFT.assertItemsEquals({1,2,3},{3,1,2}) end) +_AFT.describe("testAssertAlmostEquals", function() _AFT.assertAlmostEquals(1.25 ,1.5,0.5) end) +_AFT.describe("testAssertNotAlmostEquals", function() _AFT.assertNotAlmostEquals(1.25,1.5,0.125) end) +_AFT.describe("testAssertEvalToTrue", function() _AFT.assertEvalToTrue(true) end) +_AFT.describe("testAssertEvalToFalse", function() _AFT.assertEvalToFalse(false) end) + +_AFT.describe("testAssertStrContains", function() _AFT.assertStrContains("Hello I'm a string","string") end) +_AFT.describe("testAssertStrContains", function() _AFT.assertStrContains("Hello I'm a second string","second",5) end) + +_AFT.describe("testAssertStrIContains", function() _AFT.assertStrIContains("Hello I'm another string","I'm") end) + +_AFT.describe("testAssertNotStrContains", function() _AFT.assertNotStrContains("Hello it's me again, the other string","banana") end) +_AFT.describe("testAssertNotStrContains", function() _AFT.assertNotStrContains("Hello it's me again, the other string","banana",8) end) +... +... +... +_AFT.describe("testAssertNotIsUserdata", function() _AFT.assertNotIsUserdata(2) end) + + +function _callback(responseJ) _AFT.assertStrContains(responseJ.response, "Some String") end +function _callbackError(responseJ) _AFT.assertStrContains(responseJ.request.info, "Ping Binder Daemon fails") end + +_AFT.describe("testAssertVerbStatusSuccess",function() _AFT.assertVerbStatusSuccess('hello', 'ping', {}) end) +_AFT.describe("testAssertVerbResponseEquals",function() _AFT.assertVerbResponseEquals('hello', 'ping', {},"Some String") end) +_AFT.describe("testAssertVerbCb",function() _AFT.assertVerbCb('hello', 'ping', {},_callback) end) +_AFT.describe("testAssertVerbStatusError",function() _AFT.assertVerbStatusError('hello', 'pingfail', {}) end) +_AFT.describe("testAssertVerbResponseEqualsError",function() _AFT.assertVerbResponseEqualsError('hello', 'pingfail', {},"Ping Binder Daemon fails") end) +_AFT.describe("testAssertVerbCbError",function() _AFT.assertVerbCbError('hello', 'pingfail', {},_callbackError) 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.
\ No newline at end of file diff --git a/docs/2_LaunchTheExample.md b/docs/2_LaunchTheExample.md new file mode 100644 index 0000000..2186d53 --- /dev/null +++ b/docs/2_LaunchTheExample.md @@ -0,0 +1,147 @@ +# Launch The Example + +To launch your tests, enter this command. + +```bash +afb-daemon --name afbd-test --port=1234 --workdir=package --ldpaths=/opt/AGL/lib64/afb:lib --token= -vvv --tracereq=common +``` + +On afb-daemon startup you should have all the app-framework config displayed: + +```shell +---BEGIN-OF-CONFIG--- +-- console: ./AFB-console.out +-- rootdir: . +-- roothttp: +-- rootbase: /opa +-- rootapi: /api +-- workdir: . +-- uploaddir: . +-- token: 1 +-- name: afbd-test +-- aliases: +-- dbus_clients: +-- dbus_servers: +-- ws_clients: +-- ws_servers: +-- so_bindings: +-- ldpaths: /opt/AGL/lib64/afb:lib +-- weak_ldpaths: +-- calls: +-- exec: +-- httpdPort: 1234 +-- cacheTimeout: 100000 +-- apiTimeout: 20 +-- cntxTimeout: 32000000 +-- nbSessionMax: 10 +-- mode: local +-- tracereq: common +-- traceditf: no +-- tracesvc: no +-- traceevt: no +-- no_ldpaths: no +-- noHttpd: no +-- background: no +-- monitoring: no +-- random_token: no +---END-OF-CONFIG--- +INFO: entering foreground mode +INFO: running with pid 20430 +INFO: API monitor added +INFO: binding monitor added to set main +INFO: Scanning dir=[/opt/AGL/lib64/afb] for bindings +INFO: binding [/opt/AGL/lib64/afb/demoContext.so] is a valid AFB binding V1 +INFO: binding [/opt/AGL/lib64/afb/demoContext.so] calling registering function afbBindingV1Register +INFO: API context added +INFO: binding /opt/AGL/lib64/afb/demoContext.so loaded with API prefix context +INFO: binding [/opt/AGL/lib64/afb/helloWorld.so] looks like an AFB binding V2 +INFO: binding hello calling preinit function +NOTICE: [API hello] hello binding comes to live +INFO: API hello added +INFO: binding hello added to set main +INFO: binding [/opt/AGL/lib64/afb/tic-tac-toe.so] looks like an AFB binding V2 +INFO: API tictactoe added +INFO: binding tictactoe added to set main +INFO: binding [/opt/AGL/lib64/afb/demoPost.so] is a valid AFB binding V1 +INFO: binding [/opt/AGL/lib64/afb/demoPost.so] calling registering function afbBindingV1Register +INFO: API post added +INFO: binding /opt/AGL/lib64/afb/demoPost.so loaded with API prefix post +INFO: binding [/opt/AGL/lib64/afb/ave.so] looks like an AFB binding Vdyn +... +... +... +NOTICE: API salut started +INFO: API tictactoe starting... +NOTICE: API tictactoe started +NOTICE: Waiting port=1234 rootdir=. +NOTICE: Browser URL= http://localhost:1234 +``` + +Then in a new terminal launch the client: + +``` bash +afb-client-demo ws://localhost:1234/api?token=1 +afTest launch_all_tests +``` + +You should get something like: + +``` bash +{"response":{"info":"Launching tests"},"jtype":"afb-reply","request":{"status":"success","uuid":"3fa17ce6-0029-4ef9-8e0d-38dba2a9cf38"}} +{"event":"afTest\/results","data":{"info":"Success : 72 Failures : 6"},"jtype":"afb-event"} +``` + +Here you can see that the verb succeeded and that we have 71 Success for 5 failures. + +And on your afb-daemon terminal you have all information about your tests step-by-step (note that it depends on the level of verbosity you gave to the afb-daemon (-vvv option)). + +```shell +DEBUG: received websocket request for afTest/launch_all_tests: null +HOOK: [xreq-000001:afTest/launch_all_tests] BEGIN +HOOK: [xreq-000001:afTest/launch_all_tests] json() -> "null" +HOOK: [xreq-000002:monitor/set] BEGIN +HOOK: [xreq-000002:monitor/set] reply[denied](null, invalid token's identity) +HOOK: [xreq-000002:monitor/set] END +HOOK: [xreq-000003:monitor/trace] BEGIN +HOOK: [xreq-000003:monitor/trace] reply[denied](null, invalid token's identity) +HOOK: [xreq-000003:monitor/trace] END +~~~~~ Begin Test ~~~~~ +~~~~~ End Test ~~~~~ +... +... +... +~~~~~ Begin Test ~~~~~ +~~~~~ End Test ~~~~~ +~~~~~~~~~~ BEGIN ALL TESTS ~~~~~~~~~~ +HOOK: [xreq-000001:afTest/launch_all_tests] reply[success]({ "info": "Launching tests" }, (null)) +# XML output to var/jUnitResults.xml +# Started on Wed Jul 11 15:42:44 2018 +# Starting class: testPingSuccess +# Starting test: testPingSuccess.testFunction +~~~~~ Begin testPingSuccess ~~~~~ +HOOK: [xreq-000004:hello/ping] BEGIN +HOOK: [xreq-000004:hello/ping] json() -> null +HOOK: [xreq-000004:hello/ping] reply[success]("Some String", Ping Binder Daemon tag=pingSample count=1 query=null) +HOOK: [xreq-000004:hello/ping] END +~~~~~ End testPingSuccess ~~~~~ +# Starting class: testPingSuccessAndResponse +# Starting test: testPingSuccessAndResponse.testFunction +HOOK: [xreq-000005:hello/ping] BEGIN +HOOK: [xreq-000005:hello/ping] json() -> null +HOOK: [xreq-000005:hello/ping] reply[success]("Some String", Ping Binder Daemon tag=pingSample count=2 query=null) +HOOK: [xreq-000005:hello/ping] END +# Starting class: testPingSuccessResponseFail +# Starting test: testPingSuccessResponseFail.testFunction +HOOK: [xreq-000006:hello/ping] BEGIN +HOOK: [xreq-000006:hello/ping] json() -> null +HOOK: [xreq-000006:hello/ping] reply[success]("Some String", Ping Binder Daemon tag=pingSample count=3 query=null) +HOOK: [xreq-000006:hello/ping] END +# Failure: ./var/aft.lua:224: expected: "Unexpected String" +# actual: "Some String" +... +... +... +~~~~~~~~~~ END ALL TESTS ~~~~~~~~~~ +HOOK: [xreq-000001:afTest/launch_all_tests] END + +```
\ No newline at end of file diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 0000000..229ce8e --- /dev/null +++ b/docs/README.md @@ -0,0 +1,21 @@ +# Introduction + +This document explains how to setup and write your tests. + +<br> +<br> +<br> +<br> +<br> + +| *Meta* | *Data* | +| -- | -- | +| **Title** | {{ config.title }} | +| **Author** | {{ config.author }} | +| **Description** | {{ config.description }} | +| **Keywords** | {{ config.keywords }} | +| **Language** | English | +| **Published** | Published {{ config.published }} as an electronic book | +| **Updated** | {{ gitbook.time }} | +| **Collection** | Open-source | +| **Website** | [{{ config.website }}]({{ config.website }}) | diff --git a/docs/SUMMARY.md b/docs/SUMMARY.md new file mode 100644 index 0000000..cc5e57a --- /dev/null +++ b/docs/SUMMARY.md @@ -0,0 +1,24 @@ +# Summary + +* [Installation](0_Installation.md) + +* [Test example](1_TestExample.md) + +* [Launch the example](2_LaunchTheExample.md) + +* [Write your tests](WriteYourTests/Introduction.md) + * [Project Tree](WriteYourTests/0_ProjectTree.md) + * [Binding configuration](WriteYourTests/1_BindingConfiguration.md) + * [LUA test files](WriteYourTests/2_LUATestFiles.md) + * [References](WriteYourTests/Reference/Introduction.md) + * [Binding test functions](WriteYourTests/Reference/0_BindingTestFunctions.md) + * [Binding assert functions](WriteYourTests/Reference/1_BindingAssertFunctions.md) + * [Test framework functions](WriteYourTests/Reference/2_TestFrameworkFunctions.md) + * [LUAUnit assertion functions](WriteYourTests/Reference/LuaUnitAssertionFunctions/Introduction.md) + * [General Assertions](WriteYourTests/Reference/LuaUnitAssertionFunctions/0_GeneralAssertions.md) + * [Value Assertions](WriteYourTests/Reference/LuaUnitAssertionFunctions/1_ValueAssertions.md) + * [Scientific Assertions](WriteYourTests/Reference/LuaUnitAssertionFunctions/2_ScientificAssertions.md) + * [String Assertions](WriteYourTests/Reference/LuaUnitAssertionFunctions/3_StringAssertions.md) + * [Error Assertions](WriteYourTests/Reference/LuaUnitAssertionFunctions/4_ErrorAssertions.md) + * [Type Assertions](WriteYourTests/Reference/LuaUnitAssertionFunctions/5_TypeAssertions.md) + * [Table Assertions](WriteYourTests/Reference/LuaUnitAssertionFunctions/6_TableAssertions.md)
\ No newline at end of file diff --git a/docs/WriteYourTests/0_ProjectTree.md b/docs/WriteYourTests/0_ProjectTree.md new file mode 100644 index 0000000..e23c834 --- /dev/null +++ b/docs/WriteYourTests/0_ProjectTree.md @@ -0,0 +1,37 @@ +# afb-test architecture + +```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 +``` + +To write your tests we will only touch to the **controller** folder, specifically +to the **lua.d** and to the **etc** folders. + +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 diff --git a/docs/WriteYourTests/1_BindingConfiguration.md b/docs/WriteYourTests/1_BindingConfiguration.md new file mode 100644 index 0000000..9980357 --- /dev/null +++ b/docs/WriteYourTests/1_BindingConfiguration.md @@ -0,0 +1,38 @@ +# Binding configuration + +The file `aft-test.json` contains the controller binding configuration. Here, +you have to change or define the *files* key in the *args* object of the +*testVerb* section, *testVerb* is an array of verb definition which are +meant to launch different LUA test files. + +Also you MUST specify which *api* you need to trace to perform your tests. +Specify which api to trace using a pattern. + +Edit the JSON array to point to your tests files. + +Here is an example: + +```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": "afTest", + "info": "Binding made to test other bindings", + "require": [ + "hello" + ] + }, + "testVerb": { + "uid": "launch_all_tests", + "info": "Launch all the tests", + "action": "lua://AFT#_launch_test", + "args": { + "trace": "hello", + "files": ["aftTest.lua","helloworld.lua"] + } + } +} +```
\ No newline at end of file diff --git a/docs/WriteYourTests/2_LUATestFiles.md b/docs/WriteYourTests/2_LUATestFiles.md new file mode 100644 index 0000000..377b8f2 --- /dev/null +++ b/docs/WriteYourTests/2_LUATestFiles.md @@ -0,0 +1,17 @@ +# LUA Test files + +First, ensure that you put your LUA tests files in the `lua.d` directory. + +You have two differents things to take in account when you'll write your tests +using this framework: *test* and *assertions*. + +*Assertions* are functions meant to test an atomic operation result. +(ie: `1+1 = 2` is an assertion) + +*Test* functions represent a test (Unbelievable), they represent a set of one or +several *assertions* which are all needed to succeed to valid the test. + +The framework came with several *test* and *assertion* functions to simply be +able to test verb calls and events receiving. Use the simple one as often as +possible and if you need more use the one that calls a callback. Specifying a +callback let you add assertions and enrich the test.
\ No newline at end of file diff --git a/docs/WriteYourTests/Introduction.md b/docs/WriteYourTests/Introduction.md new file mode 100644 index 0000000..a8b457b --- /dev/null +++ b/docs/WriteYourTests/Introduction.md @@ -0,0 +1,10 @@ +# Write your test + +Follow this section to know how to write your test. + +Section's Table of content : + +* [Project Tree](0_ProjectTree.html) +* [Binding configuration](1_BindingConfiguration.html) +* [LUA test files](2_LUATestFiles.html) +* [References](Reference/Introduction.html) diff --git a/docs/WriteYourTests/Reference/0_BindingTestFunctions.md b/docs/WriteYourTests/Reference/0_BindingTestFunctions.md new file mode 100644 index 0000000..da8f014 --- /dev/null +++ b/docs/WriteYourTests/Reference/0_BindingTestFunctions.md @@ -0,0 +1,102 @@ +# Binding Test functions + +* **_AFT.testVerbStatusSuccess(testName, api, verb, args, setUp, tearDown)** + + Simply test that the call of a verb successfully returns. + + *setUp* and *tearDown* are functions that can be added to your context, + it works just like **_AFT.beforeEach()** and **_AFT.afterEach()**, + *setUp* will be ran before your *testFunction* and **_AFT.beforeEach()** + (if set) functions, *tearDown* will be ran after your *testFunction* and + **_AFT.afterEach()** (if set) functions. + +* **_AFT.testVerbStatusError(testName, api, verb, args, setUp, tearDown)** + + The inverse than above. + + *setUp* and *tearDown* are functions that can be added to your context, + it works just like **_AFT.beforeEach()** and **_AFT.afterEach()**, + *setUp* will be ran before your *testFunction* and **_AFT.beforeEach()** + (if set) functions, *tearDown* will be ran after your *testFunction* and + **_AFT.afterEach()** (if set) functions. + +* **_AFT.testVerbResponseEquals(testName, api, verb, args, expectedResponse, setUp, tearDown)** + + Test that the call of a verb successfully returns and that verb's response + is equals to the *expectedResponse*. + + *setUp* and *tearDown* are functions that can be added to your context, + it works just like **_AFT.beforeEach()** and **_AFT.afterEach()**, *setUp* + will be ran before your *testFunction* and **_AFT.beforeEach()** (if set) + functions, *tearDown* will be ran after your *testFunction* and + **_AFT.afterEach()** (if set) functions. + +* **_AFT.testVerbResponseEqualsError(testName, api, verb, args, expectedResponse, setUp, tearDown)** + + The inverse than above. + + *setUp* and *tearDown* are functions that can be added to your context, it works + just like **_AFT.beforeEach()** and **_AFT.afterEach()**, *setUp* will be ran + before your *testFunction* and **_AFT.beforeEach()** (if set) functions, + *tearDown* will be ran after your *testFunction* and **_AFT.afterEach()** (if + set) functions. + +* **_AFT.testVerbCb(testName, api, verb, args, expectedResponse, callback, setUp, tearDown)** + + Test the call of a verb with a custom callback. From this callback you + will need to make some assertions on what you need (verb JSON return object + content mainly). + + If you don't need to test the response simply specify an empty LUA table. + + *setUp* and *tearDown* are functions that can be added to your context, it works + just like **_AFT.beforeEach()** and **_AFT.afterEach()**, *setUp* will be ran + before your *testFunction* and **_AFT.beforeEach()** (if set) functions, + *tearDown* will be ran after your *testFunction* and **_AFT.afterEach()** (if + set) functions. + +* **_AFT.testVerbCbError(testName, api, verb, args, expectedResponse, callback, setUp, tearDown)** + + Should return success on failure. + + *setUp* and *tearDown* are functions that can be added to your context, it works + just like **_AFT.beforeEach()** and **_AFT.afterEach()**, *setUp* will be ran + before your *testFunction* and **_AFT.beforeEach()** (if set) functions, + *tearDown* will be ran after your *testFunction* and **_AFT.afterEach()** (if + set) functions. + +* **_AFT.testEvtReceived(testName, eventName, timeout, setUp, tearDown)** + + Prior to be able to check that an event has been received, you have to + register the event with the test framework using **_AFT.addEventToMonitor** + function. + + Check if an event has been correctly received in time (timeout in µs). An event + name use the application framework naming scheme: **api/event_name**. + +* **_AFT.testEvtNotReceived(testName, eventName, timeout, setUp, tearDown)** + + Prior to be able to check that an event has not been received, you have to + register the event with the test framework using **_AFT.addEventToMonitor** + function. + + Check if an event has not been correctly received in time (timeout in µs). An + event name use the application framework naming scheme: **api/event_name**. + +* **_AFT.testGrpEvtReceived(testName, eventGrp, timeout, setUp, tearDown)** + + Prior to be able to check that a group of event (a table of event) has been + received, you have to register the event with the test framework using + **_AFT.addEventToMonitor** function. + + Check if events has been correctly received in time (timeout in µs). An + event name use the application framework naming scheme: **api/event_name**. + +* **_AFT.testGrpEvtNotReceived(testName, eventGrp, timeout, setUp, tearDown)** + + Prior to be able to check that a group of event (a table of event) has not + been received, you have to register the event with the test framework using + **_AFT.addEventToMonitor** function. + + Check if event has not been correctly received in time (timeout in µs). An + event name use the application framework naming scheme: **api/event_name**.
\ No newline at end of file diff --git a/docs/WriteYourTests/Reference/1_BindingAssertFunctions.md b/docs/WriteYourTests/Reference/1_BindingAssertFunctions.md new file mode 100644 index 0000000..1202976 --- /dev/null +++ b/docs/WriteYourTests/Reference/1_BindingAssertFunctions.md @@ -0,0 +1,66 @@ +# Binding Assert functions + +* **_AFT.assertVerbStatusSuccess(api, verb, args)** + + Simply test that the call of a verb successfully returns. + +* **_AFT.assertVerbStatusError(api, verb, args)** + + The inverse than above. + +* **_AFT.assertVerbResponseEquals(api, verb, args, expectedResponse)** + + Test that the call of a verb successfully returns and that verb's response + is equals to the *expectedResponse*. + +* **_AFT.assertVerbResponseEqualsError(api, verb, args, expectedResponse)** + + The inverse than above. + +* **_AFT.assertVerbCb(api, verb, args, expectedResponse, callback)** + + Test the call of a verb with a custom callback. From this callback you + will need to make some assertions on what you need (verb JSON return object + content mainly). + + If you don't need to test the response simply specify an empty LUA table. + +* **_AFT.assertVerbCbError(api, verb, args, expectedResponse, callback)** + + Should return success on failure. + +* **_AFT.assertEvtReceived(eventName, timeout)** + + Prior to be able to check that an event has been received, you have to + register the event with the test framework using **_AFT.addEventToMonitor** + function. + + Check if an event has been correctly received in time (timeout in µs). + An event name use the application framework naming scheme: **api/event_name**. + +* **_AFT.assertEvtNotReceived(eventName, timeout)** + + Prior to be able to check that an event has been received, you have to + register the event with the test framework using **_AFT.addEventToMonitor** + function. + + Check if an event has been correctly received in time (timeout in µs). + An event name use the application framework naming scheme: **api/event_name**. + +* **_AFT.assertGrpEvtReceived(eventGrp, timeout)** + + Prior to be able to check that a group of event (a table of event) has been + received, you have to register the event with the test framework using + **_AFT.addEventToMonitor** function. + + Check if events has been correctly received in time (timeout in µs). + An event name use the application framework naming scheme: **api/event_name**. + +* **_AFT.assertGrpEvtNotReceived(eventGrp, timeout)** + + Prior to be able to check that a group of event (a table of event) has not + been received, you have to register the event with the test framework using + **_AFT.addEventToMonitor** function. + + Check if events has not been correctly received in time (timeout in µs). + An event name use the application framework naming scheme: **api/event_name**.
\ No newline at end of file diff --git a/docs/WriteYourTests/Reference/2_TestFrameworkFunctions.md b/docs/WriteYourTests/Reference/2_TestFrameworkFunctions.md new file mode 100644 index 0000000..20184ec --- /dev/null +++ b/docs/WriteYourTests/Reference/2_TestFrameworkFunctions.md @@ -0,0 +1,59 @@ +# Test Framework functions + +* **_AFT.addEventToMonitor(eventName, callback)** + + Add a binding event in the test framework to be able to assert its reception + . You'll need to add as much as events you expect to receive. You could also + specify a callback to test deeper that the event is as you want to. The + callback will happens after the assertion that it has been received so you + can work on data that the event eventually carry. + +* **_AFT.setJunitFile(filePath)** + + Set the *JUnit* file path. When *JUnit* is set as the output type for the + test framework. + +* **_AFT.setBeforeEach(function)** + + Set the **_AFT.beforeEach()** function which is used to run the *function* + before each tests. + +* **_AFT.setAfterEach(function)** + + Set the **_AFT.afterEach()** function which is used to run the *function* + after each tests. + +* **_AFT.setBeforeAll(function)** + + Set the **_AFT.beforeAll()** function which is used to run the *function* + before all tests. If the given function is successful it has to return 0 + else it will return an error. + +* **_AFT.setAfterAll(function)** + + Set the **_AFT.afterAll()** function which is used to run the *function* + after all tests. If the given function is successful it has to return 0 + else it will return an error. + +* **_AFT.describe(testName, testFunction, setUp, tearDown)** + + Give a context to a custom test. *testFunction* will be given the name + provided by *testName* and will be tested. + + *setUp* and *tearDown* are functions that can be added to your context, + it works just like **_AFT.beforeEach()** and **_AFT.afterEach()**, + *setUp* will be ran before your *testFunction* and **_AFT.beforeEach()** + (if set) functions, *tearDown* will be ran after your *testFunction* and + **_AFT.afterEach()** (if set) functions. + +* **_AFT.setBefore(testName, beforeTestFunction)** + Set a function to be ran at the beginning of the given *testName* function. + + ```lua + _AFT.testVerbStatusSuccess('testPingSuccess','hello', 'ping', {}) + _AFT.setBefore("testPingSuccess",function() print("~~~~~ Begin testPingSuccess ~~~~~") end) + _AFT.setAfter("testPingSuccess",function() print("~~~~~ End testPingSuccess ~~~~~") end) + ``` + +* **_AFT.setBefore(testName, beforeTestFunction)** + Set a function to be ran at the end of the given *testName* function.
\ No newline at end of file diff --git a/docs/WriteYourTests/Reference/Introduction.md b/docs/WriteYourTests/Reference/Introduction.md new file mode 100644 index 0000000..8de5a15 --- /dev/null +++ b/docs/WriteYourTests/Reference/Introduction.md @@ -0,0 +1,10 @@ +# References + +Follow this section to know which functions are available !! + +Section's Table of content : + +* [Binding test functions](0_BindingTestFunctions.html) +* [Binding assert functions](1_BindingAssertFunctions.html) +* [Test framework functions](2_TestFrameworkFunctions.html) +* [LUAUnit assertion functions](LuaUnitAssertionFunctions/Introduction.html)
\ No newline at end of file diff --git a/docs/WriteYourTests/Reference/LuaUnitAssertionFunctions/0_GeneralAssertions.md b/docs/WriteYourTests/Reference/LuaUnitAssertionFunctions/0_GeneralAssertions.md new file mode 100644 index 0000000..4a719b6 --- /dev/null +++ b/docs/WriteYourTests/Reference/LuaUnitAssertionFunctions/0_GeneralAssertions.md @@ -0,0 +1,32 @@ +# General Assertions + +* **_AFT.assertEquals(actual, expected)** + + Assert that two values are equal. + + For tables, the comparison is a deep comparison : + + * number of elements must be the same + * tables must contain the same keys + * each key must contain the same values. The values are also compared recursively with deep comparison. + + LuaUnit provides other table-related assertions, see [Table assertions](http://luaunit.readthedocs.io/en/luaunit_v3_2_1/#assert-table) + +* **_AFT.assertNotEquals(actual, expected)** + + Assert that two values are different. The assertion fails if the two values are identical. + + It also uses table deep comparison. + +* **_AFT.assertAlmostEquals(actual, expected, margin)** + + Assert that two floating point numbers are almost equal. + + When comparing floating point numbers, strict equality does not work. + Computer arithmetic is so that an operation that mathematically yields + 1.00000000 might yield 0.999999999999 in lua . That’s why you need an + almost equals comparison, where you specify the error margin. + +* **_AFT.assertNotAlmostEquals(actual, expected, margin)** + + Assert that two floating point numbers are not almost equal.
\ No newline at end of file diff --git a/docs/WriteYourTests/Reference/LuaUnitAssertionFunctions/1_ValueAssertions.md b/docs/WriteYourTests/Reference/LuaUnitAssertionFunctions/1_ValueAssertions.md new file mode 100644 index 0000000..ed927cd --- /dev/null +++ b/docs/WriteYourTests/Reference/LuaUnitAssertionFunctions/1_ValueAssertions.md @@ -0,0 +1,58 @@ +# Value assertions + +* **_AFT.assertEvalToTrue(value)** + + Assert that a given value evals to true. Lua coercion rules are applied so + that values like 0,"",1.17 succeed in this assertion. If provided, extra_msg + is a string which will be printed along with the failure message. + +* **_AFT.assertEvalToFalse(Value)** + + Assert that a given value eval to *false*. Lua coercion rules are applied so + that *nil* and *false* succeed in this assertion. If provided, extra_msg is a + string which will be printed along with the failure message. + +* **_AFT.assertIsTrue(value)** + + Assert that a given value compares to true. Lua coercion rules are applied so + that values like 0, "", 1.17 all compare to true. + +* **_AFT.assertIsFalse(value)** + + Assert that a given value compares to false. Lua coercion rules are applied so + that only nil and false all compare to false. + +* **_AFT.assertIsNil(value)** + + Assert that a given value is nil . + +* **_AFT.assertNotIsNil(value)** + + Assert that a given value is not *nil* . Lua coercion rules are applied + so that values like ``0``, ``""``, ``false`` all validate the assertion. + If provided, *extra_msg* is a string which will be printed along with the + failure message. + +* **_AFT.assertIs(actual, expected)** + + Assert that two variables are identical. For string, numbers, boolean and + for nil, this gives the same result as assertEquals() . For the other types, + identity means that the two variables refer to the same object. + + Example : + + ```lua + `s1='toto' + s2='to'..'to' + t1={1,2} + t2={1,2} + luaunit.assertIs(s1,s1) -- ok + luaunit.assertIs(s1,s2) -- ok + luaunit.assertIs(t1,t1) -- ok + luaunit.assertIs(t1,t2) -- fail` + ``` + +* **_AFT.assertNotIs(actual, expected)** + + Assert that two variables are not identical, in the sense that they do not + refer to the same value. See assertIs() for more details.
\ No newline at end of file diff --git a/docs/WriteYourTests/Reference/LuaUnitAssertionFunctions/2_ScientificAssertions.md b/docs/WriteYourTests/Reference/LuaUnitAssertionFunctions/2_ScientificAssertions.md new file mode 100644 index 0000000..9f80a7a --- /dev/null +++ b/docs/WriteYourTests/Reference/LuaUnitAssertionFunctions/2_ScientificAssertions.md @@ -0,0 +1,48 @@ +# Scientific assertions + +>**Note** +>If you need to deal with value minus zero, be very careful because Lua versions +are inconsistent on how they treat the >syntax -0 : it creates either a plus +zero or a minus zero. Multiplying or dividing 0 by -1 also yields inconsistent > +results. The reliable way to create the -0 value is : minusZero = -1 / (1/0). + +* **_AFT.assertIsNaN(value)** + Assert that a given number is a *NaN* (Not a Number), according to the + definition of IEEE-754_ . If provided, *extra_msg* is a string which will + be printed along with the failure message. + +* **_AFT.assertIsPlusInf(value)** + + Assert that a given number is *plus infinity*, according to the definition of + IEEE-754_. If provided, *extra_msg* is a string which will be printed along + with the failure message. + +* **_AFT.assertIsMinusInf(value)** + + Assert that a given number is *minus infinity*, according to the definition of + IEEE-754_. If provided, *extra_msg* is a string which will be printed along + with the failure message. + +* **_AFT.assertIsInf(value)** + + Assert that a given number is *infinity* (either positive or negative), + according to the definition of IEEE-754_. If provided, *extra_msg* is a string + which will be printed along with the failure message. + +* **_AFT.assertIsPlusZero(value)** + + Assert that a given number is *+0*, according to the definition of IEEE-754_. + The verification is done by dividing by the provided number and verifying + that it yields *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*, see note above + +* **_AFT.assertIsMinusZero(value)** + + Assert that a given number is *-0*, according to the definition of IEEE-754_. + The verification is done by dividing by the provided number and verifying that + 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*
\ No newline at end of file diff --git a/docs/WriteYourTests/Reference/LuaUnitAssertionFunctions/3_StringAssertions.md b/docs/WriteYourTests/Reference/LuaUnitAssertionFunctions/3_StringAssertions.md new file mode 100644 index 0000000..a816998 --- /dev/null +++ b/docs/WriteYourTests/Reference/LuaUnitAssertionFunctions/3_StringAssertions.md @@ -0,0 +1,38 @@ +# 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.
\ No newline at end of file diff --git a/docs/WriteYourTests/Reference/LuaUnitAssertionFunctions/4_ErrorAssertions.md b/docs/WriteYourTests/Reference/LuaUnitAssertionFunctions/4_ErrorAssertions.md new file mode 100644 index 0000000..482b98d --- /dev/null +++ b/docs/WriteYourTests/Reference/LuaUnitAssertionFunctions/4_ErrorAssertions.md @@ -0,0 +1,30 @@ +# 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 if the message contains a string 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 pattern 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 -+.?\*) .
\ No newline at end of file diff --git a/docs/WriteYourTests/Reference/LuaUnitAssertionFunctions/5_TypeAssertions.md b/docs/WriteYourTests/Reference/LuaUnitAssertionFunctions/5_TypeAssertions.md new file mode 100644 index 0000000..843f651 --- /dev/null +++ b/docs/WriteYourTests/Reference/LuaUnitAssertionFunctions/5_TypeAssertions.md @@ -0,0 +1,38 @@ +# 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 ).
\ No newline at end of file diff --git a/docs/WriteYourTests/Reference/LuaUnitAssertionFunctions/6_TableAssertions.md b/docs/WriteYourTests/Reference/LuaUnitAssertionFunctions/6_TableAssertions.md new file mode 100644 index 0000000..8d29988 --- /dev/null +++ b/docs/WriteYourTests/Reference/LuaUnitAssertionFunctions/6_TableAssertions.md @@ -0,0 +1,19 @@ +# 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: + + ```lua + 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. + + ```lua + luaunit.assertItemsEquals( {1,{2,3},4}, {4,{3,2,},1} ) -- assertion fails because {2,3} ~= {3,2} + ```
\ No newline at end of file diff --git a/docs/WriteYourTests/Reference/LuaUnitAssertionFunctions/Introduction.md b/docs/WriteYourTests/Reference/LuaUnitAssertionFunctions/Introduction.md new file mode 100644 index 0000000..2bdf05c --- /dev/null +++ b/docs/WriteYourTests/Reference/LuaUnitAssertionFunctions/Introduction.md @@ -0,0 +1,13 @@ +# LuaUnit Assertion Functions + +Follow this section to know which luaUnit assertion functions are available !! + +Section's Table of content : + +* [General Assertions](0_GeneralAssertions.html) +* [Value Assertions](1_ValueAssertions.html) +* [Scientific Assertions](2_ScientificAssertions.html) +* [String Assertions](3_StringAssertions.html) +* [Error Assertions](4_ErrorAssertions.html) +* [Type Assertions](5_TypeAssertions.html) +* [Table Assertions](6_TableAssertions.html)
\ No newline at end of file diff --git a/docs/_layouts/ebook/page.html b/docs/_layouts/ebook/page.html new file mode 100644 index 0000000..bf325e9 --- /dev/null +++ b/docs/_layouts/ebook/page.html @@ -0,0 +1,36 @@ +{% extends "layout.html" %} + +{% block title %}{{ page.title }}{% endblock %} +{% block description %}{{ page.description }}{% endblock %} + +{% block style %} + {### Include theme css before plugins css ###} + {% if not fileExists(config.styles.print) %} + {% if options.format %} + <link rel="stylesheet" href="{{ (options.format + ".css")|resolveAsset }}"> + {% else %} + <link rel="stylesheet" href="{{ "ebook.css"|resolveAsset }}"> + {% endif %} + {% endif %} + + {{ super() }} + + {### Custom stylesheets for the book ###} + + {% for type, style in config.styles %} + {% if fileExists(style) and (type == "ebook" or type == "print" or type == options.format) %} + <link rel="stylesheet" href="{{ style|resolveFile }}"> + {% endif %} + {% endfor %} +{% endblock %} + +{% block body %} +<div class="page"> + {% block page %} + <h1 class="book-chapter book-chapter-{{ page.depth }}">{{ page.title }}</h1> + <div class="section"> + {{ page.content|safe }} + </div> + {% endblock %} +</div> +{% endblock %} diff --git a/docs/_layouts/ebook/pdf_footer.html b/docs/_layouts/ebook/pdf_footer.html new file mode 100644 index 0000000..679e562 --- /dev/null +++ b/docs/_layouts/ebook/pdf_footer.html @@ -0,0 +1,13 @@ +{% extends "./page.html" %} +{% block body %} +<div id="pdf-footer" class="pdf-footer"> + <span class="footer-left">Version {{ config.version }}</span> + <span class="footer-right">{{ page.num }}</span> + <span class="footer-center">{{ config.published }}</span> +</div> + +<!-- Allow to hide footer for some pages using hidepagefooters config in book.json --> +<script> + if (({% for num in config.hidepagefooters %}{{ page.num }} == {{ num }} || {% endfor %}false)) document.getElementById('pdf-footer').style.display = 'none' +</script> +{% endblock %} diff --git a/docs/_layouts/ebook/pdf_header.html b/docs/_layouts/ebook/pdf_header.html new file mode 100644 index 0000000..ef49641 --- /dev/null +++ b/docs/_layouts/ebook/pdf_header.html @@ -0,0 +1,13 @@ +{% extends "./page.html" %} +{% block body %} +<div id="pdf-header" class="pdf-header"> + <span class="header-left">IoT.Bzh</span> + <span class="header-right">{{ config.title }}</span> +</div> + +<!-- Allow to hide header for some pages using hidepageheaders config in book.json --> +<script> + if (({% for num in config.hidepageheaders %}{{ page.num }} == {{ num }} || {% endfor %}false)) document.getElementById('pdf-header').style.display = 'none' +</script> + +{% endblock %}
\ No newline at end of file diff --git a/docs/_layouts/ebook/summary.html b/docs/_layouts/ebook/summary.html new file mode 100644 index 0000000..be328a4 --- /dev/null +++ b/docs/_layouts/ebook/summary.html @@ -0,0 +1,58 @@ +{% extends "./page.html" %} + +{% block title %}{{ "SUMMARY"|t }}{% endblock %} + +{% macro articles(_articles) %} + {% for article in _articles %} + <li> + <span class="inner"> + {% if article.path or article.url %} + {% if article.path %} + <a href="{{ article.path|contentURL }}{{ article.anchor }}">{{ article.title }}</a> + {% else %} + <a target="_blank" href="{{ article.url }}">{{ article.title }}</a> + {% endif %} + {% else %} + <span>{{ article.title }}</span> + {% endif %} + {% if 1 %} + <span class="page">{{ article.level }}</span> + {% endif %} + </span> + {% if article.articles.length > 0 %} + <ol> + {{ articles(article.articles) }} + </ol> + {% endif %} + </li> + {% endfor %} +{% endmacro %} + +{% block page %} +<div class="section toc"> + <h1>{{ "SUMMARY"|t }}</h1> + <ol> + {% for part in summary.parts %} + {% if part.title %} + <li class="part-title"> + <h2>{{ part.title }}</h2> + </li> + {% endif %} + {{ articles(part.articles) }} + + {% if not loop.last %} + <li class="divider"></li> + {% endif %} + {% endfor %} + + {% if glossary.path %} + <li> + <span class="inner"> + <a href="{{ ('/' + glossary.path)|contentURL }}">{{ "GLOSSARY"|t }}</a> + </span> + </li> + {% endif %} + </ol> +</div> +{% endblock %} + diff --git a/docs/_layouts/layout.html b/docs/_layouts/layout.html new file mode 100644 index 0000000..3d5aca6 --- /dev/null +++ b/docs/_layouts/layout.html @@ -0,0 +1,28 @@ +<!DOCTYPE HTML> +<html lang="{{ config.language }}" {% if page.dir == "rtl" %}dir="rtl"{% endif %}> + <head> + <meta charset="UTF-8"> + <meta content="text/html; charset=utf-8" http-equiv="Content-Type"> + <title>{% block title %}{{ config.title|d("GitBook", true) }}{% endblock %}</title> + <meta http-equiv="X-UA-Compatible" content="IE=edge" /> + <meta name="description" content="{% block description %}{% endblock %}"> + <meta name="generator" content="GitBook {{ gitbook.version }}"> + {% if config.author %}<meta name="author" content="{{ config.author }}">{% endif %} + {% if config.isbn %}<meta name="identifier" content="{{ config.isbn }}" scheme="ISBN">{% endif %} + {% block style %} + {% for resource in plugins.resources.css %} + {% if resource.url %} + <link rel="stylesheet" href="{{ resource.url }}"> + {% else %} + <link rel="stylesheet" href="{{ resource.path|resolveAsset }}"> + {% endif %} + {% endfor %} + {% endblock %} + + {% block head %}{% endblock %} + </head> + <body> + {% block body %}{% endblock %} + {% block javascript %}{% endblock %} + </body> +</html> diff --git a/docs/cover.jpg b/docs/cover.jpg Binary files differnew file mode 100644 index 0000000..2986e86 --- /dev/null +++ b/docs/cover.jpg diff --git a/docs/cover_small.jpg b/docs/cover_small.jpg Binary files differnew file mode 100644 index 0000000..42f7943 --- /dev/null +++ b/docs/cover_small.jpg diff --git a/docs/resources/cover.svg b/docs/resources/cover.svg new file mode 100644 index 0000000..6726de7 --- /dev/null +++ b/docs/resources/cover.svg @@ -0,0 +1,210 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + width="1800" + height="2360" + viewBox="0 0 1800 2360" + id="svg2" + version="1.1" + inkscape:version="0.91 r13725" + sodipodi:docname="cover.svg"> + <defs + id="defs4175"> + <filter + style="color-interpolation-filters:sRGB" + inkscape:label="Drop Shadow" + id="filter4000"> + <feFlood + result="flood" + flood-color="rgb(0,0,0)" + flood-opacity="0.475" + id="feFlood4002" /> + <feComposite + result="composite1" + operator="in" + in="flood" + in2="SourceGraphic" + id="feComposite4004" /> + <feGaussianBlur + result="blur" + stdDeviation="5" + id="feGaussianBlur4006" /> + <feOffset + result="offset" + dy="8" + dx="8" + id="feOffset4008" /> + <feComposite + result="composite2" + operator="over" + in="SourceGraphic" + in2="offset" + id="feComposite4010" /> + </filter> + <filter + style="color-interpolation-filters:sRGB" + id="filter4000-6" + inkscape:label="Drop Shadow"> + <feFlood + id="feFlood4002-4" + flood-opacity="0.475" + flood-color="rgb(0,0,0)" + result="flood" /> + <feComposite + id="feComposite4004-6" + in2="SourceGraphic" + in="flood" + operator="in" + result="composite1" /> + <feGaussianBlur + id="feGaussianBlur4006-2" + stdDeviation="5" + result="blur" /> + <feOffset + id="feOffset4008-8" + dx="8" + dy="8" + result="offset" /> + <feComposite + id="feComposite4010-9" + in2="offset" + in="SourceGraphic" + operator="over" + result="composite2" /> + </filter> + </defs> + <sodipodi:namedview + id="base" + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1.0" + inkscape:pageopacity="0.0" + inkscape:pageshadow="2" + inkscape:zoom="0.24748737" + inkscape:cx="928.3577" + inkscape:cy="404.58117" + inkscape:document-units="px" + inkscape:current-layer="layer1" + showgrid="false" + inkscape:snap-text-baseline="false" + units="px" + inkscape:window-width="1920" + inkscape:window-height="1171" + inkscape:window-x="1920" + inkscape:window-y="0" + inkscape:window-maximized="1" + showguides="false" /> + <metadata + id="metadata7"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <dc:title /> + </cc:Work> + </rdf:RDF> + </metadata> + <g + inkscape:label="Layer 1" + inkscape:groupmode="layer" + id="layer1" + transform="translate(0,1307.6379)"> + <g + id="iotbzh-logo" + transform="matrix(2.3917866,0,0,2.3917866,216.6324,-1946.4393)" + inkscape:export-filename="/home/sdx/Pictures/Logo/logo_iot_bzh_100dpi.png" + inkscape:export-xdpi="100.22011" + inkscape:export-ydpi="100.22011" + style="display:inline;filter:url(#filter4000-6)"> + <text + sodipodi:linespacing="125%" + id="text3557-5-3-7-0-7-3" + y="519.50671" + x="27.886671" + style="font-style:normal;font-weight:normal;font-size:97.09867096px;line-height:125%;font-family:Sans;letter-spacing:0px;word-spacing:0px;display:inline;fill:#000000;fill-opacity:1;stroke:none" + xml:space="preserve"><tspan + style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:97.09867096px;line-height:125%;font-family:FreeEuro;-inkscape-font-specification:'FreeEuro Bold';text-align:start;writing-mode:lr-tb;text-anchor:start" + y="519.50671" + x="27.886671" + id="tspan3559-5-4-1-5-0-6" + sodipodi:role="line">IOT</tspan></text> + <path + inkscape:connector-curvature="0" + d="m 286.73007,473.23356 c 28.21686,16.29102 28.75566,58.73779 0.99693,78.53831 -7.67688,5.47598 -8.77935,4.91028 -1.99529,-1.0238 17.47377,-15.28453 17.98492,-42.17775 1.08522,-57.09786 l -3.91266,-3.45435 0.72312,-3.71053 c 0.39771,-2.04076 0.5997,-5.73115 0.44885,-8.20083 -0.33876,-5.54623 0.15803,-6.49185 2.65383,-5.05094 z m -64.76568,11.40332 c 7.06047,-7.74198 18.64659,-14.16089 29.04027,-16.08874 l 6.87489,-1.27521 0.87404,2.89709 c 0.4807,1.59343 0.67439,5.2245 0.43037,8.06906 l -0.44364,5.17195 -6.13887,1.6918 c -10.91241,3.00731 -20.4022,10.85909 -25.4533,21.05979 l -2.41633,4.87984 -2.74281,-0.41238 c -5.14252,-0.77316 -12.72985,-3.97645 -12.79123,-5.40033 -0.092,-2.13451 8.34659,-15.74625 12.76661,-20.59287 z m 33.20546,36.39493 c -28.21687,16.29101 -65.24624,-4.46574 -68.51461,-38.40577 -0.9039,-9.38637 0.13723,-10.0583 1.88428,-1.21608 4.49989,22.77499 27.53453,36.66428 48.90556,29.48876 l 4.94788,-1.66128 2.85184,2.48149 c 1.56852,1.36481 4.66349,3.38493 6.87772,4.48914 4.97257,2.47973 5.54308,3.38282 3.04733,4.82374 z m 22.50729,-61.79039 c 3.17451,9.98553 2.94038,23.22889 -0.58688,33.19399 l -2.33309,6.59143 -2.94597,-0.69161 c -1.6203,-0.38041 -4.86173,-2.02821 -7.2032,-3.6618 l -4.25721,-2.97018 1.60429,-6.16234 c 2.85178,-10.95404 0.79685,-23.09833 -5.51167,-32.57307 l -3.01788,-4.53253 1.72854,-2.16916 c 3.24083,-4.06698 9.80863,-9.03614 11.07242,-8.37738 1.89457,0.98756 9.46336,15.1015 11.45065,21.35265 z m -48.80223,10.31437 c 0,-32.58201 36.49058,-54.27201 67.51771,-40.1325 8.58077,3.9104 8.6421,5.148 0.11108,2.23988 -21.97368,-7.49048 -45.51946,5.51348 -49.99082,27.6091 l -1.03521,5.11561 -3.57498,1.22902 c -1.96621,0.67596 -5.26316,2.34622 -7.32655,3.71171 -4.63379,3.06649 -5.70115,3.10904 -5.70115,0.22718 z m 42.25842,50.3871 c -10.23499,-2.24356 -21.58699,-9.06801 -28.45341,-17.10525 l -4.5418,-5.31622 2.07194,-2.20549 c 1.13957,-1.21302 4.18733,-3.19628 6.77282,-4.40726 l 4.70085,-2.20176 4.53458,4.47053 c 8.06061,7.94674 19.60535,12.23927 30.96496,11.51329 l 5.43422,-0.34731 1.01427,2.58154 c 1.90169,4.84014 2.92124,13.01261 1.71883,13.77769 -1.80254,1.14695 -17.80995,0.64475 -24.21726,-0.75976 z" + style="display:inline;fill:#5a2ca0" + id="path3415-4-2-2-5-0-3-7-4-4-1-5" /> + <text + sodipodi:linespacing="125%" + id="text3557-5-3-7-46-7-3-7" + y="519.50671" + x="317.95816" + style="font-style:normal;font-weight:normal;font-size:97.09867096px;line-height:125%;font-family:Sans;letter-spacing:0px;word-spacing:0px;display:inline;fill:#000000;fill-opacity:1;stroke:none" + xml:space="preserve"><tspan + style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:97.09867096px;line-height:125%;font-family:FreeEuro;-inkscape-font-specification:'FreeEuro Bold';text-align:start;writing-mode:lr-tb;text-anchor:start" + y="519.50671" + x="317.95816" + id="tspan3559-5-4-1-90-0-2-9" + sodipodi:role="line">BZH</tspan></text> + </g> + <flowRoot + xml:space="preserve" + id="root-title" + transform="matrix(2.3469382,0,0,2.3469382,464.13874,-1200)"><flowRegion + id="flowRegion4303"><rect + id="rect4305" + width="679.99994" + height="141.42853" + x="-154.28572" + y="400"/> + </flowRegion> + <flowPara + id="title" + style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:87.5px;line-height:125%;font-family:Verdana;-inkscape-font-specification:'Verdana, Bold';text-align:center;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1">{title}</flowPara></flowRoot> <flowRoot + xml:space="preserve" + id="root-subtitle" + transform="matrix(1.8523279,0,0,1.8523279,553.97647,-380)"><flowRegion + id="flowRegion4303-6"><rect + id="rect4305-0" + width="852.32806" + height="154.51677" + x="-239.3591" + y="290"/> + </flowRegion> + <flowPara + id="subtitle" + style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:62.5px;line-height:125%;font-family:Verdana;-inkscape-font-specification:'Verdana, Bold';text-align:center;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1">{subtitle}</flowPara> + </flowRoot> + <flowRoot + id="root-version" + xml:space="preserve" + transform="translate(-2.0185547,164)"><flowRegion + id="flowRegion4169"><rect + y="501.68909" + x="343.32947" + height="99.591171" + width="1117.3768" + id="rect4171" /></flowRegion><flowPara + style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:50px;line-height:125%;font-family:Verdana;-inkscape-font-specification:'Verdana, Bold';text-align:center;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1" + id="version">{version}</flowPara></flowRoot> <flowRoot + transform="translate(-2.0185547,238)" + xml:space="preserve" + id="root-date"><flowRegion + id="flowRegion4170"><rect + id="rect4172" + width="1117.3768" + height="99.591171" + x="343.32947" + y="501.68909" /></flowRegion><flowPara + id="date" + style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:50px;line-height:125%;font-family:Verdana;-inkscape-font-specification:'Verdana, Bold';text-align:center;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1">{date}</flowPara></flowRoot> </g> +</svg> diff --git a/docs/resources/ebook.css b/docs/resources/ebook.css new file mode 100644 index 0000000..e8df4d8 --- /dev/null +++ b/docs/resources/ebook.css @@ -0,0 +1,402 @@ +/* IoT.Bzh theaming */ + +h1 { + color: #330066; + border-bottom: 2px solid #330066; +} + +h2 { + color: #330066; +} + +h3 { + color: #330066; +} + +h4 { + color: #330066; +} + + +/* GENERAL ELEMENTS */ + +/* clear both */ + +.clear { + clear: both; +} + +.section> :last-child { + margin-bottom: 0 !important; +} + +.section> :first-child { + margin-top: 0 !important; +} + + +/* SPECIAL ELEMENTS */ + + +/* page break always after element on pdf/print definition */ + +div.pagebreak { + page-break-after: always; +} + + +/* no page break inside element on pdf/print definition */ + +div.nopb { + page-break-inside: avoid !important; + margin: 4px 0 4px 0; +} + + +/* note blocks */ + +div.note { + background: #FCF8E3 none repeat scroll 0% 0%; + color: #8A6D3B; + padding: 15px; + margin-bottom: 10px; + border-bottom: 5px solid #DDD; + border-color: #FAEBCC; + page-break-inside: avoid; +} + +div.note p { + padding-bottom: 0; + margin-bottom: 0; +} + +/* warning blocks */ + +div.warning { + background: #FD9595 none repeat scroll 0% 0%; + color: #8A6D3B; + padding: 15px; + margin-bottom: 10px; + border-bottom: 5px solid #DDD; + border-color: #FF6B6B; + page-break-inside: avoid; +} + +div.warning p { + padding-bottom: 0; + margin-bottom: 0; +} + +/* images, figures and captions */ + +p img { + /* center all images */ + display: block; + margin: 0 auto; + padding: 10px 0; +} + +figure { + margin: 1.0em 0px; + padding: 10px 0; + text-align: center; + page-break-inside: avoid; + display: block; +} + +figure img { + display: block; + margin: 0 auto; +} + +figcaption { + clear: left; + margin: 1.0em 0 0 0; + text-align: center; + font-style: italic; + line-height: 1.5em; + font-size: 80%; + color: #666; + display: block; +} + +.page .section p img { + margin-top: 10px; +} + + +/* ul, ol list margin fix */ + +.page .section ol, +.page .section ul { + margin-bottom: 10px; +} + + +/* blockquotes */ + +.page .section blockquote { + margin: 0 0 0 5%; + font-style: italic; +} + + +/* PAGE SPECIFIC */ + + +/* set summary page to right side of the paper */ + +.page .toc h1 { + page-break-before: right; +} + +.page .section.toc { + page-break-inside: always; +} + +/* table headers */ + +div#README\.md table { + margin-top: 30px; + font-size: 95%; +} + +div#README\.md table thead { + display: none; +} + + + +/* CITATION AND IMAGES */ + + +/* math image styles */ + +.page .section p img.svg, +.page .section p img.png { + margin-top: 0px; + margin-bottom: -2px; +} + +.page .section p img.math { + vertical-align: middle; + height: auto; + width: auto; + margin-top: -4px; + max-height: 15px; +} + +.page .section p img.math.line1 { + margin-top: -7px; + max-height: 19px; +} + +.page .section p img.math.line2 { + margin-top: -1px; + max-height: 30px; +} + + +/* credits page */ + +.page .section ul.pictures { + margin-left: -30px; +} + +.page .section ul.pictures li { + list-style: outside none none; +} + +.page .section ul.pictures li a { + float: left; +} + +.page .section ul.pictures li span { + display: block; + margin-left: 100px; +} + + + +/* sub and super script */ + +.page .section sub { + font-size: 80%; + margin-left: 1px; +} + + +/* citations and references */ + +.page .section sup { + margin-left: -1px; + margin-right: 2px; + font-size: 80%; +} + +.page .section sup:before { + content: " "; +} + +.page .section ul.citations, +.page .section ul.references { + margin-left: -30px; +} + + +.page .section ul.citations li:nth-child(1) { + margin-top: 20px; + padding-top: 20px; + border-top: 1px solid #BBB; +} + +.page .section ul.citations li, +.page .section ul.references li { + list-style: outside none none; +} + +.page .section ul.citations li { + font-size: 80%; +} + +.page .section ul.citations li>span:nth-child(1), +.page .section ul.references li>span:nth-child(1) { + display: block; + float: left; + text-align: left; + width: 70px +} + +.page .section ul.citations li>span:nth-child(1) { + width: 50px +} + +.page .section ul.references li div { + margin-left: 70px; +} + +.page .section ul.citations li div { + margin-left: 50px; +} + +.page .section a[href="#"], +.page .section a[href="#"]:link, +.page .section a[href="#"]:visited, +.page .section a[href="#"]:hover, +.page .section a[href="#"]:focus { + text-decoration: none; + color: inherit; + cursor: text; + font-style: italic; +} + + +/* self referential footnotes */ + +.page .section div[type="selfref"] a[href="#"], +.page .section div[type="selfref"] a[href="#"]:link, +.page .section div[type="selfref"] a[href="#"]:visited, +.page .section div[type="selfref"] a[href="#"]:hover, +.page .section div[type="selfref"] a[href="#"]:focus { + font-style: normal; +} + +.page .section div[type="selfref"] span:nth-child(1) { + display: none; +} + + +/* page break always after element on pdf/print definition */ + +div.page-break { + page-break-inside: always; +} + +div.page-break:before { + content: ' '; +} + + +/* no page break inside element on pdf/print definition */ + +div.nopb { + page-break-inside: avoid; +} + +/* justify text */ +p { + text-align: justify; +} + +/* page header and footer */ + +.pdf-footer, +.pdf-header { + margin-top: 20px; + color: #aaa; +} + +.pdf-header .header-left { + float: left; + margin-left: 2em; + margin-right: auto; +} + +.pdf-header .header-right { + display: table; + margin-left: auto; + margin-right: 2em; +} + +.pdf-footer .sub { + padding-top: 8px; + font-size: 70%; +} + +.pdf-header .sub { + padding-top: 2px; + font-size: 70%; +} + +.pdf-footer { + padding-top: 10px; + border-top: 1px solid #eee; +} + +.pdf-footer .footer-left { + float: left; + margin-left: 2em; + margin-right: auto; +} + +.pdf-footer .footer-center { + display: table; + margin-left: auto; + margin-right: auto; +} + +.pdf-footer .footer-right { + float: right; + margin-left: auto; + margin-right: 2em; +} + +.pdf-header { + padding-bottom: 10px; + border-bottom: 1px solid #eee; +} + +.pdf-header .header-pages-count { + float: right; + text-align: right; +} + +.pdf-header .header-pages-count a, +.pdf-header .header-pages-count a:visited, +.pdf-header .header-pages-count a:active, +.pdf-header .header-pages-count a:focus, +.pdf-header .header-pages-count a:link { + text-decoration: none; + color: #aaa; + cursor: text; +} diff --git a/docs/resources/make_cover.sh b/docs/resources/make_cover.sh new file mode 100755 index 0000000..1026ecb --- /dev/null +++ b/docs/resources/make_cover.sh @@ -0,0 +1,27 @@ +#!/bin/bash +DOCS_DIR=$(cd $(dirname $0)/.. && pwd) +BOOKFILE=$DOCS_DIR/../book.json + +TITLE=$(grep '"title":' $BOOKFILE | cut -d'"' -f 4) +SUBTITLE=$(grep '"subtitle":' $BOOKFILE | cut -d'"' -f 4) +VERSION="Version $(grep '"version":' $BOOKFILE | cut -d'"' -f 4)" +DATE=$(grep '"published":' $BOOKFILE | cut -d'"' -f 4) + +[ -z "$TITLE" ] && { echo "Error TITLE not set!" ; exit 1; } +[ -z "$VERSION" ] && { echo "Error VERSION not set!" ; exit 1; } +[ -z "$DATE" ] && { echo "Error DATE not set!" ; exit 1; } + + +cat $(dirname $0)/cover.svg | sed -e "s/{title}/$TITLE/g" \ + -e "s/font-size:87.5px/font-size:54px/g" \ + -e "s/{subtitle}/$SUBTITLE/g" \ + -e "s/font-size:62.5px/font-size:40px/g" \ + -e "s/{version}/$VERSION/g" \ + -e "s/{date}/$DATE/g" \ + > /tmp/cover.svg + +# use imagemagick convert tool (cover size must be 1800x2360) +convert -resize "1600x2160!" -border 100 -bordercolor white -background white \ + -flatten -quality 100 /tmp/cover.svg $DOCS_DIR/cover.jpg + +convert -resize "200x262!" $DOCS_DIR/cover.jpg $DOCS_DIR/cover_small.jpg |