Skip to content

Run sample program demo scripts in all.sh#7982

Merged
gilles-peskine-arm merged 18 commits intoMbed-TLS:developmentfrom
gilles-peskine-arm:sample_program_demo_scripts-3.4
Oct 18, 2023
Merged

Run sample program demo scripts in all.sh#7982
gilles-peskine-arm merged 18 commits intoMbed-TLS:developmentfrom
gilles-peskine-arm:sample_program_demo_scripts-3.4

Conversation

@gilles-peskine-arm
Copy link
Copy Markdown
Contributor

@gilles-peskine-arm gilles-peskine-arm commented Jul 25, 2023

Run sample program demo scripts (programs/test/*_demo.sh) in a few components of all.sh.

In the long term, we should run the programs in all configurations, but this requires declaring dependencies properly. For the time being, just run the programs in a few builds (out-of-box, full config, with sanitizers, without deprecated functions).

This is a rebase of a part of #2698, adapted for the evolution of the development branch and omitting the new demo script for certificate-related programs.

  • Create programs/demo_common.sh for common logic.
  • Create run_demos.py and run it from a few components in all.sh.
  • Do different changes to check_files.py because that part of the file has evolved.
  • New: Adapt dlopen_demo.sh which didn't exist at the time of the original PR. (It's more of a test than a demo, but I prefer to keep things conceptually simple and treat it in the same way.)

PR checklist

Please tick as appropriate and edit the reasons (e.g.: "backport: not needed because this is a new feature")

run_demos.py is the frontend to a framework for smoke-testing the
sample programs. It runs scripts called programs/*/*_demo.sh
("demo scripts") and check that they succeed. A typical demo script
runs one sample program or a combination of sample programs to
demonstrate their usage.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
The new file programs/demo_common.sh contains initialization code,
utility functions and cleanup code meant to be used by all demo
scripts written in sh.

Initial features:

* msg: Display a message.
* run, run_bad: Run a command, visibly.
* $root_dir, $programs_dir: location of the mbedtls source tree.
* $files_to_clean: files that are cleaned up on exit.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
Demo scripts should declare their build-time dependencies, to make
them more user-friendly. If a dependency is not met, users should see
an explicit message rather than an incomprehensible error.

Don't rely on the dependencies of individual programs because some
demo scripts use multiple programs and because some scripts might have
additional requirements.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
Run the sample program demo scripts in builds with a configuration
that is at least as complete as the default configuration.

Do not run sample programs in all configurations since they are
expected to fail if a required feature is missing.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
Since there's no EXIT trap in plain sh, the main script must call it
explicitly when it exits.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
@gilles-peskine-arm gilles-peskine-arm added needs-ci Needs to pass CI tests size-s Estimated task size: small (~2d) component-test Test framework and CI scripts priority-medium Medium priority - this can be reviewed as time permits labels Jul 25, 2023
ShebangIssueTracker implements the rule that scripts must be executable if
and only if they have a shebang line. By removing PermissionIssueTracker, we
now allow files with any extension to be executable (provided they have a
shebang line), and allow *.sh and *.pl to be non-executable modules if they
don't have a shebang line (as was already the case for *.py).

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
@gilles-peskine-arm gilles-peskine-arm added 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 labels Jul 26, 2023
@gilles-peskine-arm gilles-peskine-arm marked this pull request as ready for review July 26, 2023 07:10
@gilles-peskine-arm gilles-peskine-arm removed the needs-ci Needs to pass CI tests label Jul 26, 2023
@tom-daubney-arm tom-daubney-arm self-requested a review August 3, 2023 08:51
Copy link
Copy Markdown
Contributor

@tom-daubney-arm tom-daubney-arm left a comment

Choose a reason for hiding this comment

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

I have given this a thorough review to the best of my ability and think it LGTM.
I am not the most experienced with bash however and can't be 100% confident about everything but I have not been able to find any issues with this PR and so I am approving.

It would be really great if the second reviewer was adept at bash to make sure there aren't issues being missed here.

@davidhorstmann-arm davidhorstmann-arm self-requested a review August 4, 2023 09:32
@tom-daubney-arm tom-daubney-arm removed the needs-reviewer This PR needs someone to pick it up for review label Aug 4, 2023
@tom-daubney-arm tom-daubney-arm removed the request for review from davidhorstmann-arm October 16, 2023 08:54
@tom-daubney-arm tom-daubney-arm added the needs-reviewer This PR needs someone to pick it up for review label Oct 16, 2023
@davidhorstmann-arm davidhorstmann-arm self-requested a review October 16, 2023 09:23
@mpg mpg removed the needs-reviewer This PR needs someone to pick it up for review label Oct 17, 2023
Copy link
Copy Markdown
Contributor

@davidhorstmann-arm davidhorstmann-arm left a comment

Choose a reason for hiding this comment

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

LGTM, one non-blocker no issues

@davidhorstmann-arm davidhorstmann-arm added approved Design and code approved - may be waiting for CI or backports and removed needs-review Every commit must be reviewed by at least two team members, labels Oct 17, 2023
@gilles-peskine-arm gilles-peskine-arm added this pull request to the merge queue Oct 18, 2023
Merged via the queue into Mbed-TLS:development with commit 0ea1b8f Oct 18, 2023
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 priority-medium Medium priority - this can be reviewed as time permits size-s Estimated task size: small (~2d)

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

4 participants