Skip to content

Commit f6f40bc

Browse files
authored
Add unit test workflow (#7)
* add unit test workflow * CBORDefinitions: fix comment
1 parent 8b8b111 commit f6f40bc

File tree

3 files changed

+58
-1
lines changed

3 files changed

+58
-1
lines changed

.github/workflows/unit-tests.yml

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Unit Tests
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- ".github/workflows/unit-tests.yml"
7+
- 'extras/test/**'
8+
- 'src/**'
9+
10+
push:
11+
paths:
12+
- ".github/workflows/unit-tests.yml"
13+
- 'extras/test/**'
14+
- 'src/**'
15+
16+
jobs:
17+
test:
18+
name: Run unit tests
19+
runs-on: ubuntu-latest
20+
21+
env:
22+
COVERAGE_DATA_PATH: extras/coverage-data/coverage.info
23+
24+
steps:
25+
- name: Checkout
26+
uses: actions/checkout@v4
27+
28+
- uses: arduino/cpp-test-action@main
29+
with:
30+
runtime-paths: |
31+
- extras/test/build/bin/testNetworkConfigurator
32+
coverage-exclude-paths: |
33+
- '*/extras/test/*'
34+
- '/usr/*'
35+
coverage-data-path: ${{ env.COVERAGE_DATA_PATH }}
36+
37+
# A token is used to avoid intermittent spurious job failures caused by rate limiting.
38+
- name: Set up Codecov upload token
39+
run: |
40+
if [[ "${{ github.repository }}" == "arduino-libraries/Arduino_NetworkConfigurator" ]]; then
41+
# In order to avoid uploads of data from forks, only use the token for runs in the parent repo.
42+
# Token is intentionally exposed.
43+
# See: https://community.codecov.com/t/upload-issues-unable-to-locate-build-via-github-actions-api/3954
44+
CODECOV_TOKEN="49f6e3b9-4c5b-40a0-ba75-0f5ce723a2ad"
45+
else
46+
# codecov/codecov-action does unauthenticated upload if empty string is passed via the `token` input.
47+
CODECOV_TOKEN=""
48+
fi
49+
echo "CODECOV_TOKEN=$CODECOV_TOKEN" >> "$GITHUB_ENV"
50+
51+
- name: Upload coverage report to Codecov
52+
uses: codecov/codecov-action@v3
53+
with:
54+
file: "${{ env.COVERAGE_DATA_PATH }}"
55+
fail_ci_if_error: true
56+
token: ${{ env.CODECOV_TOKEN }}

extras/test/src/test_provisioning_command_encode.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@
123123
{
124124
JWTProvisioningMessage command;
125125
command.c.id = ProvisioningMessageId::JWTProvisioningMessageId;
126+
memset(command.jwt, 0x00, 269);
126127
memset(command.jwt, 0xCA, 268);
127128
uint8_t buffer[512];
128129
size_t bytes_encoded = sizeof(buffer);

src/configuratorAgents/agents/boardConfigurationProtocol/cbor/ProvisioningMessage.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ struct UniqueHardwareIdProvisioningMessage {
105105
struct JWTProvisioningMessage {
106106
ProvisioningMessage c;
107107
struct {
108-
char jwt[PROVISIONING_JWT_SIZE]; //The payload is an array of char with a maximum length of 268, not null terminated. It's not a string.
108+
char jwt[PROVISIONING_JWT_SIZE]; //The payload is a string with maximum dimension of 268 characters + '\0'.
109109
};
110110
};
111111

0 commit comments

Comments
 (0)