Skip to content

Commit 482441e

Browse files
authored
Merge pull request #90 from hug-dev/aarch64-tests
Modify Travis CI test script
2 parents f918a2d + 1f2986a commit 482441e

File tree

15 files changed

+181
-218
lines changed

15 files changed

+181
-218
lines changed

.cargo/config

Lines changed: 0 additions & 4 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
- name: Build the container
1212
run: docker build -t all-providers tests/all_providers
1313
- name: Run the container to execute the test script
14-
run: docker run -v $(pwd):/tmp/parsec -w /tmp/parsec all-providers /tmp/parsec/tests/all_providers/ci.sh
14+
run: docker run -v $(pwd):/tmp/parsec -w /tmp/parsec all-providers /tmp/parsec/tests/ci.sh all
1515

1616
mbed-crypto-provider:
1717
name: Integration tests using Mbed Crypto provider
@@ -21,7 +21,7 @@ jobs:
2121
- name: Build the container
2222
run: docker build -t mbed-crypto-provider tests/per_provider/provider_cfg/mbed-crypto
2323
- name: Run the container to execute the test script
24-
run: docker run -v $(pwd):/tmp/parsec -w /tmp/parsec mbed-crypto-provider /tmp/parsec/tests/per_provider/ci.sh mbed-crypto
24+
run: docker run -v $(pwd):/tmp/parsec -w /tmp/parsec mbed-crypto-provider /tmp/parsec/tests/ci.sh mbed-crypto
2525

2626
pkcs11-provider:
2727
name: Integration tests using PKCS 11 provider
@@ -31,7 +31,7 @@ jobs:
3131
- name: Build the container
3232
run: docker build -t pkcs11-provider tests/per_provider/provider_cfg/pkcs11
3333
- name: Run the container to execute the test script
34-
run: docker run -v $(pwd):/tmp/parsec -w /tmp/parsec pkcs11-provider /tmp/parsec/tests/per_provider/ci.sh pkcs11
34+
run: docker run -v $(pwd):/tmp/parsec -w /tmp/parsec pkcs11-provider /tmp/parsec/tests/ci.sh pkcs11
3535

3636
tpm-provider:
3737
name: Integration tests using TPM provider
@@ -41,17 +41,4 @@ jobs:
4141
- name: Build the container
4242
run: docker build -t tpm-provider tests/per_provider/provider_cfg/tpm
4343
- name: Run the container to execute the test script
44-
run: docker run -v $(pwd):/tmp/parsec -w /tmp/parsec tpm-provider /tmp/parsec/tests/per_provider/ci.sh tpm
45-
46-
cross-compilation-arm64-linux:
47-
name: Cross compilation for the aarch64-unknown-linux-gnu target
48-
runs-on: ubuntu-latest
49-
steps:
50-
- uses: actions/checkout@v1
51-
- name: Install cross
52-
run: cargo install cross
53-
- name: Build the cross Dockerfile
54-
run: docker build -t parsec-cross tests/cross_compilation
55-
- name: Cross-compile with cross
56-
#TODO: compile will all features included by setting up the right Dockerfile
57-
run: cross build --target aarch64-unknown-linux-gnu --verbose --no-default-features
44+
run: docker run -v $(pwd):/tmp/parsec -w /tmp/parsec tpm-provider /tmp/parsec/tests/ci.sh tpm

.travis.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,21 @@
11
# Executing our tests on Arm64 with Travis CI
2+
# The TPM provider Dockerfile does not build on Arm so the all-providers and tpm-provider tests
3+
# are not executed on Aarch64.
24
arch: arm64
35
services:
46
- docker
57
jobs:
68
include:
7-
- name: "Various tests targeting a Parsec image with all providers included"
8-
env:
9-
- DOCKER_IMAGE_NAME=all-providers
10-
- DOCKER_IMAGE_PATH=tests/all_providers
11-
- SCRIPT=tests/all_providers/ci.sh
129
- name: "Integration tests using Mbed Crypto provider"
1310
env:
1411
- DOCKER_IMAGE_NAME=mbed-crypto-provider
1512
- DOCKER_IMAGE_PATH=tests/per_provider/provider_cfg/mbed-crypto
16-
- SCRIPT="tests/per_provider/ci.sh mbed-crypto"
13+
- SCRIPT="tests/ci.sh mbed-crypto"
1714
- name: "Integration tests using PKCS 11 provider"
1815
env:
1916
- DOCKER_IMAGE_NAME=pkcs11-provider
2017
- DOCKER_IMAGE_PATH=tests/per_provider/provider_cfg/pkcs11
21-
- SCRIPT="tests/per_provider/ci.sh pkcs11"
18+
- SCRIPT="tests/ci.sh pkcs11"
2219
script:
2320
- docker build -t $DOCKER_IMAGE_NAME $DOCKER_IMAGE_PATH
2421
- docker run -v $(pwd):/tmp/parsec -w /tmp/parsec $DOCKER_IMAGE_NAME /tmp/parsec/$SCRIPT

Cross.toml

Lines changed: 0 additions & 4 deletions
This file was deleted.

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
<img src="https://github.com/parallaxsecond/parsec/blob/master/parsec.png?raw=true" alt="Parsec logo"/>
2020
<br><br>
2121
<a href="https://github.com/parallaxsecond/parsec/actions?query=workflow%3A%22Continuous+Integration%22"><img src="https://github.com/parallaxsecond/parsec/workflows/Continuous%20Integration/badge.svg" alt="CI tests"/></a>
22+
<a href="https://travis-ci.com/parallaxsecond/parsec"><img src="https://travis-ci.com/parallaxsecond/parsec.svg?branch=master" alt="Travis CI tests"/></a>
2223
<a href="https://opensource.org/licenses/Apache-2.0"><img src="https://img.shields.io/badge/License-Apache%202.0-blue.svg" alt="License"/></a>
2324
</p>
2425

tests/all_providers/ci.sh

Lines changed: 0 additions & 67 deletions
This file was deleted.

tests/all_providers/config.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[core_settings]
2-
log_level = "debug"
2+
log_level = "error"
33
# The CI already timestamps the logs
44
log_timestamp = false
55

tests/ci.sh

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
#!/usr/bin/env bash
2+
3+
# ------------------------------------------------------------------------------
4+
# Copyright (c) 2019, Arm Limited, All Rights Reserved
5+
# SPDX-License-Identifier: Apache-2.0
6+
#
7+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
8+
# not use this file except in compliance with the License.
9+
# You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
# See the License for the specific language governing permissions and
17+
# limitations under the License.
18+
# ------------------------------------------------------------------------------
19+
20+
set -e
21+
22+
usage () {
23+
printf "
24+
Continuous Integration test script
25+
26+
This script will execute various tests targeting a platform with a
27+
single provider or all providers included.
28+
It is meant to be executed inside one of the container
29+
which Dockerfiles are in tests/per_provider/provider_cfg/*/
30+
or tests/all_providers/
31+
32+
Usage: ./tests/ci.sh PROVIDER_NAME
33+
where PROVIDER_NAME can be one of:
34+
- mbed-crypto
35+
- pkcs11
36+
- tpm
37+
- all
38+
"
39+
}
40+
41+
# Check if the PROVIDER_NAME was given.
42+
if [ $# -eq 0 ]
43+
then
44+
echo "error: a provider name needs to be given as input argument to that script."
45+
usage
46+
exit 1
47+
fi
48+
49+
# Switch amoung parameters
50+
if [[ $1 = "mbed-crypto" ]]
51+
then
52+
# Mbed Cyypto provider
53+
FEATURES="--no-default-features --features=$1-provider"
54+
CONFIG_PATH="tests/per_provider/provider_cfg/$1/config.toml"
55+
elif [[ $1 = "tpm" ]]
56+
then
57+
# TPM provider
58+
FEATURES="--no-default-features --features=$1-provider"
59+
CONFIG_PATH="tests/per_provider/provider_cfg/$1/config.toml"
60+
61+
tpm_server &
62+
sleep 5
63+
tpm2_startup -c -T mssim
64+
elif [[ $1 = "pkcs11" ]]
65+
then
66+
# PKCS11 provider
67+
FEATURES="--no-default-features --features=$1-provider"
68+
CONFIG_PATH="tests/per_provider/provider_cfg/$1/config.toml"
69+
70+
# Find and append the slot number at the end of the configuration file.
71+
tests/per_provider/provider_cfg/pkcs11/find_slot_number.sh $CONFIG_PATH
72+
elif [[ $1 = "all" ]]
73+
then
74+
# All providers
75+
FEATURES="--all-features"
76+
CONFIG_PATH="tests/all_providers/config.toml"
77+
78+
tpm_server &
79+
sleep 5
80+
tpm2_startup -c -T mssim
81+
82+
tests/per_provider/provider_cfg/pkcs11/find_slot_number.sh $CONFIG_PATH
83+
else
84+
echo "error: PROVIDER_NAME given (\"$1\") is invalid."
85+
usage
86+
exit 1
87+
fi
88+
89+
##############
90+
# Build test #
91+
##############
92+
RUST_BACKTRACE=1 cargo build -vv $FEATURES
93+
94+
#################
95+
# Static checks #
96+
#################
97+
# On native target clippy or fmt might not be available.
98+
if rustup component list | grep -q fmt
99+
then
100+
cargo fmt --all -- --check
101+
fi
102+
if rustup component list | grep -q clippy
103+
then
104+
cargo clippy --all-targets $FEATURES -- -D warnings
105+
fi
106+
107+
############################
108+
# Unit tests and doc tests #
109+
############################
110+
RUST_BACKTRACE=1 cargo test --lib $FEATURES
111+
RUST_BACKTRACE=1 cargo test --doc $FEATURES
112+
113+
######################################
114+
# Start Parsec for integration tests #
115+
######################################
116+
RUST_BACKTRACE=1 cargo run -vv $FEATURES -- --config $CONFIG_PATH &
117+
SERVER_PID=$!
118+
# Sleep time needed to make sure Parsec is ready before launching the tests.
119+
sleep 5
120+
121+
if [[ $1 = "all" ]]
122+
then
123+
# All providers tests
124+
RUST_BACKTRACE=1 cargo test -vv $FEATURES all_providers
125+
else
126+
# Per provider tests
127+
################
128+
# Normal tests #
129+
################
130+
RUST_BACKTRACE=1 cargo test -vv $FEATURES normal_tests
131+
132+
#####################
133+
# Persistence tests #
134+
#####################
135+
RUST_BACKTRACE=1 cargo test -vv $FEATURES persistent-before
136+
137+
# Create a fake mapping file for the root application, the provider and a
138+
# key name of "Test Key". It contains a valid PSA Key ID.
139+
# It is tested in test "should_have_been_deleted".
140+
# This test does not make sense for the TPM provider.
141+
if [[ $1 = "mbed-crypto" ]]
142+
then
143+
# For Mbed Provider
144+
mkdir -p mappings/cm9vdA==/1
145+
printf '\xe0\x19\xb2\x5c' > mappings/cm9vdA==/1/VGVzdCBLZXk\=
146+
elif [[ $1 = "pkcs11" ]]
147+
then
148+
# For PKCS 11 Provider
149+
mkdir -p mappings/cm9vdA==/2
150+
printf '\xe0\x19\xb2\x5c' > mappings/cm9vdA==/2/VGVzdCBLZXk\=
151+
fi
152+
153+
# Trigger a configuration reload to load the new mappings.
154+
kill -s SIGHUP $SERVER_PID
155+
156+
RUST_BACKTRACE=1 cargo test -vv $FEATURES persistent-after
157+
158+
################
159+
# Stress tests #
160+
################
161+
RUST_BACKTRACE=1 cargo test -vv $FEATURES stress_test
162+
fi
163+
164+
kill $SERVER_PID
165+
cargo clean

tests/cross_compilation/Dockerfile

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)