Gyorgy Szing | ba1095c | 2020-11-24 00:33:11 +0100 | [diff] [blame] | 1 | Build test runner |
| 2 | ================= |
| 3 | |
| 4 | This directory captures build test case definitions and a tool to execute the test based on |
| 5 | the 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 |
| 7 | and |yasha|. |
| 8 | |
| 9 | Dependencies |
| 10 | ------------ |
| 11 | |
| 12 | |Jinja2| and |yasha| are python tools and python3 is needed to run the tests. Please install |
| 13 | the following tools into your build environment: |
| 14 | |
| 15 | - python3 |
| 16 | - pip3 |
| 17 | |
| 18 | After 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 | |
| 30 | Files |
| 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 | |
| 50 | Design |
| 51 | ------ |
| 52 | |
| 53 | The project needs a convenient way to define and execute "build tests". This test aims to ensure |
| 54 | all build configurations are in a good working condition. Testing is done by executing build |
| 55 | of 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 |
| 57 | data is processed by some tool which is responsible for test execution. |
| 58 | |
| 59 | For command execution the bash shell is a good candidate. It provides portability between OSs, is |
| 60 | widely adopted and well tested. Unfortunately shells are not good on handling structured data. |
| 61 | To address this shortcoming templating is utilized or "code generation" is used. The shell script |
| 62 | to execute the command is generated based on a template file and the test data. |
| 63 | |
| 64 | Since python is already a dependency of Trusted Services we selected the |Jinja2| template engine |
| 65 | to 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 | |
| 76 | Usage |
| 77 | ----- |
| 78 | |
| 79 | There are two "entry points" to the tests. If the intention is to run all tests, issue ``make``. |
| 80 | |
| 81 | Makefile |
| 82 | """""""" |
| 83 | The makefile is responsible to provide a high level "API". It allows executing the script generation |
| 84 | process and to run the tests. It ensures all components are fresh before being executed. |
| 85 | |
| 86 | Issue ``make help`` to get a list of supported commands. |
| 87 | |
| 88 | run.sh |
| 89 | """""" |
| 90 | |
| 91 | ``run.sh`` is the test runner. It is responsible to execute the needed builds in a proper way and |
| 92 | thus validate the build definitions. |
| 93 | |
| 94 | Execute ``run.sh help`` to get further details. |
| 95 | |
| 96 | |
| 97 | -------------- |
| 98 | |
Gyorgy Szing | ba1095c | 2020-11-24 00:33:11 +0100 | [diff] [blame] | 99 | .. |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 Hall | e76ade8 | 2020-11-25 03:07:21 +0100 | [diff] [blame] | 106 | |
| 107 | *Copyright (c) 2020-2021, Arm Limited and Contributors. All rights reserved.* |
| 108 | |
| 109 | SPDX-License-Identifier: BSD-3-Clause |