Building, running and testing - RobertDrazkowskiGL/parsec GitHub Wiki

Building

user@host:~/parsec$ cargo build --features cryptoauthlib-provider

Checking code formatting

user@host:~/parsec$ cargo fmt --all -- --check

Checking lints

user@host:~/parsec$ cargo clippy --all-targets --features cryptoauthlib-provider -- -D clippy::all -D clippy::cargo

Doc tests

user@host:~/parsec$ cargo test --doc --features cryptoauthlib-provider

Unit tests

user@host:~/parsec$ cargo test --lib --features cryptoauthlib-provider

End-to-end tests

Prerequisites
At least two consoles (terminals) are needed.
The Parsec binaries must be compiled with direct authenticator built-in, e.g. using below command:
user@host:~/parsec$ cargo build --features=cryptoauthlib-provider,all-authenticators

Check formatting
user@host:~/parsec$ cargo fmt --all --manifest-path e2e_tests/Cargo.toml -- --check

Check lints
user@host:~/parsec$ cargo clippy --all-targets --features=cryptoauthlib-provider --manifest-path e2e_tests/Cargo.toml -- -D clippy::all -D clippy::cargo

First console: Start parsec

There are minor differences in command line, depending on backend to be used.

Tests using software backend, i.e. rust-cryptoauthlib::test-interface

user@host:~/parsec$ RUST_LOG=info ./target/debug/parsec -c e2e_tests/provider_cfg/cryptoauthlib/config.toml

Tests using a hardware backend - an ATECC608a on i2c bus

user@host:~/parsec$ RUST_LOG=info ./target/debug/parsec -c e2e_tests/provider_cfg/cryptoauthlib/config_608a.toml

Second console: run tests

user@host:~/parsec$ cd e2e_tests
user@host:~/parsec/e2e_tests$ PARSEC_SERVICE_ENDPOINT="unix:/tmp/parsec.sock" cargo test --features cryptoauthlib-provider normal_tests -- --test-threads 1
The number of test threads is limited, otherwise tests requirements quickly exhaust the number of available slots.
The location of parsec service socket file PARSEC_SERVICE_ENDPOINT must be the same as the one defined in config.toml, section listener, field socket_path.

To see the logs add 'nocapture' option
PARSEC_SERVICE_ENDPOINT="unix:/tmp/parsec.sock" cargo test --features cryptoauthlib-provider export_ecc_private_key_not_possible -- --nocapture -- --test-threads 1

Integration tests run by github CI

Please note - all below tests must pass to make merging a pull request possible.
Hint - these tests are run in their containers and take a lot of time and consume a lot of disk space as well.
Check using df if there is enough disk space (around 10GB) before every test.
If not docker container ls -al together with docker container rm can help.
Please also note, that as long as there is no good CryptoAuthentication Library in-software emulator, running end-to-end tests of a cryptoauthlib-provider is difficult in github CI.
And finally - github CI tests are setup here: parsec/.github/workflows/ci.yml - please refer to this file if an unexpected occurs.

Integration tests using Mbed Crypto provider

user@host:~/parsec$ docker run -v $(pwd):/tmp/parsec -w /tmp/parsec ghcr.io/parallaxsecond/parsec-service-test-all /tmp/parsec/ci.sh mbed-crypto

Integration tests using PKCS 11 provider

user@host:~/parsec$ docker run -v $(pwd):/tmp/parsec -w /tmp/parsec ghcr.io/parallaxsecond/parsec-service-test-all /tmp/parsec/ci.sh pkcs11

Integration tests using TPM provider

user@host:~/parsec$ docker run -v $(pwd):/tmp/parsec -w /tmp/parsec ghcr.io/parallaxsecond/parsec-service-test-all /tmp/parsec/ci.sh tpm

Integration tests using Crypto Trusted Service provider

user@host:~/parsec$ docker run -v $(pwd):/tmp/parsec -w /tmp/parsec ghcr.io/parallaxsecond/parsec-service-test-all /tmp/parsec/ci.sh trusted-service

Integration tests using CryptoAuthLib provider

Please note - it is still experimental!
user@host:~/parsec$ docker run -v $(pwd):/tmp/parsec -w /tmp/parsec ghcr.io/parallaxsecond/parsec-service-test-all /tmp/parsec/ci.sh --no-stress-test cryptoauthlib

Various tests targeting a Parsec image with all providers included

user@host:~/parsec$ docker run -v $(pwd):/tmp/parsec -w /tmp/parsec ghcr.io/parallaxsecond/parsec-service-test-all /tmp/parsec/ci.sh all

⚠️ **GitHub.com Fallback** ⚠️