testitpy 0.1__tar.gz → 0.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {testitpy-0.1 → testitpy-0.3}/.github/workflows/release.yml +1 -1
- {testitpy-0.1/src/testitpy.egg-info → testitpy-0.3}/PKG-INFO +60 -5
- testitpy-0.3/README.md +62 -0
- testitpy-0.3/docs/_config.yml +1 -0
- testitpy-0.3/docs/images/testit_structure.png +0 -0
- testitpy-0.3/docs/index.md +373 -0
- {testitpy-0.1 → testitpy-0.3}/pyproject.toml +16 -1
- testitpy-0.3/src/testit/__init__.py +14 -0
- {testitpy-0.1 → testitpy-0.3}/src/testit/main.py +29 -14
- testitpy-0.3/src/testit/run.py +376 -0
- testitpy-0.3/src/testit/run_util.py +144 -0
- testitpy-0.3/src/testit/templates/config.test +58 -0
- testitpy-0.3/src/testit/templates/testit_golden.py +39 -0
- testitpy-0.3/src/testit/testit.py +632 -0
- testitpy-0.3/src/testit/testit_util.py +292 -0
- {testitpy-0.1 → testitpy-0.3/src/testitpy.egg-info}/PKG-INFO +60 -5
- {testitpy-0.1 → testitpy-0.3}/src/testitpy.egg-info/SOURCES.txt +3 -1
- testitpy-0.1/README.md +0 -8
- testitpy-0.1/old_setup.py +0 -34
- testitpy-0.1/src/testit/__init__.py +0 -0
- testitpy-0.1/src/testit/run.py +0 -244
- testitpy-0.1/src/testit/run_util.py +0 -99
- testitpy-0.1/src/testit/templates/config.test +0 -148
- testitpy-0.1/src/testit/templates/testit_golden.py +0 -18
- testitpy-0.1/src/testit/testit.py +0 -411
- testitpy-0.1/src/testit/testit_util.py +0 -203
- {testitpy-0.1 → testitpy-0.3}/.gitignore +0 -0
- {testitpy-0.1 → testitpy-0.3}/LICENSE +0 -0
- {testitpy-0.1 → testitpy-0.3}/setup.cfg +0 -0
- {testitpy-0.1 → testitpy-0.3}/src/testitpy.egg-info/dependency_links.txt +0 -0
- {testitpy-0.1 → testitpy-0.3}/src/testitpy.egg-info/entry_points.txt +0 -0
- {testitpy-0.1 → testitpy-0.3}/src/testitpy.egg-info/requires.txt +0 -0
- {testitpy-0.1 → testitpy-0.3}/src/testitpy.egg-info/top_level.txt +0 -0
|
@@ -33,7 +33,7 @@ jobs:
|
|
|
33
33
|
publish-to-pypi:
|
|
34
34
|
name: >-
|
|
35
35
|
Publish Python 🐍 distribution 📦 to PyPI
|
|
36
|
-
|
|
36
|
+
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
|
|
37
37
|
needs:
|
|
38
38
|
- build
|
|
39
39
|
runs-on: ubuntu-latest
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: testitpy
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3
|
|
4
4
|
Summary: A tool for verifying RTL and FPGA models using custom SW applications
|
|
5
5
|
Author-email: Tommaso Terzano <tommaso.terzano@gmail.com>
|
|
6
6
|
License: GNU GENERAL PUBLIC LICENSE
|
|
@@ -687,12 +687,67 @@ Requires-Dist: numpy
|
|
|
687
687
|
Requires-Dist: pyserial
|
|
688
688
|
Requires-Dist: hjson
|
|
689
689
|
Requires-Dist: importlib_resources
|
|
690
|
+
Dynamic: license-file
|
|
690
691
|
|
|
691
|
-
#
|
|
692
|
+
# Just TestIt!
|
|
693
|
+
|
|
694
|
+
TestIt is a python package designed to **automate full-system integration testing** using a **Software-Based Self-Test (SBST)** approach.
|
|
695
|
+
While formal verification methods are highly effective for targeting individual components, their complexity grows exponentially with the size of the System-Under-Test (SUT), making them impractical for testing large scale systems, like MCUs.
|
|
696
|
+
Furthermore, they do not test interactions between the hardware platform and the software stack, which is essential for validating real-world functionality.
|
|
697
|
+
Last but not least, they are limited to simulated environments, with all their limitations.
|
|
698
|
+
|
|
699
|
+
TestIt tackles these limitations and to **bridge the gap** between **formal verification** and **real-world applications**.
|
|
700
|
+
|
|
701
|
+
#### In short, what can TestIt do?
|
|
702
|
+
- Automate **generation** of **random datasets** and **reference values**, according to your specifications.
|
|
703
|
+
- Automate **building** of simulation **models** and synthesis for FPGA.
|
|
704
|
+
- Automate **compilation** of SW application, which take advantage of the datasets it generates.
|
|
705
|
+
- Automate **execution of tests**, both in simulation environments and using FPGAs, which greatly speed up the test time (up to **x11 times reduction**).
|
|
706
|
+
- Characterize the **real-world performance** of your system.
|
|
707
|
+
|
|
708
|
+
#### How can TestIt do all of this?
|
|
709
|
+
With just three requirements:
|
|
710
|
+
- A simple **configuration file**, `config.test`, in which you have to describe both *your workflow* and the *tests* you want to run.
|
|
711
|
+
- A **python module**, `testit_golden.py`, in which you can develop the *golden functions* used to generate the reference values for your test.
|
|
712
|
+
- A complete **Makefile-based workflow**, with some custom targets, as described below. This is the *gateway* that TestIt uses to access your workflow to build, compile and load.
|
|
713
|
+
|
|
714
|
+
#### How can you use TestIt?
|
|
715
|
+
Again, very simple! Just go to TestIt's documentation at https://vlsi-lab.github.io/TestIt/.
|
|
716
|
+
If you have any question or suggestions, just contact Tommaso Terzano at tommaso.terzano@gmail.com.
|
|
717
|
+
He will be glad to connect with you and help you with any doubt you might have.
|
|
718
|
+
|
|
719
|
+
## Installation
|
|
720
|
+
|
|
721
|
+
Simply run this command in your bash terminal:
|
|
722
|
+
|
|
723
|
+
```bash
|
|
724
|
+
pip install testitpy
|
|
725
|
+
```
|
|
726
|
+
|
|
727
|
+
That's it!
|
|
728
|
+
|
|
729
|
+
## Usage
|
|
730
|
+
|
|
731
|
+
```bash
|
|
732
|
+
$ testit -h
|
|
733
|
+
|
|
734
|
+
usage: testit [-h] {run,setup,report} ...
|
|
735
|
+
|
|
736
|
+
TestIt CLI tool
|
|
737
|
+
|
|
738
|
+
positional arguments:
|
|
739
|
+
{run,setup,report}
|
|
740
|
+
run Run the verification process
|
|
741
|
+
setup Set up the verification environment
|
|
742
|
+
report Generate a report based on the test results
|
|
743
|
+
|
|
744
|
+
options:
|
|
745
|
+
-h, --help show this help message and exit
|
|
746
|
+
```
|
|
692
747
|
|
|
693
748
|
[](https://github.com/vlsi-lab/TestIt/actions/workflows/release.yml)
|
|
694
749
|
|
|
695
|
-
|
|
696
|
-
This is the package structure:
|
|
750
|
+
[](https://pypistats.org/packages/testitpy) [](https://pypi.org/project/testitpy/) [](https://github.com/vlsi-lab/TestIt)
|
|
697
751
|
|
|
752
|
+
---
|
|
698
753
|
|
testitpy-0.3/README.md
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# Just TestIt!
|
|
2
|
+
|
|
3
|
+
TestIt is a python package designed to **automate full-system integration testing** using a **Software-Based Self-Test (SBST)** approach.
|
|
4
|
+
While formal verification methods are highly effective for targeting individual components, their complexity grows exponentially with the size of the System-Under-Test (SUT), making them impractical for testing large scale systems, like MCUs.
|
|
5
|
+
Furthermore, they do not test interactions between the hardware platform and the software stack, which is essential for validating real-world functionality.
|
|
6
|
+
Last but not least, they are limited to simulated environments, with all their limitations.
|
|
7
|
+
|
|
8
|
+
TestIt tackles these limitations and to **bridge the gap** between **formal verification** and **real-world applications**.
|
|
9
|
+
|
|
10
|
+
#### In short, what can TestIt do?
|
|
11
|
+
- Automate **generation** of **random datasets** and **reference values**, according to your specifications.
|
|
12
|
+
- Automate **building** of simulation **models** and synthesis for FPGA.
|
|
13
|
+
- Automate **compilation** of SW application, which take advantage of the datasets it generates.
|
|
14
|
+
- Automate **execution of tests**, both in simulation environments and using FPGAs, which greatly speed up the test time (up to **x11 times reduction**).
|
|
15
|
+
- Characterize the **real-world performance** of your system.
|
|
16
|
+
|
|
17
|
+
#### How can TestIt do all of this?
|
|
18
|
+
With just three requirements:
|
|
19
|
+
- A simple **configuration file**, `config.test`, in which you have to describe both *your workflow* and the *tests* you want to run.
|
|
20
|
+
- A **python module**, `testit_golden.py`, in which you can develop the *golden functions* used to generate the reference values for your test.
|
|
21
|
+
- A complete **Makefile-based workflow**, with some custom targets, as described below. This is the *gateway* that TestIt uses to access your workflow to build, compile and load.
|
|
22
|
+
|
|
23
|
+
#### How can you use TestIt?
|
|
24
|
+
Again, very simple! Just go to TestIt's documentation at https://vlsi-lab.github.io/TestIt/.
|
|
25
|
+
If you have any question or suggestions, just contact Tommaso Terzano at tommaso.terzano@gmail.com.
|
|
26
|
+
He will be glad to connect with you and help you with any doubt you might have.
|
|
27
|
+
|
|
28
|
+
## Installation
|
|
29
|
+
|
|
30
|
+
Simply run this command in your bash terminal:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
pip install testitpy
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
That's it!
|
|
37
|
+
|
|
38
|
+
## Usage
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
$ testit -h
|
|
42
|
+
|
|
43
|
+
usage: testit [-h] {run,setup,report} ...
|
|
44
|
+
|
|
45
|
+
TestIt CLI tool
|
|
46
|
+
|
|
47
|
+
positional arguments:
|
|
48
|
+
{run,setup,report}
|
|
49
|
+
run Run the verification process
|
|
50
|
+
setup Set up the verification environment
|
|
51
|
+
report Generate a report based on the test results
|
|
52
|
+
|
|
53
|
+
options:
|
|
54
|
+
-h, --help show this help message and exit
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
[](https://github.com/vlsi-lab/TestIt/actions/workflows/release.yml)
|
|
58
|
+
|
|
59
|
+
[](https://pypistats.org/packages/testitpy) [](https://pypi.org/project/testitpy/) [](https://github.com/vlsi-lab/TestIt)
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
theme: jekyll-theme-primer
|
|
Binary file
|
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
# Just TestIt!
|
|
2
|
+
|
|
3
|
+
TestIt is a python package designed to **automate full-system integration testing** using a **Software-Based Self-Test (SBST)** approach.
|
|
4
|
+
While formal verification methods are highly effective for targeting individual components, their complexity grows exponentially with the size of the System-Under-Test (SUT), making them impractical for testing large scale systems, like MCUs.
|
|
5
|
+
Furthermore, they do not test interactions between the hardware platform and the software stack, which is essential for validating real-world functionality.
|
|
6
|
+
Last but not least, they are limited to simulated environments, with all their limitations.
|
|
7
|
+
|
|
8
|
+
TestIt tackles these limitations and aims at **bridging the gap** between **formal verification** and **real-world applications**.
|
|
9
|
+
|
|
10
|
+
#### In short, what can TestIt do?
|
|
11
|
+
- Automate **generation** of **random datasets** and **reference values**, according to your specifications.
|
|
12
|
+
- Automate **building** of simulation **models** and synthesis for FPGA.
|
|
13
|
+
- Automate **compilation** of SW application, which take advantage of the datasets it generates.
|
|
14
|
+
- Automate **execution of tests**, both in simulation environments and using FPGAs, which greatly speed up the test time (up to **x11 times reduction**).
|
|
15
|
+
- Characterize the **real-world performance** of your system.
|
|
16
|
+
|
|
17
|
+
#### How can TestIt do all of this?
|
|
18
|
+
With just three requirements:
|
|
19
|
+
- A simple **configuration file**, `config.test`, in which you have to describe both *your workflow* and the *tests* you want to run.
|
|
20
|
+
- A **python module**, `testit_golden.py`, in which you can develop the *golden functions* used to generate the reference values for your test.
|
|
21
|
+
- A complete **Makefile-based workflow**, with some custom targets, as described below. This is the *gateway* that TestIt uses to access your workflow to build, compile and load.
|
|
22
|
+
|
|
23
|
+
#### How can you use TestIt?
|
|
24
|
+
Again, it's super simple! Just follow this documentation and you'll find plenty of useful tips to integrate TestIt into your project.
|
|
25
|
+
If you have any questions or suggestions, don’t hesitate to reach out to Tommaso Terzano at tommaso.terzano@gmail.com. He's always happy to help clear up any doubts you might have.
|
|
26
|
+
|
|
27
|
+
> ⚠️ Take every "**must do**" with the utmost seriousness, as not following those advices will break TestIt. In Italy we say "_Uomo avvisato mezzo salvato_"...
|
|
28
|
+
|
|
29
|
+
## Installation
|
|
30
|
+
|
|
31
|
+
Simply run the following command in your bash terminal:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
pip install testitpy
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
That's it!
|
|
38
|
+
|
|
39
|
+
## Common Q&A
|
|
40
|
+
|
|
41
|
+
<div style="text-align: center;">
|
|
42
|
+
<img src="images/testit_structure.png" alt="Structure of a TestIt environment" width="700">
|
|
43
|
+
</div>
|
|
44
|
+
<p align="center"><b>Figure 1</b>: Structure of a TestIt environment </p>
|
|
45
|
+
|
|
46
|
+
In order to run TestIt and take full advantage of its features, it's important to get to know how it works. This section answers many of the questions you might have.
|
|
47
|
+
|
|
48
|
+
- **How does TestIt interact with my RTL project?**
|
|
49
|
+
TestIt uses Make as a gateway to tap into your RTL project's workflow. We considered several approaches, but chose Make because it’s the most popular scripting tool in open-source RTL projects. And if your project doesn’t already use a Makefile, don’t worry, Make is so flexible and simple that you can easily integrate it into your workflow. Just note that TestIt does require you to add a few standardized targets to your Makefile.
|
|
50
|
+
Check out section xx for more details and examples.
|
|
51
|
+
|
|
52
|
+
- **What does Software-Based Self-Test mean?**
|
|
53
|
+
_SBST_ is a testing approach where software applications (_Software-Based_) run directly on your target system to verify specific units, without needing any external equipment (_Self-Test_). Essentially, the application checks its own functionality for you.
|
|
54
|
+
|
|
55
|
+
For example, imagine you want to test a Systolic Array (SA) integrated into your custom MCU. With SBST, you'd write an application that performs a matrix multiplication using your SA. This application then compares the SA's result with a reference value (i.e., the expected result of the multiplication). And that’s SBST in a nutshell!
|
|
56
|
+
|
|
57
|
+
Now, to set up a realistic test campaign, you'd typically need to generate hundreds of input matrices, compute their expected results, compile your software, run it on simulation or FPGA, read and store the outputs, and then repeat the process. With TestIt, you can streamline all of this with a single command:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
testit run
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Pretty neat, right?
|
|
64
|
+
|
|
65
|
+
- **How can TestIt generate random input datasets?**
|
|
66
|
+
TestIt creates a unique dataset for every test iteration based on your specifications in the _test_ field of `config.test`. There, you define the size, dimensions, and data type for your input dataset(s). Plus, you can even **parameterize** dataset features!
|
|
67
|
+
Following the SBST approach, TestIt writes these input datasets, along with any parameters and reference values—to C source and header files in the directory specified in the _test_ field of `config.test`. This way, everything is automated and ready for your test campaign.
|
|
68
|
+
|
|
69
|
+
- **How can TestIt input datasets be parametrized?**
|
|
70
|
+
When specifying the test you want TestIt to run, include a parameters field in your configuration (see section xxx for details). In this field, you can describe as many parameters as you need by assigning each a name and a value. Optionally, you can also provide a value range and a step size.
|
|
71
|
+
|
|
72
|
+
TestIt scans your input dataset specifications for strings that match any of the defined parameters. When a match is found, it replaces that string with the current parameter value, allowing your input datasets to dynamically change shape with each iteration.
|
|
73
|
+
Additionally, these parameters are passed to the golden function defined in `testit_golden.py`, so your function can use them as needed.
|
|
74
|
+
Finally, all parameters are declared in the header file generated by TestIt in the directory specified in the test field, making them accessible to your test application.
|
|
75
|
+
|
|
76
|
+
For example, you might set a *TILE_SIZE* parameter to experiment with different tiling strategies for your SA, or define an *ARRAY_LEN* parameter with a range and a step to vary the array size with each iteration. Imagination is the only limit!
|
|
77
|
+
|
|
78
|
+
- **What should the golden function(s) look like?**
|
|
79
|
+
Pro tip: when you run `testit setup`, TestIt will generate fully commented template files for both `config.test` and `testit_golden.py`, ready to be modified and tailored to your project.
|
|
80
|
+
|
|
81
|
+
There are just a couple of requirements for your golden functions. First of all, they **must** accept two arguments: *input_datasets* and *parameters*, which TestIt passes as lists. The only other requirement is that your function **must** return a _one-dimensional list_. If your output is a tensor, simply flatten it. Everything else in your function is completely up to you.
|
|
82
|
+
|
|
83
|
+
- **How can TestIt read the result(s) of my application(s)?**
|
|
84
|
+
TestIt relies on a regular expression mechanism, meaning your test application **must** print its output, whether via a serial connection or a file dump in simulation environments, using the regex you define in the _test_ field of `config.test`. You can make this regex as elaborate as needed, but remember to include tags for each field.
|
|
85
|
+
|
|
86
|
+
Your application is free to print multiple regex strings, provided they follow the same structure. This setup allows a single test application to run as many sub-tests as you want, offering significant flexibility. For example, you can leverage this feature for **performance characterization**. As explained in section zzz, your application could record test durations using an on-board timer and then report those timings within the regex, which are then communicated back to the host device.
|
|
87
|
+
|
|
88
|
+
One critical requirement is that your application **must** signal when an iteration is complete. This is easily accomplished by printing a **"&"** character, which TestIt’s serial thread interprets as an end-of-communication signal.
|
|
89
|
+
|
|
90
|
+
## Functional Description
|
|
91
|
+
|
|
92
|
+
This section covers every aspect and feature of TestIt. If the previous section didn't answer all your doubts, this one will.
|
|
93
|
+
Let's get technical!
|
|
94
|
+
|
|
95
|
+
### Requirements
|
|
96
|
+
|
|
97
|
+
This section covers all the requirements that TestIt needs to run a successful integration test.
|
|
98
|
+
|
|
99
|
+
#### Configure the testing environment: *config.test*
|
|
100
|
+
|
|
101
|
+
This file is at heart a JSON database, which contains all the information that TestIt needs to operate, about both your workflow and the tests you want to run.
|
|
102
|
+
Specifically, there are three fields that you need to fill out:
|
|
103
|
+
|
|
104
|
+
- **target**
|
|
105
|
+
|
|
106
|
+
```json
|
|
107
|
+
{
|
|
108
|
+
name: "pynq-z2"
|
|
109
|
+
type: "fpga"
|
|
110
|
+
usbPort: 2
|
|
111
|
+
baudrate: 9600
|
|
112
|
+
iterations: 10
|
|
113
|
+
outputFile: "path/to/sim/dump"
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
This field captures all the details about the target platform you are using, which can be any FPGA development board or simulation tool that *your workflow* supports.
|
|
117
|
+
|
|
118
|
+
- __*name*__: You can choose any name you like. Keep in mind, this name will be passed as an argument to almost every TestIt-related Makefile target, so structure your Makefile accordingly.
|
|
119
|
+
|
|
120
|
+
- __*type*__: This **must be** either **fpga** or **sim**. Don't worry, TestIt checks all parameters that requires some fixed values, so if you get this wrong, it will tell you.
|
|
121
|
+
|
|
122
|
+
- __*usbPort*__: This is quite is straightforward, it specifies the USB port number to use.
|
|
123
|
+
|
|
124
|
+
- __*baudrate*__: Similarly, this parameter defines the communication speed. There isn’t much more to add here.
|
|
125
|
+
|
|
126
|
+
- __*iterations*__: This is a key parameter. By default, TestIt repeats the defined tests for the number of iterations specified with this parameter. In each iteration, the tool selects random parameters (if available) and generates a corresponding input dataset and reference values. Note that this value can be overridden when using [sweep mode](#sweep-mode).
|
|
127
|
+
|
|
128
|
+
- __*outputFile*__: This parameter may seem a bit tricky. TestIt reads test results via serial communication between the host device and the system under test (SUT). This method is used even for simulation-based tests. Essentially, your simulation system needs to dump the serial communication data to a file, and TestIt then reads and parses this file to extract the test information. The _outputFile_ parameter specifies the directory containing this file.
|
|
129
|
+
|
|
130
|
+
- <a id="report-dir"> **report**</a>
|
|
131
|
+
```json
|
|
132
|
+
{
|
|
133
|
+
dir: "path/to/report/folder"
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
This field simply specifies the directory where TestIt will store the test results and generate the report when you run the `testit report` [command](#run-the-testing-campaign).
|
|
137
|
+
|
|
138
|
+
- **test**
|
|
139
|
+
```json
|
|
140
|
+
[
|
|
141
|
+
{
|
|
142
|
+
appName: "application_name"
|
|
143
|
+
dir: "path/to/app"
|
|
144
|
+
genFilesName: "test_data"
|
|
145
|
+
outputFormat: "(\\d+):(\\d+):(\\d+)"
|
|
146
|
+
outputTags: ["TestID", "Cycles", "Outcome"]
|
|
147
|
+
|
|
148
|
+
parameters: [
|
|
149
|
+
{
|
|
150
|
+
name: "SIZE"
|
|
151
|
+
value: [4, 10]
|
|
152
|
+
step: 2
|
|
153
|
+
}
|
|
154
|
+
]
|
|
155
|
+
|
|
156
|
+
inputDataset: [
|
|
157
|
+
{
|
|
158
|
+
name: "input_matrix_A"
|
|
159
|
+
dataType: "uint8_t"
|
|
160
|
+
valueRange: [0, 255]
|
|
161
|
+
dimensions: ["SIZE", "SIZE"]
|
|
162
|
+
}
|
|
163
|
+
{
|
|
164
|
+
name: "input_matrix_B"
|
|
165
|
+
dataType: "uint8_t"
|
|
166
|
+
valueRange: [0, 255]
|
|
167
|
+
dimensions: ["SIZE", "SIZE"]
|
|
168
|
+
}
|
|
169
|
+
]
|
|
170
|
+
|
|
171
|
+
outputDataset: [
|
|
172
|
+
{
|
|
173
|
+
name: "output_matrix"
|
|
174
|
+
dataType: "uint8_t"
|
|
175
|
+
}
|
|
176
|
+
]
|
|
177
|
+
|
|
178
|
+
goldenResultFunction: {
|
|
179
|
+
name: "matmul"
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
]
|
|
183
|
+
```
|
|
184
|
+
This field describes all the tests you want TestIt to run. In the example above, there’s only a single test, but notice that it’s actually a list (hence the square brackets), so feel free to add as many tests as you desires. Let’s break this down piece by piece:
|
|
185
|
+
<br>
|
|
186
|
+
|
|
187
|
+
First of all, you need to specify some __details__ about the test:
|
|
188
|
+
- __*appName*__: This is crucial because it’s passed to the Make targets for compiling the test application. Make sure you match the name your own workflow expects.
|
|
189
|
+
- __*dir*__: This simply points to the directory where your test application lives.
|
|
190
|
+
- __*genFilesName*__: This is the name for the C source and header files that TestIt will generate to store random datasets, reference values, and parameters. Your test application should link the header so it can access all this data, so be sure to use the right name.
|
|
191
|
+
- __*outputFormat*__: Super important! This is the _regular expression_ that TestIt will use to parse the results from your test application. It’s important to ensure your application prints data in the same format.
|
|
192
|
+
- <a id="output-tags"> __*outputTags*__</a>: Again, super important! These are the tags associated with the fields in the regex. Each tag corresponds to a capture group in the regular expression.
|
|
193
|
+
<br>
|
|
194
|
+
|
|
195
|
+
The next step is to define __parameters__, which are essential for TestIt’s functionality but not strictly required. This field is also a _list_, so feel free to define multiple parameters per test.
|
|
196
|
+
|
|
197
|
+
Each parameter __must__ have:
|
|
198
|
+
- __*name*__: This is the name that TestIt will include in the generated header file, so make sure your test application is ready to use it.
|
|
199
|
+
- __*value*__: This can be a _fixed value_, a _fixed string_, or a _value range_. If it’s a value range (like in the example), TestIt will pick one value from that range in each iteration. And if any dimensions of your input dataset (like "input_matrix_A" or "input_matrix_B") depend on this parameter, TestIt will parse the correct parameter value for every matching dimension.
|
|
200
|
+
|
|
201
|
+
If the value is defined as a range, it’s _possible_ to define a **step** parameter (as shown in the example). This parameter is used by TestIt whenever you run your tests in sweep mode, by calling `testit run --sweep`.
|
|
202
|
+
In sweep mode, TestIt cycles through every possible **parameter combination**, effectively overriding the **iterations** parameter you set in the **target** field.
|
|
203
|
+
<br>
|
|
204
|
+
|
|
205
|
+
Next on the list: __input datasets__. Just like parameters, this field is a _list_, so you can define as many input datasets as you wish.
|
|
206
|
+
|
|
207
|
+
Each input dataset **must** have:
|
|
208
|
+
- **_name_**: This is the name TestIt will give to the C array it writes in the source and header files. Make sure your test application knows this name.
|
|
209
|
+
- **_dataType_**: A _string_ used to define the C array that holds the dataset values. TestIt checks that this is a standard C type, as for the moment custom datatypes aren’t supported yet.
|
|
210
|
+
- **_valueRange_**: The range from which TestIt picks values to create the random dataset. Make sure this range suits the chosen data type.
|
|
211
|
+
- **_dimensions_**: A _list_ describing the dataset’s dimensions. If a dimension corresponds to a _parameter_, TestIt will parse the correct value automatically. You can have as many dimensions as you like!
|
|
212
|
+
<br>
|
|
213
|
+
|
|
214
|
+
Next up is a straightforward step: defining the __output datasets__. They only have a couple of fields, as output size and dimensions are extracted by TestIt from the array that your golden function returns:
|
|
215
|
+
|
|
216
|
+
- **_name_**: Just like for input datasets, this is the name TestIt will assign to the C array it writes in the source and header files. Make sure your test application looks for this name.
|
|
217
|
+
- **_dataType_**: Similar to the input datasets, this _string_ determines the C array’s type. TestIt validates that it’s a standard C type; custom datatypes aren’t supported yet.
|
|
218
|
+
<br>
|
|
219
|
+
|
|
220
|
+
Speaking of golden functions, the __goldenResultFunction__ is the very last step in defining the _test_ field.
|
|
221
|
+
|
|
222
|
+
- **_name_**: This is the name of the function TestIt will call to generate the reference dataset. It **must** match exactly the name you used for your function in `testit_golden.py`.
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
#### Define the golden functions: *testit_golden.py*
|
|
226
|
+
|
|
227
|
+
This file is quite simply a collection of all the functions that your test camapign will need to generate reference values. The functions declared in file will be dynamically imported by TestIt at execution time, just by looking for the name included in the _goldenResultFunction_ field in `config.test`. You can include any package you need in this file, so be free to experiment with it and taylor this Python module to your needs.
|
|
228
|
+
|
|
229
|
+
The only critical aspect you need to take into account is the nature of the arguments and return value of the function, which **must** be:
|
|
230
|
+
- **input_dataset** -> **list of numpy arrays**
|
|
231
|
+
- **parameters** -> **list of dictionaries**
|
|
232
|
+
- **return value** -> **list of numpy arrays**
|
|
233
|
+
|
|
234
|
+
This section will guide you through a couple of example functions, a simple one and a more complex one, that you can use as a reference to build your own function.
|
|
235
|
+
|
|
236
|
+
The first one is the _workhorse of machine learning_, the __matrix multiplication__. When calling the [command](#setup-the-environment) `testit setup`, TestIt will include this very function in the template `testit_golden.py` that it will generate.
|
|
237
|
+
Let's analyze this function!
|
|
238
|
+
|
|
239
|
+
```python
|
|
240
|
+
def matrix_multiply(inputs: list, parameters: list) -> list:
|
|
241
|
+
"""
|
|
242
|
+
Multiplies two NumPy matrices and returns the result.
|
|
243
|
+
|
|
244
|
+
:param inputs: Randomly generated datasets (List of Numpy Arrays)
|
|
245
|
+
:param parameters: Parameters (Dict)
|
|
246
|
+
:return: Resulting Golden Datasets (List of Numpy Arrays)
|
|
247
|
+
"""
|
|
248
|
+
matrix_A = inputs[0]
|
|
249
|
+
matrix_B = inputs[1]
|
|
250
|
+
|
|
251
|
+
# Check if multiplication is valid
|
|
252
|
+
if matrix_A.shape[1] != matrix_B.shape[0]:
|
|
253
|
+
raise ValueError("Matrix dimensions do not match for multiplication!")
|
|
254
|
+
|
|
255
|
+
result = np.matmul(matrix_A, matrix_A)
|
|
256
|
+
|
|
257
|
+
return [result]
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
This simple function extracts two NumPy matrices from the list that TestIt generates, checks if they have compatible shapes, and multiplies them. If the dimensions don’t match, it raises an error to keep you informed. Notice how it returns the result as a single-element list, this is exactly what TestIt expects from a golden function.
|
|
261
|
+
|
|
262
|
+
The following function is a more complex example of what it's possible to achieve with TestIt. It performs the __im2col reshaping transformation__, which enables to compute _convolutions_ as a single __matrix multipication__. Here it is:
|
|
263
|
+
|
|
264
|
+
```python
|
|
265
|
+
def im2col_function(inputs, parameters):
|
|
266
|
+
inputs = np.array(inputs)
|
|
267
|
+
|
|
268
|
+
# Extract parameters
|
|
269
|
+
batch_size = next(item['value'] for item in parameters if item['name'] == 'BATCH')
|
|
270
|
+
channels = next(item['value'] for item in parameters if item['name'] == 'CH')
|
|
271
|
+
image_height = next(item['value'] for item in parameters if item['name'] == 'IH')
|
|
272
|
+
image_width = next(item['value'] for item in parameters if item['name'] == 'IW')
|
|
273
|
+
top_pad = next(item['value'] for item in parameters if item['name'] == 'TOP_PAD')
|
|
274
|
+
bottom_pad = next(item['value'] for item in parameters if item['name'] == 'BOTTOM_PAD')
|
|
275
|
+
left_pad = next(item['value'] for item in parameters if item['name'] == 'LEFT_PAD')
|
|
276
|
+
right_pad = next(item['value'] for item in parameters if item['name'] == 'RIGHT_PAD')
|
|
277
|
+
stride_d1 = next(item['value'] for item in parameters if item['name'] == 'STRIDE_D1')
|
|
278
|
+
stride_d2 = next(item['value'] for item in parameters if item['name'] == 'STRIDE_D2')
|
|
279
|
+
(filter_height, filter_width) = (next(item['value'] for item in parameters if item['name'] == 'FH'), next(item['value'] for item in parameters if item['name'] == 'FW'))
|
|
280
|
+
kernel_size = (filter_height, filter_width)
|
|
281
|
+
|
|
282
|
+
# Convert the input array into a PyTorch tensor with the correct shape
|
|
283
|
+
input_tensor = torch.tensor(inputs).view(batch_size, channels, image_height, image_width)
|
|
284
|
+
|
|
285
|
+
dilation = 1
|
|
286
|
+
# Ensure kernel_size, stride, padding, and dilation are tuples
|
|
287
|
+
if isinstance(kernel_size, int):
|
|
288
|
+
kernel_size = (kernel_size, kernel_size)
|
|
289
|
+
if isinstance(dilation, int):
|
|
290
|
+
dilation = (dilation, dilation)
|
|
291
|
+
|
|
292
|
+
# Adjust padding format for F.pad (expects pad_left, pad_right, pad_top, pad_bottom)
|
|
293
|
+
padding_format = (left_pad, right_pad, top_pad, bottom_pad)
|
|
294
|
+
|
|
295
|
+
# Apply zero padding
|
|
296
|
+
padded_input = F.pad(input_tensor, padding_format, "constant", 0)
|
|
297
|
+
|
|
298
|
+
# Unfold the padded input tensor
|
|
299
|
+
unfolded = padded_input.unfold(2, kernel_size[0], stride_d2).unfold(3, kernel_size[1], stride_d1)
|
|
300
|
+
unfolded = unfolded.permute(0, 2, 3, 1, 4, 5)
|
|
301
|
+
|
|
302
|
+
# Reshape to get the 2D tensor where each row is a flattened receptive field
|
|
303
|
+
channel_dim = padded_input.size(1)
|
|
304
|
+
unfolded_tensor = unfolded.contiguous().view(-1, channel_dim * kernel_size[0] * kernel_size[1]).t()
|
|
305
|
+
|
|
306
|
+
# Convert the PyTorch tensor to a NumPy array and then to a list (simple array)
|
|
307
|
+
unfolded_array = unfolded_tensor.numpy()
|
|
308
|
+
unfolded_array = [unfolded_array.reshape(*unfolded_array.shape)]
|
|
309
|
+
|
|
310
|
+
return unfolded_array
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
The interesting thing about this example is how it's possible to use parameters generated by TestIt to perform complex computations. In this case, TestIt generates a multitude of parameters, that define the input tensor shape (_BATCH_, _CH_, _IW_ and _IH_) and the filter shape (_FW_ and _FH_), as well as padding parameters and strides.
|
|
314
|
+
Since parameters are passed as a _list of dictonaries_, it's necessary to find the correct dictonary, i.e. the parameter wanted, and then extract its value. This is the best way we found, but you're welcome to try and find better ways. For example, you could write a simple function, _getParameter()_, in the same *testit_golden.py* or even in a separate module.
|
|
315
|
+
|
|
316
|
+
## Commands
|
|
317
|
+
|
|
318
|
+
TestIt provides three main commands to access its functionalities.
|
|
319
|
+
|
|
320
|
+
---
|
|
321
|
+
|
|
322
|
+
### **Setup the environment**
|
|
323
|
+
```bash
|
|
324
|
+
testit setup
|
|
325
|
+
```
|
|
326
|
+
This is the first command you’ll want to run. It does exactly what it says—it sets up your TestIt environment. Running this command generates template versions of *testit_golden.py* and *config.test*, based on the targets and examples in this documentation.
|
|
327
|
+
|
|
328
|
+
You don’t have to place these files in the root of your RTL project, but keep in mind that **all subsequent TestIt commands must be executed in the same directory where you first ran** `testit setup`. That’s where TestIt expects to find its configuration files.
|
|
329
|
+
|
|
330
|
+
---
|
|
331
|
+
|
|
332
|
+
### **Run the testing campaign**
|
|
333
|
+
```bash
|
|
334
|
+
testit run [flags]
|
|
335
|
+
```
|
|
336
|
+
This is the core command of TestIt, the one that actually executes the testing campaign. As mentioned earlier, you must run it in the directory where *testit_golden.py* and *config.test* are stored, which doesn’t necessarily have to be the root of your RTL project.
|
|
337
|
+
|
|
338
|
+
You can customize the test campaign with the following flags:
|
|
339
|
+
|
|
340
|
+
```bash
|
|
341
|
+
testit run --nobuild
|
|
342
|
+
```
|
|
343
|
+
If you have already built your simulation or FPGA model and want to skip the build step, this flag will prevent TestIt from rebuilding it.
|
|
344
|
+
|
|
345
|
+
```bash
|
|
346
|
+
testit run --sweep
|
|
347
|
+
```
|
|
348
|
+
This enables <a id="sweep-mode">**sweep mode**</a>, which overrides the _iterations_ parameter and instead tests all possible parameter combinations for each individual test. This mode ensures a more comprehensive testing effort and is particularly useful for **performance characterization**. Be aware that this may generate a _large number of iterations_. The command line interface will always display the current iteration count and provide a dynamic estimate of the total test duration.
|
|
349
|
+
|
|
350
|
+
```bash
|
|
351
|
+
testit run --mammamia
|
|
352
|
+
```
|
|
353
|
+
Use this flag to let your test campaign cook like an Italian nonna would.
|
|
354
|
+
|
|
355
|
+
---
|
|
356
|
+
|
|
357
|
+
### **Generate a test report**
|
|
358
|
+
```bash
|
|
359
|
+
testit report [flags]
|
|
360
|
+
```
|
|
361
|
+
This command generates a report of your most recent test campaign, displaying it in your terminal and saving it as `report.rpt` in the [directory](#report-dir) specified in `config.test`.
|
|
362
|
+
|
|
363
|
+
> ⚠️ Every time you run `testit run`, the previous test campaign data is erased! If you need to keep it, make sure to back it up somewhere else.
|
|
364
|
+
|
|
365
|
+
There are a couple of options to customize your report:
|
|
366
|
+
|
|
367
|
+
```bash
|
|
368
|
+
testit report --sort_key [key_name]
|
|
369
|
+
```
|
|
370
|
+
This sorts the test results based on any of the [output tags](#output-tags) defined in `config.test`. If you want to sort the results in descending order, add `--descending` to the command. Otherwise, sorting will be in ascending order.
|
|
371
|
+
|
|
372
|
+
---
|
|
373
|
+
|
|
@@ -1,10 +1,25 @@
|
|
|
1
|
+
# Copyright (C) 2025 Politecnico di Torino
|
|
2
|
+
#
|
|
3
|
+
# This program is free software: you can redistribute it and/or modify
|
|
4
|
+
# it under the terms of the GNU General Public License as published by
|
|
5
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
6
|
+
# (at your option) any later version.
|
|
7
|
+
#
|
|
8
|
+
# This program is distributed in the hope that it will be useful,
|
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11
|
+
# GNU General Public License for more details.
|
|
12
|
+
#
|
|
13
|
+
# You should have received a copy of the GNU General Public License
|
|
14
|
+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
15
|
+
|
|
1
16
|
[build-system]
|
|
2
17
|
requires = ["setuptools>=45", "setuptools_scm[toml]>=6.2"]
|
|
3
18
|
build-backend = "setuptools.build_meta"
|
|
4
19
|
|
|
5
20
|
[project]
|
|
6
21
|
name = "testitpy"
|
|
7
|
-
version = "0.
|
|
22
|
+
version = "0.3"
|
|
8
23
|
authors = [
|
|
9
24
|
{name = "Tommaso Terzano", email = "tommaso.terzano@gmail.com"},
|
|
10
25
|
]
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Copyright (C) 2025 Politecnico di Torino
|
|
2
|
+
#
|
|
3
|
+
# This program is free software: you can redistribute it and/or modify
|
|
4
|
+
# it under the terms of the GNU General Public License as published by
|
|
5
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
6
|
+
# (at your option) any later version.
|
|
7
|
+
#
|
|
8
|
+
# This program is distributed in the hope that it will be useful,
|
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11
|
+
# GNU General Public License for more details.
|
|
12
|
+
#
|
|
13
|
+
# You should have received a copy of the GNU General Public License
|
|
14
|
+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|