-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
All.sh add support for tf-psa-crypto components #9720
Changes from 7 commits
8da0e9e
3d41154
8bcad48
a93f988
a4f0227
6ffebef
d10f42f
dea700d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,112 @@ | ||
#! /usr/bin/env bash | ||
|
||
# all.sh | ||
# all.sh (transitional wrapper) | ||
# | ||
# Copyright The Mbed TLS Contributors | ||
# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later | ||
|
||
# This file is executable; it is the entry point for users and the CI. | ||
# See "Files structure" in all-core.sh for other files used. | ||
# This is a transitional wrapper that's only meant for the CI. | ||
# Developers should directly invoke on or two of: | ||
# - tests/scripts/mbedtls-all.sh ... | ||
# - (cd tf-psa-crypto && tests/scripts/all.sh ...) | ||
# | ||
# During the transition, it's illegal for a tf-psa-crypto component to have | ||
# the same name as an mbedtls components; since this wrapper handles both | ||
# sides at once, component names need to be globally unique. Once the | ||
# transition period is over, unicity on each side will be enough. | ||
# | ||
# For context, here are the steps of the transition: | ||
# 1. We have an all.sh in tf-psa-crypto but for now we don't invoke it directly | ||
# on the CI, only through this transitional wrapper in mbedtls. (tf-psa-crypto | ||
# doesn't have its own CI initially and runs Mbed TLS's instead.) | ||
# 2. We move all relevant components to tf-psa-crypto so that it gets the level of | ||
# coverage we want. We need to make sure the new names are unique. | ||
# 3. We change the CI job on tf-psa-crypto to stop checking out mbedtls and running | ||
# its all.sh - instead we do the normal thing of checking out tf-psa-crypto and | ||
# running its all.sh. (In two steps: (a) add the new job, (b) remove the old | ||
# one.) | ||
# 4. We remove the transitional wrapper in mbedtls and we're now free to rename | ||
# tf-psa-crypto components as we want. If we followed a consistent naming | ||
# pattern, this can be as simple as s/_tf_psa_crypto// in components-*.sh. | ||
|
||
# This script must be invoked from the project's root. | ||
|
||
# There are exactly 4 ways this is invoked in the CI: | ||
# 1. tests/scripts/all.sh --help | ||
# 2. tests/scripts/all.sh --list-all-components | ||
# 3. tests/scripts/all.sh --list-components | ||
# 4. tests/scripts/all.sh --seed 4 --keep-going single_component_name | ||
# This wrapper does not support other invocations. | ||
|
||
set -eu | ||
|
||
# Cases 1-3 | ||
if [ "$#" -eq 1 ]; then | ||
if [ "$1" = '--help' ]; then | ||
# It doesn't matter which one we use, they're the same | ||
tests/scripts/mbedtls-all.sh "$1" | ||
exit 0 | ||
fi | ||
if [ "$1" = '--list-all-components' -o "$1" = '--list-components' ]; then | ||
# Invoke both | ||
tests/scripts/mbedtls-all.sh "$1" | ||
(cd tf-psa-crypto && tests/scripts/all.sh "$1") | ||
exit 0 | ||
fi | ||
fi | ||
|
||
if [ "$#" -ne 4 -o "$1" != '--seed' -o "$3" != '--keep-going' ]; then | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I attempt to run the script using the following command
I believe this is incorrect and I should either be greeted with the error or the command executes? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah right, good point, that's poor error handling. I'll fix it. |
||
echo "This invocation is not supported by the transitional wrapper." >&2 | ||
echo "See the comments at the top of $0." >&2 | ||
exit 1 | ||
fi | ||
|
||
# Case 4: invoke the right all.sh for this component | ||
comp_name=$4 | ||
|
||
# Get the list of components available on each side. | ||
COMP_MBEDTLS=$(tests/scripts/mbedtls-all.sh --list-all-components | tr '\n' ' ') | ||
COMP_CRYPTO=$(cd tf-psa-crypto && tests/scripts/all.sh --list-all-components | tr '\n' ' ') | ||
|
||
# tell if $1 is in space-separated list $2 | ||
is_in() { | ||
needle=$1 | ||
haystack=$2 | ||
case " $haystack " in | ||
*" $needle "*) echo 1;; | ||
*) echo 0;; | ||
esac | ||
} | ||
|
||
is_crypto=$(is_in "$comp_name" "$COMP_CRYPTO") | ||
is_mbedtls=$(is_in "$comp_name" "$COMP_MBEDTLS") | ||
|
||
# Component should be on exactly one side (see comment near the top). | ||
if [ "$is_crypto" -eq 1 -a "$is_mbedtls" -eq 1 ]; then | ||
echo "Component '$comp_name' is both in crypto and Mbed TLS". >&2 | ||
echo "See the comments at the top of $0." >&2 | ||
exit 1 | ||
fi | ||
if [ "$is_crypto" -eq 0 -a "$is_mbedtls" -eq 0 ]; then | ||
echo "Component '$comp_name' is neither in crypto nor in Mbed TLS". >&2 | ||
echo "See the comments at the top of $0." >&2 | ||
exit 1 | ||
fi | ||
|
||
# The path is going to change when this is moved to the framework | ||
test_script_dir="${0%/*}" | ||
source "$test_script_dir"/all-core.sh | ||
|
||
main "$@" | ||
# Invoke the real thing | ||
if [ "$is_crypto" -eq 1 ]; then | ||
# Make sure the path to the outcomes file is absolute. This is done by | ||
# pre_prepare_outcome_file() however by the time it runs we've already | ||
# changed the working directory, so do it now. | ||
if [ -n "${MBEDTLS_TEST_OUTCOME_FILE+set}" ]; then | ||
case "$MBEDTLS_TEST_OUTCOME_FILE" in | ||
[!/]*) MBEDTLS_TEST_OUTCOME_FILE="$PWD/$MBEDTLS_TEST_OUTCOME_FILE";; | ||
esac | ||
export MBEDTLS_TEST_OUTCOME_FILE | ||
fi | ||
cd tf-psa-crypto | ||
exec tests/scripts/all.sh "$@" | ||
else | ||
exec tests/scripts/mbedtls-all.sh "$@" | ||
fi |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#! /usr/bin/env bash | ||
|
||
# all.sh (mbedtls part) | ||
# | ||
# Copyright The Mbed TLS Contributors | ||
# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later | ||
|
||
# This file is executable; it is the entry point for users and the CI. | ||
# See "Files structure" in all-core.sh for other files used. | ||
|
||
# This script must be invoked from the project's root. | ||
|
||
# The path is going to change when this is moved to the framework | ||
source tests/scripts/all-core.sh | ||
|
||
main "$@" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#! /usr/bin/env bash | ||
|
||
# all.sh | ||
# | ||
# Copyright The Mbed TLS Contributors | ||
# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later | ||
|
||
# This file is executable; it is the entry point for users and the CI. | ||
# See "Files structure" in all-core.sh for other files used. | ||
|
||
# This script must be invoked from the project's root. | ||
|
||
# Prevent silly mistakes when people would invoke this from mbedtls | ||
if [ -d tf-psa-crypto -a -d library ]; then | ||
echo "When invoking this script from an mbedtls checkout," >&2 | ||
echo "you must change the working directory to tf-psa-crypto." >&2 | ||
exit 255 | ||
fi | ||
|
||
# The path is going to change when this is moved to the framework | ||
source ../tests/scripts/all-core.sh | ||
|
||
main "$@" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# components-build-system.sh | ||
# | ||
# Copyright The Mbed TLS Contributors | ||
# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later | ||
|
||
# This file contains test components that are executed by all.sh | ||
|
||
################################################################ | ||
#### Build System Testing | ||
################################################################ | ||
|
||
component_test_cmake_tf_psa_crypto_out_of_source () { | ||
ronald-cron-arm marked this conversation as resolved.
Show resolved
Hide resolved
|
||
msg "build: cmake tf-psa-crypto 'out-of-source' build" | ||
TF_PSA_CRYPTO_ROOT_DIR="$PWD" | ||
mkdir "$OUT_OF_SOURCE_DIR" | ||
cd "$OUT_OF_SOURCE_DIR" | ||
# Note: Explicitly generate files as these are turned off in releases | ||
cmake -D CMAKE_BUILD_TYPE:String=Check -D GEN_FILES=ON "$TF_PSA_CRYPTO_ROOT_DIR" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Echoing Harry's concern in #9755 (comment) : we currently prevent The problem is a race condition. Just having a small number of successful CI runs is not enough to gain confidence. Maybe the cmake file in tf-psa-crypto is better written and is not susceptible to the race condition. That's quite plausible, but do we actually know that? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The component There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @gilles-peskine-arm I think your concern is valid in general, but quite unrelated to this PR, as Ronald explained.
Since you offered, I'm gonna do just that. I'm also going to start a discussion on slack about the potential issue and things we could do about it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, I'd missed that it was a move and not new. I agree that a month of CI is enough to have confidence that this isn't a problem with the tf-psa-crypto cmake scripts. |
||
make | ||
msg "test: cmake tf-psa-crypto 'out-of-source' build" | ||
make test | ||
cd "$TF_PSA_CRYPTO_ROOT_DIR" | ||
rm -rf "$OUT_OF_SOURCE_DIR" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that this conflicts with #9293, which I hope we can merge soon since all it's missing is one approval on one backport.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This also conflicts with #9286, but that's not quite ready yet, so I suggest that we go 9293, then 9720, then 9286.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I'm not seeing the conflict with 9293 - it seems to me that the two PRs are not touching the same files. What am I missing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My bad, there's no merge conflict with 9293 and I don't think there's a semantic conflict either. There's a potential semantic conflict with #9286 since it will error out if a component name is duplicated between mbedtls and tf-psa-crypto.
I ran a merge of something that conflicted but that must have been some different branches or with a non-up-to-date local copy and I can't find exactly what I ran yesterday anymore. I have a conflict checker script and it reports no conflict between the current state of this PR and any other PR opened in the last 6 months. #9293 only conflicts in
.gitignore
with a priority-medium PR.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, currently my PR also forbids component names that are duplicated between mbedtls and tf-psa-crypto, so that shouldn't be a problem. As I said earlier, I don't think we should allow components with the same name on both sides until the sides are completely separated.