Skip to content

Commit 145a4fa

Browse files
authored
Merge pull request #10449 from LinuxJedi/TropicSim
Add TROPIC01 simulator
2 parents ec101ba + c49d33a commit 145a4fa

2 files changed

Lines changed: 95 additions & 0 deletions

File tree

.github/workflows/tropic01-sim.yml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: TROPIC01 simulator test
2+
3+
# START OF COMMON SECTION
4+
on:
5+
push:
6+
branches: [ 'master', 'main', 'release/**' ]
7+
pull_request:
8+
branches: [ '*' ]
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: true
13+
# END OF COMMON SECTION
14+
15+
# Build the TROPIC01 software simulator (https://github.com/wolfSSL/simulators,
16+
# TROPIC01Sim/ subdirectory), build wolfSSL --with-tropic01 against libtropic
17+
# v0.1.0 + the simulator's TCP HAL, and run Tropic Square's wolfssl-test app
18+
# against the simulator TCP server.
19+
#
20+
# The simulator's own Dockerfile.wolfcrypt clones wolfSSL master and applies
21+
# one sed patch to it (s/ForceZero/wc_ForceZero/ in
22+
# wolfcrypt/src/port/tropicsquare/tropic01.c). That patch is now upstreamed
23+
# in wolfSSL itself, so we:
24+
# 1. COPY the PR checkout instead of cloning master.
25+
# 2. Neutralise the now-redundant ForceZero sed RUN block.
26+
# The -DLT_SEPARATE_L3_BUFF=0 CFLAG stays in the Dockerfile -- it's a
27+
# libtropic v0.1.0 compatibility shim, not a wolfSSL concern.
28+
29+
env:
30+
SIMULATORS_REF: 32a14301983acab4663fe31b5fd7f3e51cf8a534
31+
32+
jobs:
33+
tropic01_sim:
34+
name: wolfCrypt against TROPIC01 simulator
35+
if: github.repository_owner == 'wolfssl'
36+
runs-on: ubuntu-24.04
37+
timeout-minutes: 30
38+
steps:
39+
- name: Checkout wolfSSL (PR source)
40+
uses: actions/checkout@v4
41+
with:
42+
path: wolfssl-src
43+
44+
- name: Clone TROPIC01 simulator
45+
run: |
46+
git clone https://github.com/wolfSSL/simulators simulators
47+
cd simulators && git checkout "$SIMULATORS_REF"
48+
49+
- name: Stage PR wolfSSL into simulator build context
50+
run: mv wolfssl-src simulators/TROPIC01Sim/wolfssl
51+
52+
- name: Patch Dockerfile to use PR wolfSSL and drop redundant ForceZero patch
53+
working-directory: simulators/TROPIC01Sim
54+
run: |
55+
# 1. Replace the (two-line) upstream `RUN git clone --branch
56+
# ${WOLFSSL_REF} --depth 1 \ https://.../wolfssl.git /app/wolfssl`
57+
# with a COPY of the PR checkout.
58+
sed -i '/^RUN git clone --branch \${WOLFSSL_REF} --depth 1 \\$/,/wolfssl\.git \/app\/wolfssl$/c\
59+
COPY wolfssl /app/wolfssl' Dockerfile.wolfcrypt
60+
# Fail fast if the pattern drifted upstream -- better a clear error
61+
# than a CI run that silently tests master.
62+
grep -q '^COPY wolfssl /app/wolfssl$' Dockerfile.wolfcrypt
63+
! grep -q 'git clone .*wolfssl\.git' Dockerfile.wolfcrypt
64+
65+
# 2. Neutralise the ForceZero sed-patch RUN block: the fix
66+
# (s/ForceZero/wc_ForceZero/ in tropic01.c) is now upstream,
67+
# and rerunning the non-word-boundary-anchored simulator
68+
# substitution on already-fixed source would corrupt it to
69+
# `wc_wc_ForceZero`. Range matches from the ForceZero RUN sed
70+
# line to its tropic01.c continuation line.
71+
sed -i '/^RUN sed -i .*ForceZero/,/tropic01\.c$/c\RUN true' Dockerfile.wolfcrypt
72+
! grep -q 'sed -i .*ForceZero' Dockerfile.wolfcrypt
73+
74+
- uses: docker/setup-buildx-action@v3
75+
76+
- name: Build wolfCrypt-TROPIC01 test image
77+
uses: docker/build-push-action@v5
78+
with:
79+
context: simulators/TROPIC01Sim
80+
file: simulators/TROPIC01Sim/Dockerfile.wolfcrypt
81+
push: false
82+
load: true
83+
tags: wolfssl-tropic01-sim:ci
84+
cache-from: type=gha
85+
cache-to: type=gha,mode=max
86+
87+
- name: Run wolfCrypt tests against simulator
88+
run: docker run --rm wolfssl-tropic01-sim:ci

wolfcrypt/src/port/tropicsquare/tropic01.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@
3535

3636
#include <wolfssl/wolfcrypt/port/tropicsquare/tropic01.h>
3737

38+
#ifdef NO_INLINE
39+
#include <wolfssl/wolfcrypt/misc.h>
40+
#else
41+
#define WOLFSSL_MISC_INCLUDED
42+
#include <wolfcrypt/src/misc.c>
43+
#endif
44+
3845
static Tropic01CryptoDevCtx g_ctx = {0};
3946
static lt_handle_t g_h;
4047

0 commit comments

Comments
 (0)