Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .github/actions/functest/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ inputs:
stack:
description: Determine whether to run stack analysis or not
default: "false"
unit:
description: Determine whether to run unit tests or not
default: "true"
extra_args:
description: Additional arguments to pass to the tests script
default: ""
Expand All @@ -70,6 +73,7 @@ runs:
echo ACVP="${{ inputs.acvp == 'true' && 'acvp' || 'no-acvp' }}" >> $GITHUB_ENV
echo EXAMPLES="${{ inputs.examples == 'true' && 'examples' || 'no-examples' }}" >> $GITHUB_ENV
echo STACK="${{ inputs.stack == 'true' && 'stack' || 'no-stack' }}" >> $GITHUB_ENV
echo UNIT="${{ inputs.unit == 'true' && 'unit' || 'no-unit' }}" >> $GITHUB_ENV
- name: Setup nix
uses: ./.github/actions/setup-shell
with:
Expand Down Expand Up @@ -104,7 +108,7 @@ runs:
shell: ${{ env.SHELL }}
run: |
make clean
./scripts/tests all ${{ inputs.check_namespace == 'true' && '--check-namespace' || ''}} --exec-wrapper="${{ inputs.exec_wrapper }}" --cross-prefix="${{ inputs.cross_prefix }}" --cflags="${{ inputs.cflags }}" --ldflags="${{ inputs.ldflags }}" --opt=${{ inputs.opt }} --${{ env.FUNC }} --${{ env.KAT }} --${{ env.ACVP }} --${{ env.EXAMPLES }} --${{ env.STACK }} -v ${{ inputs.extra_args }}
./scripts/tests all ${{ inputs.check_namespace == 'true' && '--check-namespace' || ''}} --exec-wrapper="${{ inputs.exec_wrapper }}" --cross-prefix="${{ inputs.cross_prefix }}" --cflags="${{ inputs.cflags }}" --ldflags="${{ inputs.ldflags }}" --opt=${{ inputs.opt }} --${{ env.FUNC }} --${{ env.KAT }} --${{ env.ACVP }} --${{ env.EXAMPLES }} --${{ env.STACK }} --${{ env.UNIT }} -v ${{ inputs.extra_args }}
- name: Post ${{ env.MODE }} Tests
shell: ${{ env.SHELL }}
if: success() || failure()
Expand Down
14 changes: 13 additions & 1 deletion .github/actions/multi-functest/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ inputs:
stack:
description: Determine whether to run stack analysis or not
default: "false"
unit:
description: Determine whether to run unit tests or not
default: "true"
extra_args:
description: Additional arguments to pass to the tests script
default: ""
Expand All @@ -75,6 +78,7 @@ runs:
examples: ${{ inputs.examples }}
check_namespace: ${{ inputs.check_namespace }}
stack: ${{ inputs.stack }}
unit: ${{ inputs.unit }}
extra_args: ${{ inputs.extra_args }}
- name: Cross x86_64 Tests
if: ${{ (inputs.compile_mode == 'all' || inputs.compile_mode == 'cross-x86_64') && (success() || failure()) }}
Expand All @@ -96,6 +100,7 @@ runs:
examples: ${{ inputs.examples }}
check_namespace: ${{ inputs.check_namespace }}
stack: ${{ inputs.stack }}
unit: ${{ inputs.unit }}
extra_args: ${{ inputs.extra_args }}
- name: Cross aarch64 Tests
if: ${{ (inputs.compile_mode == 'all' || inputs.compile_mode == 'cross-aarch64') && (success() || failure()) }}
Expand All @@ -117,6 +122,7 @@ runs:
examples: ${{ inputs.examples }}
check_namespace: ${{ inputs.check_namespace }}
stack: ${{ inputs.stack }}
unit: ${{ inputs.unit }}
extra_args: ${{ inputs.extra_args }}
- name: Cross ppc64le Tests
if: ${{ (inputs.compile_mode == 'all' || inputs.compile_mode == 'cross-ppc64le') && (success() || failure()) }}
Expand All @@ -138,6 +144,7 @@ runs:
examples: ${{ inputs.examples }}
check_namespace: ${{ inputs.check_namespace }}
stack: ${{ inputs.stack }}
unit: ${{ inputs.unit }}
extra_args: ${{ inputs.extra_args }}
- name: Cross aarch64_be Tests
if: ${{ (inputs.compile_mode == 'all' || inputs.compile_mode == 'cross-aarch64_be') && (success() || failure()) }}
Expand All @@ -159,6 +166,7 @@ runs:
examples: ${{ inputs.examples }}
check_namespace: ${{ inputs.check_namespace }}
stack: ${{ inputs.stack }}
unit: ${{ inputs.unit }}
extra_args: ${{ inputs.extra_args }}
- name: Cross riscv64 Tests (RVV, VLEN=128)
if: ${{ (inputs.compile_mode == 'all' || inputs.compile_mode == 'cross-riscv64') && (success() || failure()) }}
Expand All @@ -180,6 +188,7 @@ runs:
examples: ${{ inputs.examples }}
check_namespace: ${{ inputs.check_namespace }}
stack: ${{ inputs.stack }}
unit: ${{ inputs.unit }}
extra_args: ${{ inputs.extra_args }}
- name: Cross riscv64 Tests (RVV, VLEN=256)
if: ${{ (inputs.compile_mode == 'all' || inputs.compile_mode == 'cross-riscv64') && (success() || failure()) }}
Expand All @@ -200,6 +209,7 @@ runs:
examples: ${{ inputs.examples }}
check_namespace: ${{ inputs.check_namespace }}
stack: ${{ inputs.stack }}
unit: ${{ inputs.unit }}
extra_args: ${{ inputs.extra_args }}
- name: Cross riscv64 Tests (RVV, VLEN=512)
if: ${{ (inputs.compile_mode == 'all' || inputs.compile_mode == 'cross-riscv64') && (success() || failure()) }}
Expand All @@ -220,6 +230,7 @@ runs:
examples: ${{ inputs.examples }}
check_namespace: ${{ inputs.check_namespace }}
stack: ${{ inputs.stack }}
unit: ${{ inputs.unit }}
extra_args: ${{ inputs.extra_args }}
- name: Cross riscv64 Tests (RVV, VLEN=1024)
if: ${{ (inputs.compile_mode == 'all' || inputs.compile_mode == 'cross-riscv64') && (success() || failure()) }}
Expand All @@ -240,6 +251,7 @@ runs:
examples: ${{ inputs.examples }}
check_namespace: ${{ inputs.check_namespace }}
stack: ${{ inputs.stack }}
unit: ${{ inputs.unit }}
extra_args: ${{ inputs.extra_args }}
- name: Cross riscv32 Tests
if: ${{ (inputs.compile_mode == 'all' || inputs.compile_mode == 'cross-riscv32') && (success() || failure()) }}
Expand All @@ -261,5 +273,5 @@ runs:
examples: ${{ inputs.examples }}
check_namespace: ${{ inputs.check_namespace }}
stack: ${{ inputs.stack }}
unit: ${{ inputs.unit }}
extra_args: ${{ inputs.extra_args }}

32 changes: 32 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,38 @@ jobs:
examples: false
stack: true
check_namespace: false
valgrind_unit:
name: Valgrind unit tests (${{ matrix.target.name }})
strategy:
fail-fast: false
matrix:
external:
- ${{ github.repository_owner != 'pq-code-package' }}
target:
- runner: ubuntu-latest
name: x86_64
- runner: ubuntu-24.04-arm
name: aarch64
runs-on: ${{ matrix.target.runner }}
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: Valgrind unit tests
uses: ./.github/actions/multi-functest
with:
gh_token: ${{ secrets.GITHUB_TOKEN }}
compile_mode: native
nix-shell: ci_valgrind-varlat_gcc15
nix-cache: false
opt: all
cflags: "-O3"
func: false
kat: false
acvp: false
examples: false
stack: false
unit: true
check_namespace: false
extra_args: "--exec-wrapper='valgrind --error-exitcode=1'"
config_variations:
name: Non-standard configurations
strategy:
Expand Down
34 changes: 25 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
# Copyright (c) The mldsa-native project authors
# SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT

.PHONY: func kat acvp stack \
func_44 kat_44 acvp_44 stack_44 \
func_65 kat_65 acvp_65 stack_65 \
func_87 kat_87 acvp_87 stack_87 \
run_func run_kat run_acvp run_stack \
run_func_44 run_kat_44 run_stack_44 \
run_func_65 run_kat_65 run_stack_65 \
run_func_87 run_kat_87 run_stack_87 \
.PHONY: func kat acvp stack unit \
func_44 kat_44 acvp_44 stack_44 unit_44 \
func_65 kat_65 acvp_65 stack_65 unit_65 \
func_87 kat_87 acvp_87 stack_87 unit_87 \
run_func run_kat run_acvp run_stack run_unit \
run_func_44 run_kat_44 run_stack_44 run_unit_44 \
run_func_65 run_kat_65 run_stack_65 run_unit_65 \
run_func_87 run_kat_87 run_stack_87 run_unit_87 \
bench_44 bench_65 bench_87 bench \
run_bench_44 run_bench_65 run_bench_87 run_bench \
bench_components_44 bench_components_65 bench_components_87 bench_components \
Expand Down Expand Up @@ -49,7 +49,7 @@ quickcheck: test
build: func kat acvp
$(Q)echo " Everything builds fine!"

test: run_kat run_func run_acvp
test: run_kat run_func run_acvp run_unit
$(Q)echo " Everything checks fine!"

run_kat_44: kat_44
Expand All @@ -68,6 +68,14 @@ run_func_87: func_87
$(W) $(MLDSA87_DIR)/bin/test_mldsa87
run_func: run_func_44 run_func_65 run_func_87

run_unit_44: unit_44
$(W) $(MLDSA44_DIR)/bin/test_unit44
run_unit_65: unit_65
$(W) $(MLDSA65_DIR)/bin/test_unit65
run_unit_87: unit_87
$(W) $(MLDSA87_DIR)/bin/test_unit87
run_unit: run_unit_44 run_unit_65 run_unit_87

run_acvp: acvp
EXEC_WRAPPER="$(EXEC_WRAPPER)" python3 ./test/acvp_client.py $(if $(ACVP_VERSION),--version $(ACVP_VERSION))

Expand All @@ -79,6 +87,14 @@ func_87: $(MLDSA87_DIR)/bin/test_mldsa87
$(Q)echo " FUNC ML-DSA-87: $^"
func: func_44 func_65 func_87

unit_44: $(MLDSA44_DIR)/bin/test_unit44
$(Q)echo " UNIT ML-DSA-44: $^"
unit_65: $(MLDSA65_DIR)/bin/test_unit65
$(Q)echo " UNIT ML-DSA-65: $^"
unit_87: $(MLDSA87_DIR)/bin/test_unit87
$(Q)echo " UNIT ML-DSA-87: $^"
unit: unit_44 unit_65 unit_87

kat_44: $(MLDSA44_DIR)/bin/gen_KAT44
$(Q)echo " KAT ML-DSA-44: $^"
kat_65: $(MLDSA65_DIR)/bin/gen_KAT65
Expand Down
40 changes: 40 additions & 0 deletions scripts/tests
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ class TEST_TYPES(Enum):
CUSTOM_BACKEND = 16
MULTILEVEL_BUILD = 17
MULTILEVEL_BUILD_NATIVE = 18
UNIT = 19

def is_benchmark(self):
return self in [TEST_TYPES.BENCH, TEST_TYPES.BENCH_COMPONENTS]
Expand Down Expand Up @@ -283,6 +284,8 @@ class TEST_TYPES(Enum):
return "Example (multilevel build)"
if self == TEST_TYPES.MULTILEVEL_BUILD_NATIVE:
return "Example (multilevel build, native)"
if self == TEST_TYPES.UNIT:
return "Unit Test"

def make_dir(self):
if self == TEST_TYPES.BASIC:
Expand Down Expand Up @@ -346,6 +349,8 @@ class TEST_TYPES(Enum):
return ""
if self == TEST_TYPES.MULTILEVEL_BUILD_NATIVE:
return ""
if self == TEST_TYPES.UNIT:
return "unit"

def make_run_target(self, scheme):
t = self.make_target()
Expand Down Expand Up @@ -632,6 +637,19 @@ class Tests:

self.check_fail()

def unit(self):
def _unit(opt):
self._compile_schemes(TEST_TYPES.UNIT, opt)
if self.args.run:
self._run_schemes(TEST_TYPES.UNIT, opt)

if self.do_no_opt():
_unit(False)
if self.do_opt():
_unit(True)

self.check_fail()

def acvp(self):
def _acvp(opt):
self._compile_schemes(TEST_TYPES.ACVP, opt)
Expand Down Expand Up @@ -765,6 +783,7 @@ class Tests:
acvp = self.args.acvp
examples = self.args.examples
stack = self.args.stack
unit = self.args.unit

def _all(opt):
if func is True:
Expand All @@ -775,6 +794,8 @@ class Tests:
self._compile_schemes(TEST_TYPES.ACVP, opt)
if stack is True:
self._compile_schemes(TEST_TYPES.STACK, opt)
if unit is True:
self._compile_schemes(TEST_TYPES.UNIT, opt)

if self.args.check_namespace is True:
p = subprocess.run(
Expand All @@ -796,6 +817,8 @@ class Tests:
self._run_scheme(TEST_TYPES.ACVP, opt, None)
if stack is True:
self._run_schemes(TEST_TYPES.STACK, opt, suppress_output=False)
if unit is True:
self._run_schemes(TEST_TYPES.UNIT, opt)

if self.do_no_opt():
_all(False)
Expand Down Expand Up @@ -1104,6 +1127,14 @@ def cli():
"--no-acvp", action="store_false", dest="acvp", help="Do not run acvp test"
)

unit_group = all_parser.add_mutually_exclusive_group()
unit_group.add_argument(
"--unit", action="store_true", dest="unit", help="Run unit test", default=True
)
unit_group.add_argument(
"--no-unit", action="store_false", dest="unit", help="Do not run unit test"
)

examples_group = all_parser.add_mutually_exclusive_group()
examples_group.add_argument(
"--examples",
Expand Down Expand Up @@ -1333,6 +1364,13 @@ def cli():
"kat", help="Run the kat tests for all parameter sets", parents=[common_parser]
)

# unit arguments
unit_parser = cmd_subparsers.add_parser(
"unit",
help="Run the unit tests for all parameter sets",
parents=[common_parser],
)

# stack arguments
stack_parser = cmd_subparsers.add_parser(
"stack",
Expand Down Expand Up @@ -1377,6 +1415,8 @@ def cli():
Tests(args).func()
elif args.cmd == "kat":
Tests(args).kat()
elif args.cmd == "unit":
Tests(args).unit()
elif args.cmd == "stack":
Tests(args).stack()
elif args.cmd == "size":
Expand Down
Loading
Loading