| | 1 | |
| | 2 | = Required tools = |
| | 3 | |
| | 4 | Running the MutekH testsuite have the following requirements: |
| | 5 | |
| | 6 | - A compiler toolchain, |
| | 7 | - A python 2 interpreter, available in most GNU/Linux and BSD operating systems, |
| | 8 | - Some target platform simulators, |
| | 9 | - The `testwrap` tool, a modified version of GNU coreutils timeout command, |
| | 10 | - Mercurial to clone the testsuite repository. |
| | 11 | |
| | 12 | Depending on the target you wish to run the testsuite on, you may not need to install all of these tools. |
| | 13 | |
| | 14 | The [[Install]] page explains how to install these requirements. |
| | 15 | |
| | 16 | = Usage = |
| | 17 | |
| | 18 | == Getting the test suite == |
| | 19 | |
| | 20 | Once the required tools are installed and the MutekH source code is fetched, you need to get the testsuite: |
| | 21 | |
| | 22 | {{{ |
| | 23 | cd .../mutekh |
| | 24 | hg clone https://www.mutekh.org/hg/tests |
| | 25 | }}} |
| | 26 | |
| | 27 | The python module path must point to the [source:tests/lib/python] directory: |
| | 28 | |
| | 29 | {{{ |
| | 30 | export PYTHONPATH=tests/lib/python/ |
| | 31 | }}} |
| | 32 | |
| | 33 | == Test makefile generation == |
| | 34 | |
| | 35 | Some tests applications are located in [source:tests/pool]. |
| | 36 | The [source:tests/bin/mtest] tool is designed generate a |
| | 37 | makefile which runs a set of tests: |
| | 38 | |
| | 39 | - It first reads tests descriptions from all directories passed on the command line, |
| | 40 | - then detects which backend tools are available on your system, |
| | 41 | - and finally generates a makefile ready to run the tests. |
| | 42 | |
| | 43 | Each test application will be used to generate many test targets in the makefile by |
| | 44 | exploration of associated configurations space. |
| | 45 | |
| | 46 | {{{ |
| | 47 | $ tests/bin/mtest tests/pool/hello |
| | 48 | Test: hello |
| | 49 | Total tests count: 42 |
| | 50 | Available tests count: 42 |
| | 51 | Writing 'tests.mk' makefile. |
| | 52 | }}} |
| | 53 | |
| | 54 | The generated makefile can then be used to start the previously selected tests: |
| | 55 | |
| | 56 | {{{ |
| | 57 | make -f tests.mk |
| | 58 | }}} |
| | 59 | |
| | 60 | This will generate kernel binaries, log files and other files, all with the '`TEST`' prefix. |
| | 61 | Each passed test target generates a stamp file which must be deleted to start the test again. |
| | 62 | |
| | 63 | = Test infrastructure = |
| | 64 | |
| | 65 | The testsuite repository contains the following directories: |
| | 66 | |
| | 67 | - `pool/` : Tests source code and description, |
| | 68 | - `bin/` : Test generation and execution tools, |
| | 69 | - `lib/` : python testsuite modules, |
| | 70 | - `doc/` : python code documentation, |
| | 71 | - `tools/` : additional tools source code. |
| | 72 | |
| | 73 | The [source:tests/pool] directory contains a sub-directory for each test application. |
| | 74 | Other user test applications may reside elsewhere but a test application must always |
| | 75 | be packaged in its own directory. |
| | 76 | |
| | 77 | == Test application details == |
| | 78 | |
| | 79 | This part requires good knowledge of the BuildSystem usage. |
| | 80 | |
| | 81 | A test is always packaged in a directory. It's a regular MutekH application module |
| | 82 | with an additional test description file. It is composed of: |
| | 83 | |
| | 84 | - Some '.c' source files of the test application, |
| | 85 | - An associated '`Makefile`' file, |
| | 86 | - A '`config`' file. This file contain configuration sections as described in BuildSystem#Advancedsyntax, |
| | 87 | - A '`test`' description file. This python file contains the test description. |
| | 88 | |
| | 89 | The '`test`' description file contains details about how to build and run the test application: |
| | 90 | |
| | 91 | - It specifies configuration sections which may be passed to the build system when building the test application. |
| | 92 | - It associates backend names to some of the configuration sections to allow selection of the right execution platform. |
| | 93 | - It specifies configuration space to explore for the test. |
| | 94 | - It specifies ordered test actions (configuration, build, execute, ...). |
| | 95 | - It specifies expected results. |
| | 96 | |
| | 97 | The test will be built and executed for each possible configuration in the configuration test space. |
| | 98 | |
| | 99 | === Example test files === |
| | 100 | |
| | 101 | Parts of the test files are detailed here as an example. |
| | 102 | Refer to [source:tests/pool/hello/] for full content. |
| | 103 | |
| | 104 | ==== Configuration sections ==== |
| | 105 | |
| | 106 | The test description file is a python script which relies on python modules found |
| | 107 | in the [source:tests/lib/python] directory. |
| | 108 | |
| | 109 | An instance of the `Config` class is used to identify a valid configuration |
| | 110 | section which can be passed in the BUILD variable of the build command line. |
| | 111 | Such an instance must exist for each configuration section available in the '`config`' file |
| | 112 | which is triggered during exploration of the configuration space. |
| | 113 | |
| | 114 | For instance, if the '`config`' file contains the following lines: |
| | 115 | {{{ |
| | 116 | %section test_ipi |
| | 117 | CONFIG_HEXO_IPI defined |
| | 118 | %else |
| | 119 | CONFIG_HEXO_IPI undefined |
| | 120 | }}} |
| | 121 | the following line in the '`test`' file allows triggering of the inter-processor |
| | 122 | interrupts (IPI) feature in the test configuration space: |
| | 123 | {{{ |
| | 124 | # test configuration BUILD sections |
| | 125 | |
| | 126 | ipi = Config("test_ipi") |
| | 127 | }}} |
| | 128 | |
| | 129 | Target architecture configuration sections need to be associated with one or more backends |
| | 130 | to enable the test generation tool to chose the right execution platform (eg simulator). |
| | 131 | Test will be run on available backends and unavailable backends will be skipped. |
| | 132 | |
| | 133 | {{{ |
| | 134 | # test configuration BUILD sections test backends |
| | 135 | |
| | 136 | soclib_mips32el = Config("soclib-mips32el:pf-tutorial", "soclib_mips32el") |
| | 137 | soclib_mips32el_smp4 = Config("soclib-mips32el:pf-tutorial:test_smp4", "soclib_mips32el_smp4") |
| | 138 | ibmpc_x86 = Config("ibmpc-x86", "qemu_x86", "bochs_x86") |
| | 139 | }}} |
| | 140 | |
| | 141 | ==== Test description ==== |
| | 142 | |
| | 143 | Once all `Config` instances have been created, an instance of the `Environment` class must |
| | 144 | be created which describes the test. This instance have several properties: |
| | 145 | |
| | 146 | - `name`: The test unique name, |
| | 147 | - `test_space` : A list of configuration dimensions describing the test configuration space. |
| | 148 | - `actions` : A list of actions to perform for this test. |
| | 149 | - `success_grep`: A grep expression to search for in the execution output for the test to pass, |
| | 150 | - `timeout`: simulation timeout delay, |
| | 151 | |
| | 152 | The `test_space` property is a list of `Dimension` and `Exclude` instances used to finely describe |
| | 153 | the configuration space based on previously declared `Config` objects. |
| | 154 | |
| | 155 | The following example shows how to defines a two dimensional space with the first dimension being the target |
| | 156 | architecture and the second dimension triggering the IPI feature. An additional `Exclude` rule |
| | 157 | excludes configurations where inter-processors interrupts would be used in single processor platforms. |
| | 158 | |
| | 159 | {{{ |
| | 160 | test_space = [ |
| | 161 | Dimension(soclib_mips32eb, soclib_mips32eb_smp4, ibmpc_x86), |
| | 162 | Dimension(ipi, None), |
| | 163 | Exclude(ipi & ~soclib_mips32eb_smp4) |
| | 164 | ], |
| | 165 | }}} |