forked from chipsalliance/caliptra-dpe
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ci.sh
executable file
·95 lines (77 loc) · 3.72 KB
/
ci.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# Licensed under the Apache-2.0 license
#!/bin/sh
set -ex
# TODO: Support building the simulator for different profiles
function build_rust_targets() {
profile=$1
cargo build --release --manifest-path dpe/Cargo.toml --features=$profile,no-cfi --no-default-features
cargo build --release --manifest-path crypto/Cargo.toml --no-default-features
cargo build --release --manifest-path platform/Cargo.toml --features=$profile --no-default-features
cargo build --release --manifest-path dpe/Cargo.toml --features=$profile --no-default-features
cargo build --release --manifest-path simulator/Cargo.toml --features=$profile,openssl --no-default-features
cargo build --release --manifest-path tools/Cargo.toml --features=$profile --no-default-features
cargo build --manifest-path crypto/Cargo.toml --no-default-features
cargo build --manifest-path platform/Cargo.toml --features=$profile --no-default-features
cargo build --manifest-path dpe/Cargo.toml --features=$profile --no-default-features
cargo build --manifest-path simulator/Cargo.toml --features=$profile,openssl --no-default-features
cargo build --manifest-path tools/Cargo.toml --features=$profile --no-default-features
cargo clippy --manifest-path crypto/Cargo.toml --no-default-features -- --deny=warnings
cargo clippy --manifest-path platform/Cargo.toml --features=$profile --no-default-features -- --deny=warnings
cargo clippy --manifest-path dpe/Cargo.toml --features=$profile --no-default-features -- --deny=warnings
cargo clippy --manifest-path simulator/Cargo.toml --features=$profile,openssl --no-default-features -- --deny=warnings
cargo clippy --manifest-path tools/Cargo.toml --features=$profile --no-default-features -- --deny=warnings
}
function format_rust_targets() {
cargo fmt --manifest-path crypto/Cargo.toml --check
cargo fmt --manifest-path platform/Cargo.toml --check
cargo fmt --manifest-path dpe/Cargo.toml --check
cargo fmt --manifest-path simulator/Cargo.toml --check
cargo fmt --manifest-path tools/Cargo.toml --check
}
function format_go_targets() {
( cd verification
test -z "$(gofmt -l .)"
test -z "$(golint)"
)
}
# TODO: Support building the simulator for different profiles
function test_rust_targets() {
profile=$1
cargo test --manifest-path platform/Cargo.toml --features=$profile --no-default-features
cargo test --manifest-path crypto/Cargo.toml --no-default-features
cargo test --manifest-path dpe/Cargo.toml --features=$profile --no-default-features -- --test-threads=1
cargo test --manifest-path simulator/Cargo.toml --features=$profile,openssl --no-default-features
}
# TODO: Support building the simulator for different profiles
function run_verification_tests() {
profile=$1
crypto=$2
cargo build --manifest-path simulator/Cargo.toml --features=$profile,$crypto --no-default-features
( cd verification/testing
go test -v
)
}
format_rust_targets
format_go_targets
# Run tests for P256 profile
build_rust_targets dpe_profile_p256_sha256
test_rust_targets dpe_profile_p256_sha256
run_verification_tests dpe_profile_p256_sha256 openssl
run_verification_tests dpe_profile_p256_sha256 rustcrypto
# Run tests for P384 profile
build_rust_targets dpe_profile_p384_sha384
test_rust_targets dpe_profile_p384_sha384
run_verification_tests dpe_profile_p384_sha384 openssl
run_verification_tests dpe_profile_p384_sha384 rustcrypto
# Build fuzz target
( cd dpe/fuzz
rustup toolchain install nightly-2023-11-16
cargo +nightly-2023-11-16 install cargo-fuzz cargo-afl
cargo fmt --check
cargo clippy --features libfuzzer-sys
cargo clippy --features afl
cargo +nightly-2023-11-16 fuzz build --features libfuzzer-sys
cargo +nightly-2023-11-16 afl build --features afl
)
# Fix license headers
ci-tools/file-header-fix.sh --check