Skip to content

Commit 4a8ae2b

Browse files
authored
Merge pull request #605 from pq-code-package/test_simplification
Make `tests` a shallow wrapper around `make`
2 parents 67c264e + e468030 commit 4a8ae2b

File tree

7 files changed

+336
-639
lines changed

7 files changed

+336
-639
lines changed

BUILDING.md

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,38 +11,50 @@ To build **mlkem-native**, you need `make` and a C90 compiler. To use the test s
1111
You can build and test **mlkem-native** as follows:
1212

1313
```bash
14-
make quickcheck # With native code backend (if available)
15-
make OPT=0 quickcheck # With C backend
14+
make test # With native code backend (if available)
15+
make OPT=0 test # With C backend
1616
```
1717

18-
To merely build test and benchmarking components, use the following `make` targets:
18+
To merely build test components, use the following `make` targets:
1919

2020
```bash
21-
make mlkem
21+
make func
2222
make nistkat
2323
make kat
24+
make acvp
2425
```
2526

26-
For benchmarking, specify the cycle counting method. Currently, **mlkem-native** is supporting PERF, PMU (AArch64 and x86 only), M1 (Apple Silicon only):
27+
To run them, add `run_`:
28+
29+
```bash
30+
make run_func
31+
make run_nistkat
32+
make run_kat
33+
make run_acvp
34+
```
35+
36+
The resulting binaries can be found in `test/build` (their full path is printed by `make`).
37+
38+
For benchmarking, specify the cycle counting method. Currently, **mlkem-native** is supporting PERF, PMU (AArch64 and
39+
x86 only), M1 (Apple Silicon only):
40+
2741
```
2842
# CYCLES has to be on of PERF, PMU, M1, NO
29-
make bench CYCLES=PERF
30-
make bench_components CYCLES=PERF
43+
make run_bench CYCLES=PERF
44+
make run_bench_components CYCLES=PERF
3145
```
3246

33-
The resulting binaries can then be found in `test/build`.
34-
3547
### Using `tests` script
3648

37-
We recommend compiling and running tests and benchmarks using the [`./scripts/tests`](scripts/tests) script. For
49+
For convenience, you can also use the [`./scripts/tests`](scripts/tests) script as a wrapper around `make`. For
3850
example,
3951

4052
```bash
4153
./scripts/tests func
4254
```
4355

44-
will compile and run functionality tests. For detailed information on how to use the script, please refer to the
45-
`--help` option.
56+
will compile and run functionality tests. For detailed information on how to use the script, please refer to
57+
`./scripts/tests --help`.
4658

4759
### Windows
4860

@@ -59,11 +71,15 @@ There are further scripts used for development of mlkem-native, such as `format`
5971

6072
### nix setup
6173

62-
We specify the development environment for mlkem-native using nix. If you want to help develop mlkem-native, please setup nix using the [nix installer script](https://nixos.org/download/), not your package manager.
74+
We specify the development environment for mlkem-native using nix. If you want to help develop mlkem-native, please setup nix using the [nix installer script](https://nixos.org/download/), not your package manager.
6375

6476
All the development and build dependencies are specified in [flake.nix](flake.nix). To execute a bash shell, run
6577
```bash
6678
nix develop --experimental-features 'nix-command flakes'
6779
```
6880

6981
To confirm that everything worked, try `lint` or `tests cbmc`.
82+
83+
# Checking the proofs
84+
85+
To check the CBMC proofs, enter the `nix` development environment and use `tests cbmc`.

Makefile

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,24 @@
1212
run_bench_512 run_bench_768 run_bench_1024 run_bench \
1313
bench_components_512 bench_components_768 bench_components_1024 bench_components \
1414
run_bench_components_512 run_bench_components_768 run_bench_components_1024 run_bench_components \
15-
buildall checkall all \
15+
build test all \
1616
clean quickcheck check-defined-CYCLES
1717

18-
.DEFAULT_GOAL := buildall
19-
all: quickcheck
18+
.DEFAULT_GOAL := build
19+
all: build
2020

2121
W := $(EXEC_WRAPPER)
2222

2323
include mk/config.mk
2424
include mk/components.mk
2525
include mk/rules.mk
2626

27-
quickcheck: checkall
27+
quickcheck: test
2828

29-
buildall: func nistkat kat acvp
29+
build: func nistkat kat acvp
3030
$(Q)echo " Everything builds fine!"
3131

32-
checkall: run_kat run_nistkat run_func run_acvp
32+
test: run_kat run_nistkat run_func run_acvp
3333
$(Q)echo " Everything checks fine!"
3434

3535
run_kat_512: kat_512
@@ -60,23 +60,35 @@ run_acvp: acvp
6060
python3 ./test/acvp_client.py
6161

6262
func_512: $(MLKEM512_DIR)/bin/test_mlkem512
63+
$(Q)echo " FUNC ML-MEM-512: $^"
6364
func_768: $(MLKEM768_DIR)/bin/test_mlkem768
65+
$(Q)echo " FUNC ML-MEM-768: $^"
6466
func_1024: $(MLKEM1024_DIR)/bin/test_mlkem1024
67+
$(Q)echo " FUNC ML-MEM-1024: $^"
6568
func: func_512 func_768 func_1024
6669

6770
nistkat_512: $(MLKEM512_DIR)/bin/gen_NISTKAT512
71+
$(Q)echo " NISTKAT ML-MEM-512: $^"
6872
nistkat_768: $(MLKEM768_DIR)/bin/gen_NISTKAT768
73+
$(Q)echo " NISTKAT ML-MEM-768: $^"
6974
nistkat_1024: $(MLKEM1024_DIR)/bin/gen_NISTKAT1024
75+
$(Q)echo " NISTKAT ML-MEM-1024: $^"
7076
nistkat: nistkat_512 nistkat_768 nistkat_1024
7177

7278
kat_512: $(MLKEM512_DIR)/bin/gen_KAT512
79+
$(Q)echo " KAT ML-MEM-512: $^"
7380
kat_768: $(MLKEM768_DIR)/bin/gen_KAT768
81+
$(Q)echo " KAT ML-MEM-768: $^"
7482
kat_1024: $(MLKEM1024_DIR)/bin/gen_KAT1024
83+
$(Q)echo " KAT ML-MEM-1024: $^"
7584
kat: kat_512 kat_768 kat_1024
7685

7786
acvp_512: $(MLKEM512_DIR)/bin/acvp_mlkem512
87+
$(Q)echo " ACVP ML-MEM-512: $^"
7888
acvp_768: $(MLKEM768_DIR)/bin/acvp_mlkem768
89+
$(Q)echo " ACVP ML-MEM-768: $^"
7990
acvp_1024: $(MLKEM1024_DIR)/bin/acvp_mlkem1024
91+
$(Q)echo " ACVP ML-MEM-1024: $^"
8092
acvp: acvp_512 acvp_768 acvp_1024
8193

8294
lib: $(BUILD_DIR)/libmlkem.a

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,14 @@ sudo apt-get install make gcc python3 git
3030
git clone https://github.com/pq-code-package/mlkem-native.git
3131
cd mlkem-native
3232

33-
# Build and run base tests
34-
make quickcheck
33+
# Build and run tests
34+
make build
35+
make test
3536

36-
# Build and run all tests
37+
# The same using `tests`, a convenience wrapper around `make`
3738
./scripts/tests all
39+
# Show all options
40+
./scripts/tests --help
3841
```
3942

4043
See [BUILDING.md](BUILDING.md) for more information.

mk/rules.mk

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22
$(BUILD_DIR)/mlkem512/bin/%: $(CONFIG)
33
$(Q)echo " LD $@"
44
$(Q)[ -d $(@D) ] || mkdir -p $(@D)
5-
$(LD) $(CFLAGS) -o $@ $(filter %.o,$^) $(LDLIBS)
5+
$(Q)$(LD) $(CFLAGS) -o $@ $(filter %.o,$^) $(LDLIBS)
66

77
$(BUILD_DIR)/mlkem768/bin/%: $(CONFIG)
88
$(Q)echo " LD $@"
99
$(Q)[ -d $(@D) ] || mkdir -p $(@D)
10-
$(LD) $(CFLAGS) -o $@ $(filter %.o,$^) $(LDLIBS)
10+
$(Q)$(LD) $(CFLAGS) -o $@ $(filter %.o,$^) $(LDLIBS)
1111

1212
$(BUILD_DIR)/mlkem1024/bin/%: $(CONFIG)
1313
$(Q)echo " LD $@"
1414
$(Q)[ -d $(@D) ] || mkdir -p $(@D)
15-
$(LD) $(CFLAGS) -o $@ $(filter %.o,$^) $(LDLIBS)
15+
$(Q)$(LD) $(CFLAGS) -o $@ $(filter %.o,$^) $(LDLIBS)
1616

1717
$(BUILD_DIR)/%.a: $(CONFIG)
1818
$(Q)echo " AR $@"
@@ -44,7 +44,6 @@ endif
4444

4545
$(BUILD_DIR)/%.c.o: %.c $(CONFIG)
4646
$(Q)echo " CC $@"
47-
$(Q)echo " $(CC) -c -o $@ $(CFLAGS) $<"
4847
$(Q)[ -d $(@D) ] || mkdir -p $(@D)
4948
$(Q)$(CC) -c -o $@ $(CFLAGS) $<
5049

0 commit comments

Comments
 (0)