Skip to content

Commit

Permalink
tests script for board (#28)
Browse files Browse the repository at this point in the history
* add marker for tests when running on board

Signed-off-by: Thing-han, Lim <[email protected]>

* add python script for running tests on board

Signed-off-by: Thing-han, Lim <[email protected]>

* use the python tests script in ci instead

Signed-off-by: Thing-han, Lim <[email protected]>

* clean up the original ci test script

Signed-off-by: Thing-han, Lim <[email protected]>

* move serial_marker macro into hal.h

Signed-off-by: Thing-han, Lim <[email protected]>

* -t -> -i to consist with pqm4 and import sys

Signed-off-by: Thing-han, Lim <[email protected]>

* update readme for the tests script usage

Signed-off-by: Thing-han, Lim <[email protected]>

---------

Signed-off-by: Thing-han, Lim <[email protected]>
  • Loading branch information
potsrevennil authored Apr 29, 2024
1 parent 9bde5c5 commit 544e38a
Show file tree
Hide file tree
Showing 10 changed files with 354 additions and 155 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ jobs:
id: func_test
shell: nix develop .#ci -c bash -e {0}
run: |
tests func
tests func -e -v
- name: Speed test
id: speed_test
shell: nix develop .#ci -c bash -e {0}
if: |
success()
|| steps.func_test.conclusion == 'failure'
run: |
tests speed
tests speed -e -v
- name: Stack test
id: stack_test
shell: nix develop .#ci -c bash -e {0}
Expand All @@ -64,7 +64,7 @@ jobs:
|| steps.func_test.conclusion == 'failure'
|| steps.speed_test.conclusion == 'failure'
run: |
tests stack
tests stack -e -v
- name: Nistkat test
shell: nix develop .#ci -c bash -e {0}
if: |
Expand All @@ -74,4 +74,4 @@ jobs:
|| steps.stack_test.conclusion == 'failure'
run: |
make clean
tests nistkat
tests nistkat -e -v
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ For example,
- `make clean` cleans up intermediate artifacts
- `make distclean` additionally cleanup the `libopencm3` library

### Manual testing on board
After generating the specified hex files, you can flash it to the development board using `openocd`.
For example,
```
Expand All @@ -95,3 +96,37 @@ To receive output from the develop board, you can, for example, use `pyserial-mi
```
pyserial-miniterm /dev/<tty_device> 38400
```

### Usage of the [tests script](scripts/tests)
Make sure to run `make clean` between running tests on QEMU or on board or running func/stack/speed and nistkat tests. In case of any inconsistencies, refer to the help command for the most up-to-date usage information

```
▶ tests --help
Usage: tests [OPTIONS] COMMAND [ARGS]...
Options:
--help Show this message and exit.
Commands:
func Run functional tests
nistkat Run nistkat tests
run Run for the specified platform and hex file without parsing the
output
speed Run speed tests
stack Run stack tests
```

func/speed tests depends on the iteration parameter, which is passed to the tests in compile time, therefore it is preferred to build the binaries with the tests script

```
▶ tests func --help
Usage: tests func [OPTIONS]
Options:
-cfg, --platform-cfg PATH Configuration file of the specified platform
[default: hal/stm32f4discovery.cfg]
-v, --verbose Show verbose output or not
-e, --emulate Emulate on the QEMU or not
-i, --iterations INTEGER Number of tests [default: 1]
--help Show this message and exit.
```
7 changes: 5 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
gcc-arm-embedded-13 # arm-gnu-toolchain-13.2.rel1
qemu # 8.1.5
yq

python311
python311Packages.pyserial # 3.5
python311Packages.click
];
in
{
Expand All @@ -38,7 +42,6 @@

# debug dependencies
openocd # 0.12.0
python311Packages.pyserial # 3.5
];

shellHook = ''
Expand All @@ -50,7 +53,7 @@
packages = core;

shellHook = ''
export PATH=$PWD/scripts/ci:$PATH
export PATH=$PWD/scripts:$PWD/scripts/ci:$PATH
'';
};
};
Expand Down
8 changes: 8 additions & 0 deletions hal/hal.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@
#include <stdint.h>
#include <stdlib.h>

#if !defined(MPS2_AN386)
#define SERIAL_MARKER() {\
hal_send_str("$");\
}
#else
#define SERIAL_MARKER()
#endif

enum clock_mode {
CLOCK_FAST,
CLOCK_BENCHMARK
Expand Down
143 changes: 0 additions & 143 deletions scripts/ci/tests

This file was deleted.

Loading

0 comments on commit 544e38a

Please sign in to comment.