Skip to content
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

Merged
merged 8 commits into from
Nov 7, 2024

Conversation

mpg
Copy link
Contributor

@mpg mpg commented Oct 24, 2024

Description

  • Add tf-psa-crypto/tests/scripts/all.sh that can be invoked independently and will source components from tf-psa-crypto/tests/scripts/component-*.sh. Ultimately this is going to be the main entry point for tf-psa-crypto's CI when all relevant components have been migrated.
  • Turn tests/scripts/all.sh into a wrapper that handles both mbedtls and tf-psa-crypto. This is a transitional wapper so that the CI can just keep calling the same single entry point, and still get all components, while we move relevant components to tf-psa-crypto, and until tf-psa-crypto gets its own autonomous CI.

PR checklist

Manual testing

  • Once the CI is passing, check the outcome file to confirm we're still running the same number of components.
  • Anything else reviewers can think of - time to be creative :)

mpg added 5 commits October 23, 2024 10:06
In preparation for adding tf-psa-crypto/test/scripts/all.sh which will
run from tf-psa-crypto.

Use paths relative to the currently sourced file when including common
files (ie, those that will soon be moved to the framework). Otherwise,
use paths relative to the current directory, aka project's root.

Document that test/script/all.sh must be invoked from the project's root
(that was already the case, but implicit so far).

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
The existing check only took care of CONFIG_H. This was both not enough
and too much:
- not enough because config.py can also modify CRYPTO_CONFIG_H and we
want to know about it just as much as CONFIG_H;
- too much because CONFIG_H does not exist in tf-psa-crypto.

Check a list of files instead of a single one, and adjust that list.

Also update an outdated comment about Makefiles

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
With a first component.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
In order to avoid changing the CI job's definition (which fewer team
members understand, compared to shell scripts), just have a wrapper so
that all.sh does both mbedtls and tf-psa-crypto under the hood for now.

When tf-psa-crypto has its own CI running its own all.sh (with enough
components migrated to get sufficient coverage) we can remove this hack.

Rejected strategy: modify all-core.sh so that when running in mbedtls,
it also sources components-*.sh from tf-psa-crypto, remembers which
components come from Mbed TLS and which come from crypto, and magically
adjust the environment for each component it runs. Rejected because it's
hard to be confident we're adjusting everything that needs adjusting in
the environment. Having separate processes seems much safer.

The downside is we get more complexity around error handling (check for
components requested but not available, --keep-going). When using
--keep-going with failing component(s) in mbedtls and some components in
tf-psa-crypto, the output is not satisfying for humans as we don't have
a nice summary of all errors at the end like we normally would.

IMO this is acceptable since:
- this wrapper is transitional and should be removed in a few months;
- it is mainly for the benefit of the CI; humans can always invoke the
underlying commands directly.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
@mpg mpg added enhancement needs-review Every commit must be reviewed by at least two team members, needs-reviewer This PR needs someone to pick it up for review size-s Estimated task size: small (~2d) component-test Test framework and CI scripts priority-high High priority - will be reviewed soon labels Oct 24, 2024
@mpg mpg self-assigned this Oct 24, 2024
Copy link
Contributor

@ronald-cron-arm ronald-cron-arm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks promising to me. However ./tests/scripts/all.sh test_cmake_tf_psa_crypto_out_of_source does not seem to work (list of arguments empty for mbedtls-all.sh thus running all the components?). As I said in a comment, it would be more convenient if possible to support components with the same name in Mbed TLS and TF-PSA-Crypto. Thinking about it, we would probably need to change something in outcome.csv to differentiate the test results of such components.

tests/scripts/all.sh Outdated Show resolved Hide resolved
tests/scripts/all.sh Outdated Show resolved Hide resolved
tests/scripts/all.sh Outdated Show resolved Hide resolved
@@ -1,15 +1,96 @@
#! /usr/bin/env bash

Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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?

Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

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.

@gilles-peskine-arm
Copy link
Contributor

we would probably need to change something in outcome.csv to differentiate the test results of such components.

Presumably MBEDTLS_TEST_CONFIGURATION should ensure that the component names are different.

Note that #9286 (which we plan to merge this quarter) will make it an error to run use the same value of MBEDTLS_TEST_CONFIGURATION twice on the same platform.

@mpg
Copy link
Contributor Author

mpg commented Oct 25, 2024

However ./tests/scripts/all.sh test_cmake_tf_psa_crypto_out_of_source does not seem to work (list of arguments empty for mbedtls-all.sh thus running all the components?)

Aw, silly me, forgot to test the simple case of a single component. Will fix.

@davidhorstmann-arm davidhorstmann-arm self-requested a review October 29, 2024 10:16
@mpg mpg requested a review from bensze01 October 29, 2024 10:17
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
@mpg
Copy link
Contributor Author

mpg commented Oct 30, 2024

Internal CI fully passed, and OpenCI only failed the armcc components which are a known temporary issue.

@mpg
Copy link
Contributor Author

mpg commented Oct 30, 2024

The component that was moved to tf-psa-crypto is not showing up in outcomes.csv.xz. I checked the pipeline log and it ran, so the problem is that the outcome is not recorded. I strongly suspect that's become the path to the outcomes file is relative, so the file will be created in tf-psa-crypto where it's not going to be picked up later when all the outcomes files from each component are concatenated.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
@mpg
Copy link
Contributor Author

mpg commented Oct 30, 2024

The component that was moved to tf-psa-crypto is not showing up in outcomes.csv.xz. I checked the pipeline log and it ran, so the problem is that the outcome is not recorded. I strongly suspect that's become the path to the outcomes file is relative, so the file will be created in tf-psa-crypto where it's not going to be picked up later when all the outcomes files from each component are concatenated.

The last commit seems to have fixed this. I downloaded the outcomes file from the Open CI run (Internal CI has not completed yet) then extracted the list of components with cut -d';' -f2 outcomes-new.csv | sort -u and compared to the outcomes files of the nightly run from 23 Oct (when this PR was branched out), and the only difference was the various component_release that are expected to be run only in the nightly, so everything's as expected.

@mpg mpg requested review from Harry-Ramsey and removed request for davidhorstmann-arm November 4, 2024 09:51
fi
fi

if [ "$#" -ne 4 -o "$1" != '--seed' -o "$3" != '--keep-going' ]; then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I attempt to run the script using the following command ./tests/scripts/all.sh test_cmake_tf_psa_crypto_out_of_source I encounter the following error:

./tests/scripts/all.sh: line 58: $3: unbound variable

I believe this is incorrect and I should either be greeted with the error or the command executes?

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
Copy link
Contributor

@Harry-Ramsey Harry-Ramsey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, LGTM.

@ronald-cron-arm ronald-cron-arm removed the needs-reviewer This PR needs someone to pick it up for review label Nov 4, 2024
Copy link
Contributor

@eleuzi01 eleuzi01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@eleuzi01 eleuzi01 added approved Design and code approved - may be waiting for CI or backports needs-backports Backports are missing or are pending review and approval. and removed needs-review Every commit must be reviewed by at least two team members, needs-backports Backports are missing or are pending review and approval. labels Nov 6, 2024
Copy link
Contributor

@gilles-peskine-arm gilles-peskine-arm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gatekeeper note: I'm blocking merging because I'm concerned that this may introduce an intermittent CI failure. Feel free to override my change request if my concern is invalid.

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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Echoing Harry's concern in #9755 (comment) : we currently prevent component_test_cmake_out_of_source from running on Ubuntu 16.04, but now component_test_cmake_tf_psa_crypto_out_of_source will run on Ubuntu 16.04. Why is this not a problem? I don't see it discussed in the review here.

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?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The component component_test_cmake_tf_psa_crypto_out_of_source is not added by this PR. This PR moves it from tests/scripts/components-build-system.sh to tf-psa-crypto/tests/scripts/components-build-system.sh. The component was added by the PR 9445 without protection against Ubuntu 16.04 (we just missed that point I think) which was merged October the 3rd. Thus it has been around for more that a month now. Enough to gain confidence?

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.

Feel free to override my change request if my concern is invalid.

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.

Copy link
Contributor

Choose a reason for hiding this comment

The 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.

@gilles-peskine-arm gilles-peskine-arm added needs-work needs-backports Backports are missing or are pending review and approval. labels Nov 6, 2024
@mpg mpg removed needs-work needs-backports Backports are missing or are pending review and approval. labels Nov 6, 2024
@mpg mpg enabled auto-merge November 6, 2024 20:33
@mpg mpg disabled auto-merge November 6, 2024 21:04
@mpg mpg added needs-work and removed approved Design and code approved - may be waiting for CI or backports labels Nov 6, 2024
@mpg mpg dismissed gilles-peskine-arm’s stale review November 7, 2024 08:48

The point raised is pre-existing and not made any worse by this PR; if we do something about it there's not reason it should be in this PR.

@mpg mpg added approved Design and code approved - may be waiting for CI or backports and removed needs-work labels Nov 7, 2024
@mpg mpg added this pull request to the merge queue Nov 7, 2024
Merged via the queue into Mbed-TLS:development with commit e248de5 Nov 7, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Design and code approved - may be waiting for CI or backports component-test Test framework and CI scripts enhancement priority-high High priority - will be reviewed soon size-s Estimated task size: small (~2d)
Development

Successfully merging this pull request may close these issues.

5 participants