813 Commits

Author SHA1 Message Date
Pengyu Lv
e95df0bd70 Fix CI failure
Signed-off-by: Pengyu Lv <pengyu.lv@arm.com>
2023-02-16 18:12:51 +08:00
Pengyu Lv
4a37eef78f Only check files known to git
Signed-off-by: Pengyu Lv <pengyu.lv@arm.com>
2023-02-16 18:12:51 +08:00
Pengyu Lv
bae83d25eb Improve readability
Signed-off-by: Pengyu Lv <pengyu.lv@arm.com>
2023-02-16 18:12:51 +08:00
Pengyu Lv
44b75a605b adjust help message
Signed-off-by: Pengyu Lv <pengyu.lv@arm.com>
2023-02-16 18:12:51 +08:00
Pengyu Lv
75e11d3703 print skipped file names to stdout
Signed-off-by: Pengyu Lv <pengyu.lv@arm.com>
2023-02-16 18:12:51 +08:00
Pengyu Lv
a4b9b7700a code_style.py: Add helpers to print warning and skipped files
Signed-off-by: Pengyu Lv <pengyu.lv@arm.com>
2023-02-16 18:12:51 +08:00
Pengyu Lv
b1c9cc3ae4 code_style.py: Apply exclusions to the file list
This commit rename `--files` options to `--subset` and
it means to check a subset of the files known to git.

Signed-off-by: Pengyu Lv <pengyu.lv@arm.com>
2023-02-16 18:12:51 +08:00
Gilles Peskine
d6bb16a5b8
Merge pull request #6976 from davidhorstmann-arm/2.28-c-build-helper-improvements
[Backport 2.28] Minor improvements to `c_build_helper.py`
2023-02-07 10:26:03 +01:00
Gilles Peskine
9a10538f20
Merge pull request #6965 from davidhorstmann-arm/2.28-code-style-improvements
[Backport 2.28] Improvements to code style script
2023-01-31 21:22:59 +01:00
David Horstmann
e28f2ee685 Add docstring for new compile function.
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-01-30 09:52:01 +00:00
David Horstmann
0b1b97badf Make c_build_helper module respect HOSTCC
If HOSTCC is set, use that to generate files, otherwise use CC. This
should make cross-compilation with generated files slightly easier.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-01-27 19:56:49 +00:00
David Horstmann
ddb09e4f17 c_build_helper.py: Move compile to helper
Move compilation to a separate helper function in c_build_helper.py to
allow more generic use.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-01-27 19:56:47 +00:00
Manuel Pégourié-Gonnard
27276fcb97
Merge pull request #6844 from gilles-peskine-arm/test_suite_psa_crypto_metadata-20221215-2.28
Backport 2.28: Add metadata tests for CCM* and TLS1.2-ECJPAKE-to-PMS
2023-01-27 10:05:04 +01:00
David Horstmann
04aaa45ee1 Remove unnecessary '\' linebreak characters
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-01-25 11:39:45 +00:00
David Horstmann
659d905cf9 Give proper Dict type hints in crypto_knowledge.py
This prevents a return type error in a later function that uses the
dictionaries here properly typed.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-01-24 19:01:31 +00:00
David Horstmann
6956cb58ac Don't wrap stdout and stderr in UTF-8 wrapper
This is no longer needed as we only print ASCII text directly

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-01-24 18:43:12 +00:00
David Horstmann
5682e80266 Output diff without capturing it
Instead of capturing the output of diff and printing it, let diff do its
own outputting and se the return code to decide what to do.

This also means that the conversion of stdout to UTF-8 is not necessary,
as the reason it was needed was for printing diffs of files with UTF-8
characters in them.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-01-24 18:43:12 +00:00
David Horstmann
6d02f0cfa0 Add basic output on success
Whilst it is true that "silence is golden", no output at all could be
disconcerting and it makes searching in a CI log more difficult.

Add a simple status message that says "Checked N files, style ok".

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-01-24 18:43:12 +00:00
David Horstmann
3febe15114 Remove overly verbose output on success
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-01-24 18:43:12 +00:00
David Horstmann
64827e4611 Change print to print_err for an error message
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-01-24 18:43:12 +00:00
David Horstmann
a27d872228 Document that the script must be run from the root
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-01-24 18:43:12 +00:00
David Horstmann
f7b7bf7a5e Remove provisional notice on code style script
Since code style is now enforced, the notice is wrong. Remove it to
avoid confusion.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-01-24 18:43:12 +00:00
Gilles Peskine
1d671c90db
Merge pull request #6835 from gilles-peskine-arm/code-style-files-2.28
Backport 2.28: code_style.py: Support restyling only the specified files
2023-01-19 12:26:07 +01:00
Gilles Peskine
b71d28b695 Fix example command
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-01-17 18:09:39 +00:00
Gilles Peskine
1b6c09a62e Switch to the new code style
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-01-11 14:52:35 +01:00
Thomas Daubney
0c6052f041 Modify generate errors script
Modify generate_errors.pl such that it can now handle
opening files where the file path includes a directory
name containing spaces.

Raised in issue #6879. Fix provided by
@tom-cosgrove-arm in aforementioned issue.

Signed-off-by: Thomas Daubney <thomas.daubney@arm.com>
2023-01-09 18:48:01 +00:00
David Horstmann
242df48cab Fix pylint warnings about comparison to True
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-01-05 10:04:21 +00:00
David Horstmann
fa69def8e3 Fix incorrect typing of function in code_style.py
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-01-05 10:03:48 +00:00
David Horstmann
b92d30f987 Check Uncrustify returncode in code_style.py
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-01-04 18:44:35 +00:00
Gilles Peskine
7f7630c0fe Refactoring: new method Algorithm.is_valid_for_operation
No intended behavior change.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-12-24 11:41:58 +01:00
Gilles Peskine
7528986f97 Documentation improvements
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-12-23 18:15:50 +01:00
Gilles Peskine
38f514dbc2 Support restyling only the specified files
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-12-22 16:37:55 +01:00
Gilles Peskine
4ca54d417e Don't touch the style of generated files
Ideally the result of the generator would conform to the code style, but
this would be difficult, especially with respect to the placement of line
breaks in long logical lines. So, to avoid surprises when checking the style
of generated files (which happens in releases and in long-time support
branches), systematically skip generated files.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-12-19 00:58:25 +01:00
Gilles Peskine
bb3d31659b You need --coverage when linking as well
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-12-13 18:44:14 +01:00
Gilles Peskine
26aae47042 Add option to reset the traces, to use after rework
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-12-13 18:44:14 +01:00
Gilles Peskine
f11c33c27c Put temporary files in a temporary directory
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-12-13 18:44:14 +01:00
Gilles Peskine
862e4a3f8d Add a bit of documentation
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-12-13 18:44:14 +01:00
Gilles Peskine
7f4705d8d4 Move lcov commands to a separate script
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-12-13 18:44:14 +01:00
David Horstmann
eead72ec9e Reindent line continuations for pylint
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2022-12-08 17:47:10 +00:00
David Horstmann
c747fdfe1f Fixup: Config file name in code style script
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2022-12-08 17:47:10 +00:00
David Horstmann
1f8b4d9c6b Add spaces around '+'
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2022-12-08 17:47:10 +00:00
David Horstmann
c543870882 Explain that the script is only for the future
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2022-12-08 17:47:10 +00:00
David Horstmann
3a6f9f9921 Use constant for supported Uncrustify version
Define and report the supported Uncrustify version (and remove extra
newlines from version output).

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2022-12-08 17:47:10 +00:00
David Horstmann
99a669a50d Fix typo in code style script
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2022-12-08 17:47:10 +00:00
David Horstmann
448cfec2a5 Use helper function for error printing
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2022-12-08 17:47:10 +00:00
David Horstmann
27b3704eef Miscellaneous improvements to code style script
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2022-12-08 17:47:10 +00:00
David Horstmann
20d6bfa8e7 Add script to run Uncrustify
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2022-12-06 17:02:35 +00:00
Gilles Peskine
377e7e93ba Documentation typo
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-10-14 15:34:06 +02:00
Gilles Peskine
7ff4766115 Unify check_repo_path
We had 4 identical copies of the check_repo_path function. Replace them by a
single copy in the build_tree module where it naturally belongs.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-10-14 15:34:06 +02:00
Gilles Peskine
239765ad3e Use relative imports when importing other modules in the same directory
We were using absolute imports under the assumption that the /scripts
directory is in the path. This worked in normal use because every one of our
Python scripts either were in the /scripts directory, or added the /scripts
directory to the module search path in order to reference mbedtls_dev.
However, this broke things like
```
python3 -m unittest scripts/mbedtls_dev/psa_storage.py
```

Fix this by using relative imports.

Relative imports are only supposed to be used inside a package (Python
doesn't complain, but Pylint does). So make /scripts/mbedtls_dev a proper
package by creating __init__.py.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-10-14 15:34:06 +02:00