43993f4b0f873e475e3523b4fb6665b54ff7a9b0
[AGL/documentation.git] / docs / 4_APIs_and_Services / 4.4_AGL_Test_Framework / 3_Launch_the_tests / Launch_the_tests.md
1 ---
2 edit_link: ''
3 title: Launch the tests
4 origin_url: >-
5   https://git.automotivelinux.org/apps/app-afb-test/plain/docs/3_Launch_the_tests.md?h=master
6 ---
7
8 <!-- WARNING: This file is generated by fetch_docs.js using /home/boron/Documents/AGL/docs-webtemplate/site/_data/tocs/apis_services/master/app-afb-test-developer-guides-api-services-book.yml -->
9
10 # How to launch the tests ?
11
12 ## Natively during the development
13
14 It could be convenient to be able to test the software that you are currently
15 developing. Then you can ensure that your modifications haven't introduced
16 regressions, bugs, etc. This depends upon your tests of course.
17
18 As previously saw, you need the `test widget` to be able to launch the tests and
19 you need also to have the `afb-test` binding installed and the `application
20 framework binder` to be able to execute your tests.
21
22 Assuming you already installed those components on your development host, then
23 proceed as the following from the project root directory:
24
25 ```bash
26 cd build
27 cmake -DBUILD_TEST_WGT=TRUE ..
28 make
29 make widget
30 ```
31
32 To prepare all files needed for the test launch then use the `afm-test` script:
33
34 ```bash
35 # Usage of afm-test command line utility
36 afm-test --help
37 Usage: /opt/AGL/bin/afm-test <binding-wgt-rootdir> <test-wgt-rootdir> [-m|--mode <SOLO|SERVICE>] [-t|--timeout <X>] [-l|--lavaoutput]
38 binding-wgt-rootdir: path to the test wgt file
39 test-wgt-rootdir: path to the test folder file
40 -m|--mode: SOLO (1 binder) or SERVICE (2 binders) (Default: SOLO)
41 -t|--timeout: timeout in second. (Default 3 seconds)
42 -l|--lavaoutput: Flags indicating the binding to add Lava special test markers.
43 Error: Test launch failed. Code: 1
44 # Launching the test from your build project directory
45 afm-test package package-test
46 ```
47
48 ### Example with the afb-test selftest suite
49
50 Prepare the launch building the `test widget`:
51
52 ```bash
53 $ cd build
54 # Cleaning the previous build files
55 $ rm -rf *
56 # Configuration step
57 $ cmake -DBUILD_TEST_WGT=TRUE ..
58 -- The C compiler identification is GNU 8.2.1
59 -- The CXX compiler identification is GNU 8.2.1
60 -- Check for working C compiler: /usr/lib64/ccache/cc
61 -- Check for working C compiler: /usr/lib64/ccache/cc -- works
62 -- Detecting C compiler ABI info
63 -- Detecting C compiler ABI info - done
64 -- Detecting C compile features
65 -- Detecting C compile features - done
66 -- Check for working CXX compiler: /usr/lib64/ccache/c++
67 -- Check for working CXX compiler: /usr/lib64/ccache/c++ -- works
68 -- Detecting CXX compiler ABI info
69 -- Detecting CXX compiler ABI info - done
70 -- Detecting CXX compile features
71 -- Detecting CXX compile features - done
72 Distribution detected (separated by ';' choose one of them) fedora
73 Include: /home/claneys/.config/app-templates/cmake.d/00-common-var.cmake
74 Include: /home/claneys/Workspace/Sources/IOTbzh/gerrit.automotivelinux.org/apps/app-afb-test/conf.d/cmake/00-default-osconfig.cmake
75 Include: /usr/share/cmake/Modules/CMakeAfbTemplates/cmake/cmake.d/01-build_options.cmake
76 -- Found PkgConfig: /usr/bin/pkg-config (found version "1.4.2")
77 -- Checking for module 'json-c'
78 --   Found json-c, version 0.13.1
79 -- Checking for module 'libsystemd>=222'
80 --   Found libsystemd, version 238
81 -- Checking for module 'afb-daemon>=4.0'
82 --   Found afb-daemon, version 6.90.0
83 -- Checking for module 'lua>=5.3'
84 --   Found lua, version 5.3.4
85 Include: /usr/share/cmake/Modules/CMakeAfbTemplates/cmake/cmake.d/02-variables.cmake
86 -- Check gcc_minimal_version (found gcc version 8.2.1)  (found g++ version 8.2.1)
87 Include: /usr/share/cmake/Modules/CMakeAfbTemplates/cmake/cmake.d/03-macros.cmake
88 Include: /usr/share/cmake/Modules/CMakeAfbTemplates/cmake/cmake.d/04-extra_targets.cmake
89 -- Overwrite the CMAKE default install prefix with /opt/AGL
90 -- Found CURL: /usr/lib64/libcurl.so (found version "7.59.0")
91 -- Qt's WebSocket AFB Client: Disabled!
92 -- CURL wrapping helpers: Enabled!
93 -- Notice: LUA Controler Support Selected
94 -- Notice: Using default test widget configuration's file.
95 -- If you want to use a customized test-config.xml template then specify TEST_WIDGET_CONFIG_TEMPLATE in your config.cmake file.
96 -- Configuring done
97 -- Generating done
98 -- Build files have been written to: /home/claneys/Workspace/Sources/IOTbzh/gerrit.automotivelinux.org/apps/app-afb-test/build
99 # Build the binding
100 $ make
101 Scanning dependencies of target test-files
102 [  3%] Generating test-files
103 [  3%] Built target test-files
104 Scanning dependencies of target project_populate_test-files
105 [  6%] Generating package-test/var/test-files
106 [  6%] Built target project_populate_test-files
107 Scanning dependencies of target afb-test-config
108 [  9%] Generating afb-test-config
109 Warning: JSON_CHECKER not found. Not verification made on files !
110 [  9%] Built target afb-test-config
111 Scanning dependencies of target project_populate_afb-test-config
112 [ 12%] Generating package-test/etc/afb-test-config
113 [ 12%] Built target project_populate_afb-test-config
114 Scanning dependencies of target aftest-config
115 [ 16%] Generating aftest-config
116 Warning: JSON_CHECKER not found. Not verification made on files !
117 [ 16%] Built target aftest-config
118 Scanning dependencies of target project_populate_aftest-config
119 [ 19%] Generating package/etc/aftest-config
120 [ 19%] Built target project_populate_aftest-config
121 Scanning dependencies of target fixture-files
122 [ 22%] Generating fixture-files
123 [ 22%] Built target fixture-files
124 Scanning dependencies of target project_populate_fixture-files
125 [ 25%] Generating package-test/var/fixture-files
126 [ 25%] Built target project_populate_fixture-files
127 Scanning dependencies of target afTest-lua
128 [ 29%] Generating afTest-lua
129 [ 29%] Built target afTest-lua
130 Scanning dependencies of target project_populate_afTest-lua
131 [ 32%] Generating package/var/afTest-lua
132 [ 32%] Built target project_populate_afTest-lua
133 Scanning dependencies of target afb-helpers
134 [ 35%] Building C object afb-helpers/CMakeFiles/afb-helpers.dir/wrap-json.c.o
135 [ 38%] Building C object afb-helpers/CMakeFiles/afb-helpers.dir/filescan-utils.c.o
136 [ 41%] Building C object afb-helpers/CMakeFiles/afb-helpers.dir/escape.c.o
137 [ 45%] Building C object afb-helpers/CMakeFiles/afb-helpers.dir/curl-wrap.c.o
138 [ 48%] Linking C static library libafb-helpers.a
139 [ 48%] Built target afb-helpers
140 Scanning dependencies of target ctl-utilities
141 [ 51%] Building C object app-controller-submodule/ctl-lib/CMakeFiles/ctl-utilities.dir/ctl-action.c.o
142 [ 54%] Building C object app-controller-submodule/ctl-lib/CMakeFiles/ctl-utilities.dir/ctl-config.c.o
143 [ 58%] Building C object app-controller-submodule/ctl-lib/CMakeFiles/ctl-utilities.dir/ctl-onload.c.o
144 [ 61%] Building C object app-controller-submodule/ctl-lib/CMakeFiles/ctl-utilities.dir/ctl-plugin.c.o
145 [ 64%] Building C object app-controller-submodule/ctl-lib/CMakeFiles/ctl-utilities.dir/ctl-control.c.o
146 [ 67%] Building C object app-controller-submodule/ctl-lib/CMakeFiles/ctl-utilities.dir/ctl-event.c.o
147 [ 70%] Building C object app-controller-submodule/ctl-lib/CMakeFiles/ctl-utilities.dir/ctl-lua.c.o
148 [ 74%] Building C object app-controller-submodule/ctl-lib/CMakeFiles/ctl-utilities.dir/ctl-timer.c.o
149 [ 77%] Building C object app-controller-submodule/ctl-lib/CMakeFiles/ctl-utilities.dir/ctl-lua-utils.c.o
150 [ 80%] Linking C static library libctl-utilities.a
151 [ 80%] Built target ctl-utilities
152 Scanning dependencies of target aft
153 [ 83%] Building C object src/CMakeFiles/aft.dir/aft.c.o
154 [ 87%] Building C object src/CMakeFiles/aft.dir/mapis.c.o
155 [ 90%] Linking C shared module aft.so
156 [ 90%] Built target aft
157 Scanning dependencies of target project_populate_aft
158 [ 93%] Generating package/lib/aft.so
159 [ 93%] Built target project_populate_aft
160 Scanning dependencies of target populate
161 [ 96%] Generating package/bin, package/etc, package/lib, package/htdocs, package/var, package-test/bin, package-test/etc, package-test/lib, package-test/htdocs, package-test/var
162 [ 96%] Built target populate
163 Scanning dependencies of target afTest_build_done
164 ++ Typical binding launch: afb-daemon --name afTest --port=1234 --workdir=package-test --ldpaths=/opt/AGL/lib64/afb:../package/lib --token=
165 [ 96%] Built target afTest_build_done
166 Scanning dependencies of target autobuild
167 [100%] Built target autobuild
168 # Build both widgets classic and test
169 $ make widget
170 [  2%] Built target test-files
171 Scanning dependencies of target packaging_wgt
172 [  5%] Generating package/config.xml
173 [  8%] Generating package-test/config.xml, package-test/bin/launcher
174 [  8%] Built target packaging_wgt
175 [ 11%] Generating package-test/var/test-files
176 [ 11%] Built target project_populate_test-files
177 Warning: JSON_CHECKER not found. Not verification made on files !
178 [ 14%] Built target afb-test-config
179 [ 17%] Generating package-test/etc/afb-test-config
180 [ 17%] Built target project_populate_afb-test-config
181 Warning: JSON_CHECKER not found. Not verification made on files !
182 [ 20%] Built target aftest-config
183 [ 23%] Generating package/etc/aftest-config
184 [ 23%] Built target project_populate_aftest-config
185 [ 26%] Built target fixture-files
186 [ 29%] Generating package-test/var/fixture-files
187 [ 29%] Built target project_populate_fixture-files
188 [ 32%] Built target afTest-lua
189 [ 35%] Generating package/var/afTest-lua
190 [ 35%] Built target project_populate_afTest-lua
191 [ 50%] Built target afb-helpers
192 [ 79%] Built target ctl-utilities
193 [ 88%] Built target aft
194 [ 91%] Built target project_populate_aft
195 [ 94%] Built target populate
196 Scanning dependencies of target widget
197 [ 97%] Generating aftest.wgt
198 NOTICE: -- PACKING widget aftest.wgt from directory /home/claneys/Workspace/Sources/IOTbzh/gerrit.automotivelinux.org/apps/app-afb-test/build/package
199 [100%] Generating aftest-test.wgt
200 NOTICE: -- PACKING widget aftest-test.wgt from directory /home/claneys/Workspace/Sources/IOTbzh/gerrit.automotivelinux.org/apps/app-afb-test/build/package-test
201 ++ Install widget file using in the target : afm-util install afTest.wgt
202 [100%] Built target widget
203 ```
204
205 Launch the test using the mode SERVICE for the `afb-test` because of a recursion
206 problem which loads 2 times the same binding and causes conflict. So it is
207 needed to uses 2 binders then each ones loads its binding properly:
208
209 ```bash
210 $ afm-test package package-test/ -m SERVICE
211 1..4
212 # Started on Tue Oct 30 10:32:46 2018
213 # Starting class: TestListverb
214 ok     1        TestListverb.testFunction
215 # Starting class: TestGetVerb
216 ok     2        TestGetVerb.testFunction
217 # Starting class: Test_turning_on
218 ok     3        Test_turning_on.testFunction
219 # Starting class: testLockWait
220 ok     4        testLockWait.testFunction
221 # Ran 4 tests in 0.001 seconds, 4 successes, 0 failures
222 ~~~~~~~~~~ BEGIN ALL TESTS ~~~~~~~~~~
223 1..59
224 # Started on Tue Oct 30 10:32:48 2018
225 # Starting class: testAssertEquals
226 ~~~~~ Begin Test ~~~~~
227 ~~~~~ Begin Test Assert Equals ~~~~~
228 ~~~~~ End Test Assert Equals ~~~~~
229 ~~~~~ End Test ~~~~~
230 ok     1        testAssertEquals.testFunction
231 # Starting class: testAssertNotEquals
232 ~~~~~ Begin Test ~~~~~
233 ~~~~~ End Test ~~~~~
234 ok     2        testAssertNotEquals.testFunction
235 # Starting class: testAssertItemsEquals
236 ~~~~~ Begin Test ~~~~~
237 [...]
238 ~~~~~ End Test ~~~~~
239 ok     57       testAssertVerbStatusError.testFunction
240 # Starting class: testAssertVerbResponseEqualsError
241 ~~~~~ Begin Test ~~~~~
242 ~~~~~ End Test ~~~~~
243 ok     58       testAssertVerbResponseEqualsError.testFunction
244 # Starting class: testAssertVerbCbError
245 ~~~~~ Begin Test ~~~~~
246 ~~~~~ End Test ~~~~~
247 ok     59       testAssertVerbCbError.testFunction
248 # Ran 59 tests in 0.003 seconds, 59 successes, 0 failures
249 ~~~~~~~~~~ END ALL TESTS ~~~~~~~~~~
250 Tests correctly launched.
251 ```
252
253 ## Launch test on a target board
254
255 If you are trying to launch your test on a target you'll have to use
256 a test widget which contains test files, fixture and configuration.
257 Then use **afm-test**:
258
259 ```bash
260 # afm-test -h
261 Usage: /usr/bin/afm-test [-l|--lava] [-v|--verb <verb>] <path>
262 -l|--lavaoutput: flag that enable Lava test marker to the output. (Default: disabled)
263 -v|--verb: select a specific verb to launch from the test API. (Default: all)
264 path: path to the test wgt file
265 ```
266
267 By default, the test widgets should be located in /usr/AGL/apps/testwgt. This
268 will install the widget, launch the tests then display the result on standard
269 output. After that it will kill test binding and remove it.
270
271 ### Example on a target
272
273 Here is an example:
274
275 ```bash
276 qemux86-64:~# afm-test /usr/AGL/apps/testwgt/aftest-test.wgt
277 afm-test /tmp/aftest-test.wgt
278 PASS: aftest-test@6.90 started with pid=1649
279 1..59
280 ~~~~~ Begin Test ~~~~~
281 ~~~~~ Begin Test Assert Equals ~~~~~
282 ~~~~~ End Test Assert Equals ~~~~~
283 ~~~~~ End Test ~~~~~
284 PASS: 1 testAssertEquals.testFunction
285 ~~~~~ Begin Test ~~~~~
286 ~~~~~ End Test ~~~~~
287 PASS: 2 testAssertNotEquals.testFunction
288 ~~~~~ Begin Test ~~~~~
289 ~~~~~ End Test ~~~~~
290 PASS: 3 testAssertItemsEquals.testFunction
291 ~~~~~ Begin Test ~~~~~
292 ~~~~~ End Test ~~~~~
293 [...]
294 PASS: 58 testAssertVerbResponseEqualsError.testFunction
295 ~~~~~ Begin Test ~~~~~
296 ~~~~~ End Test ~~~~~
297 PASS: 59 testAssertVerbCbError.testFunction
298 # Ran 59 tests in 0.003 seconds, 59 successes, 0 failures
299 ~~~~~~~~~~ END ALL TESTS ~~~~~~~~~~
300 1..63
301 ~~~~~ Begin Test ~~~~~
302 ~~~~~ Begin Test Assert Equals ~~~~~
303 ~~~~~ End Test Assert Equals ~~~~~
304 ~~~~~ End Test ~~~~~
305 PASS: 1 testAssertEquals.testFunction
306 ~~~~~ Begin Test ~~~~~
307 ~~~~~ End Test ~~~~~
308 PASS: 2 testAssertNotEquals.testFunction
309 ~~~~~ Begin Test ~~~~~
310 ~~~~~ End Test ~~~~~
311 PASS: 3 testAssertItemsEquals.testFunction
312 ~~~~~ Begin Test ~~~~~
313 ~~~~~ End Test ~~~~~
314 [...]
315 ~~~~~ Begin Test ~~~~~
316 ~~~~~ End Test ~~~~~
317 PASS: 61 TestGetVerb.testFunction
318 ~~~~~ Begin Test ~~~~~
319 ~~~~~ End Test ~~~~~
320 PASS: 62 Test_turning_on.testFunction
321 ~~~~~ Begin Test ~~~~~
322 ~~~~~ End Test ~~~~~
323 PASS: 63 testLockWait.testFunction
324 # Ran 63 tests in 0.003 seconds, 63 successes, 0 failures
325 ~~~~~~~~~~ END ALL TESTS ~~~~~~~~~~
326 PASS: aftest-test@6.90 killed and removed
327 ```
328
329 The command being : ```afm-test /usr/AGL/apps/testwgt/aftest-test.wgt```
330
331 You can see here that everything ran as on your pc terminal.
332 **Begin Test**  and **End Test** are the
333 beforeEach and afterEach functions and
334 **END ALL TESTS**  is the after all functions.
335
336  **PASS :** shows the function that is or was running.