blob: a4ec2c40edfc4d8c61122b5ba224711096749c21 [file] [log] [blame]
Gyorgy Szingba1095c2020-11-24 00:33:11 +01001Build test runner
2=================
3
4This directory captures build test case definitions and a tool to execute the test based on
5the data. The tool combines the power of shell scripting with the power of structured data
6(|yaml|). The bridge between the two technologies is provided by |jinja2| template engine
7and |yasha|.
8
9Dependencies
10------------
11
12|Jinja2| and |yasha| are python tools and python3 is needed to run the tests. Please install
13the following tools into your build environment:
14
15 - python3
16 - pip3
17
18After this please install further pip packages listed in ``requirements.txt`` as:
19
20.. code:: shell
21
22 pip3 install -r requirements.txt
23
24.. note::
25
26 This document lists the dependencies of this tool only. To be able to successfully run the
27 build tests further tools are needed. Please refer to the ``Trusted Services``
28 documentation for details.
29
30Files
31-------
32
33.. uml::
34
35 @startsalt
36 {
37 {T
38 + b-test
39 ++Makefile | generate and run tests
40 ++Readme.rst | this document
41 ++requirements.txt | pip package dependencies
42 ++run.sh.j2 | shell script template
43 ++test_data.schema.json | JSON schema for test case data
44 ++test_data.yaml | test case data
45 ++//user.env// | optional user specific settings
46 }
47 }
48 @endsalt
49
50Design
51------
52
53The project needs a convenient way to define and execute "build tests". This test aims to ensure
54all build configurations are in a good working condition. Testing is done by executing build
55of all supported build configurations. In order to make the testing robust and easy to use a
56"data driven" approach is the best fit. With this test cases are described by pure data and this
57data is processed by some tool which is responsible for test execution.
58
59For command execution the bash shell is a good candidate. It provides portability between OSs, is
60widely adopted and well tested. Unfortunately shells are not good on handling structured data.
61To address this shortcoming templating is utilized or "code generation" is used. The shell script
62to execute the command is generated based on a template file and the test data.
63
64Since python is already a dependency of Trusted Services we selected the |Jinja2| template engine
65to go with, and to decrease maintenance cost, we use it trough |yasha|.
66
67.. uml::
68
69 @startuml
70 [test_data.yaml] --> [yasha]
71 [run.sh.j2] --> [yasha]
72 [//user.env//] -right-> [run.sh]
73 [yasha] --> [run.sh]
74 @enduml
75
76Usage
77-----
78
79There are two "entry points" to the tests. If the intention is to run all tests, issue ``make``.
80
81Makefile
82""""""""
83The makefile is responsible to provide a high level "API". It allows executing the script generation
84process and to run the tests. It ensures all components are fresh before being executed.
85
86Issue ``make help`` to get a list of supported commands.
87
88run.sh
89""""""
90
91``run.sh`` is the test runner. It is responsible to execute the needed builds in a proper way and
92thus validate the build definitions.
93
94Execute ``run.sh help`` to get further details.
95
96
97--------------
98
Gyorgy Szingba1095c2020-11-24 00:33:11 +010099.. |yasha| replace:: `yasha`_
100.. |jinja2| replace:: `Jinja2`_
101.. |yaml| replace:: `yaml`_
102
103.. _Jinja2: https://palletsprojects.com/p/jinja
104.. _yasha: https://github.com/kblomqvist/yasha
105.. _yaml: https://yaml.org
Julian Halle76ade82020-11-25 03:07:21 +0100106
107*Copyright (c) 2020-2021, Arm Limited and Contributors. All rights reserved.*
108
109SPDX-License-Identifier: BSD-3-Clause