Skip to content

Commit e8dccc8

Browse files
willieyzhanno-becker
authored andcommitted
Port: add --aarch64-fips202-backend to tests and CI
- This commit is ported from mlkem-native PR #1106. - This commit adds the `--aarch64-fips202-backend` option to the `tests` scripts, allowing the FIPS202 backend to be specified directly as an input parameter, also adds backend_tests to the CI workflow. Signed-off-by: willieyz <[email protected]>
1 parent 7320306 commit e8dccc8

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

.github/workflows/ci.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,27 @@ jobs:
153153
compile_mode: native
154154
cflags: "-DMLDSA_DEBUG -fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all"
155155
ldflags: "-fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all"
156+
backend_tests:
157+
name: AArch64 FIPS202 backends (${{ matrix.backend }})
158+
strategy:
159+
fail-fast: false
160+
matrix:
161+
backend: [x1_scalar, x1_v84a, x2_v84a, x4_v8a_scalar, x4_v8a_v84a_scalar]
162+
runs-on: macos-latest
163+
steps:
164+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
165+
- name: build + test
166+
uses: ./.github/actions/multi-functest
167+
with:
168+
nix-shell: 'ci'
169+
nix-cache: 'false'
170+
gh_token: ${{ secrets.GITHUB_TOKEN }}
171+
compile_mode: 'native'
172+
opt: 'opt'
173+
examples: 'false'
174+
cflags: "-DMLDSA_DEBUG -fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all"
175+
ldflags: "-fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all"
176+
extra_args: "--fips202-aarch64-backend ${{ matrix.backend }}"
156177
compiler_tests:
157178
name: Compiler tests (${{ matrix.compiler.name }}, ${{ matrix.target.name }}, ${{ matrix.cflags }})
158179
strategy:

scripts/tests

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,18 @@ class Tests:
407407
if test_type.is_example() and self.args.cross_prefix != "":
408408
cflags += " -static"
409409

410+
# Add FIPS202 backend selection if specified and this is an OPT build
411+
if self.args.fips202_aarch64_backend != "auto" and opt is True:
412+
# Make sure we're forcing AArch64 architecture
413+
if not " -DMLD_FORCE_AARCH64" in cflags:
414+
cflags += " -DMLD_FORCE_AARCH64"
415+
416+
# Enable native backend for FIPS202
417+
cflags += " -DMLD_CONFIG_USE_NATIVE_BACKEND_FIPS202"
418+
419+
# Specify the backend file
420+
cflags += f' -DMLD_CONFIG_FIPS202_BACKEND_FILE=\\"fips202/native/aarch64/{self.args.fips202_aarch64_backend}.h\\"'
421+
410422
env_update = {}
411423
if cflags != "":
412424
env_update["CFLAGS"] = cflags
@@ -894,6 +906,21 @@ def cli():
894906
default="ALL",
895907
)
896908

909+
common_parser.add_argument(
910+
"--fips202-aarch64-backend",
911+
help="Select FIPS202 AArch64 backend",
912+
choices=[
913+
"auto",
914+
"x1_scalar",
915+
"x1_v84a",
916+
"x2_v84a",
917+
"x4_v8a_scalar",
918+
"x4_v8a_v84a_scalar",
919+
],
920+
default="auto",
921+
type=str,
922+
)
923+
897924
# --run / --no-run
898925
run_group = common_parser.add_mutually_exclusive_group()
899926
run_group.add_argument(

0 commit comments

Comments
 (0)