-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
113 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: Tests | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Install clang-format | ||
run: sudo apt-get install -y clang-format | ||
|
||
- name: Check code formatting | ||
run: | | ||
find . -name '*.cpp' -or -name '*.hpp' -or -name '*.c' -or -name '*.h' | xargs clang-format -style=file -i | ||
git diff --exit-code | ||
- name: Build and run tests | ||
run: | | ||
docker build -t csp_proc . | ||
docker run -t csp_proc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
FROM ubuntu:22.04 | ||
|
||
RUN apt-get update && apt-get install -y \ | ||
git \ | ||
python3 \ | ||
python3-pip \ | ||
ninja-build \ | ||
gcc \ | ||
g++ \ | ||
meson \ | ||
libcriterion-dev | ||
|
||
WORKDIR /csp_proc/ | ||
RUN git clone https://github.com/spaceinventor/libcsp.git lib/csp | ||
RUN git clone https://github.com/spaceinventor/libparam.git lib/param | ||
RUN git clone https://github.com/spaceinventor/slash.git lib/slash | ||
RUN git clone https://github.com/FreeRTOS/FreeRTOS-Kernel.git lib/freertos | ||
|
||
COPY . /csp_proc/ | ||
|
||
CMD meson setup builddir \ | ||
&& meson compile -C builddir \ | ||
&& meson test -C builddir |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,14 @@ | ||
# csp_proc | ||
Lightweight, programmable procedures with a libcsp- and libparam-native runtime. This library has a relatively small footprint suitable for microcontrollers, requiring no external libraries other than libcsp and libparam themselves. | ||
![Tests](https://github.com/discosat/csp_proc/actions/workflows/run-tests.yml/badge.svg) | ||
|
||
This provides remote control over coordination between nodes in a CSP network, essentially exposing the network as single programmable unit. | ||
Lightweight, programmable procedures with a libcsp- and libparam-native runtime. This provides remote control over coordination between nodes in a CSP network, essentially exposing the network as single programmable unit. | ||
|
||
The library has a relatively small footprint suitable for microcontrollers, requiring no external libraries other than libcsp and libparam themselves for the core of the library. However, currently, the only runtime implementation relies on FreeRTOS. | ||
|
||
# Build environment | ||
Refer to the Dockerfile for a reference build environment. It can be brought up like so: | ||
|
||
```bash | ||
docker build -t csp_proc . | ||
docker run -t csp_proc | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#include <criterion/criterion.h> | ||
|
||
#include <csp/csp_types.h> | ||
#include <csp_proc/proc_types.h> | ||
#include <csp_proc/proc_pack.h> | ||
|
||
Test(proc_pack_unpack, test_pack_unpack) { | ||
proc_t original_proc; | ||
csp_packet_t packet; | ||
|
||
original_proc.instruction_count = 1; | ||
original_proc.instructions[0].node = 1; | ||
original_proc.instructions[0].type = PROC_BLOCK; | ||
original_proc.instructions[0].instruction.block.param_a = "param_a"; | ||
original_proc.instructions[0].instruction.block.op = OP_EQ; | ||
original_proc.instructions[0].instruction.block.param_b = "param_b"; | ||
|
||
int pack_result = pack_proc_into_csp_packet(&original_proc, &packet); | ||
cr_assert(pack_result == 0, "Packing failed"); | ||
|
||
proc_t new_proc; | ||
int unpack_result = unpack_proc_from_csp_packet(&new_proc, &packet); | ||
cr_assert(unpack_result == 0, "Unpacking failed"); | ||
|
||
cr_assert(original_proc.instruction_count == new_proc.instruction_count, "Instruction counts do not match"); | ||
cr_assert(original_proc.instructions[0].node == new_proc.instructions[0].node, "Nodes do not match"); | ||
cr_assert(original_proc.instructions[0].type == new_proc.instructions[0].type, "Types do not match"); | ||
cr_assert(strcmp(original_proc.instructions[0].instruction.block.param_a, new_proc.instructions[0].instruction.block.param_a) == 0, "param_a does not match"); | ||
cr_assert(original_proc.instructions[0].instruction.block.op == new_proc.instructions[0].instruction.block.op, "op does not match"); | ||
cr_assert(strcmp(original_proc.instructions[0].instruction.block.param_b, new_proc.instructions[0].instruction.block.param_b) == 0, "param_b does not match"); | ||
} |