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

Move crypto test suites #9394

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
088a1ab
make: Fix object clean-up
ronald-cron-arm Jul 12, 2024
701b88c
Move crypto test suites
ronald-cron-arm Jul 4, 2024
83538c4
Adapt path to framework data files
ronald-cron-arm Jul 11, 2024
476d51e
Adapt .gitignore files
ronald-cron-arm Jul 5, 2024
901a675
Adapt make build system
ronald-cron-arm Jul 9, 2024
7af1bea
CMake: Include CMakePrintHelpers
ronald-cron-arm Jul 11, 2024
7f410db
tests: CMake: Align/fix config test suite generation
ronald-cron-arm Jul 9, 2024
50292a4
Duplicate tests CMake file
ronald-cron-arm Jul 9, 2024
f76cd22
Adapt CMake build of TLS and x509 test suites
ronald-cron-arm Jul 9, 2024
9a93073
Add tf-psa-crypto test suites build
ronald-cron-arm Jul 9, 2024
f352279
Adapt make cscope
ronald-cron-arm Jul 11, 2024
f5a1785
Adapt test_psa_constant_names.py
ronald-cron-arm Jul 11, 2024
9e2ff40
Adapt code_style.py
ronald-cron-arm Jul 11, 2024
5903be2
Adapt abi_check.py
ronald-cron-arm Jul 11, 2024
c51b0d1
Adapt bump_version.sh
ronald-cron-arm Jul 11, 2024
0866936
Adapt basic-build-test.sh
ronald-cron-arm Jul 12, 2024
635a2be
Adapt all.sh
ronald-cron-arm Jul 12, 2024
77d6ac2
Adapt check_test_cases.py
ronald-cron-arm Jul 12, 2024
cf1af5a
Adapt some documentation
ronald-cron-arm Jul 12, 2024
6f55ddc
programs: fuzz: Fix comment
ronald-cron-arm Jul 12, 2024
3486950
Adapt make_generated_files.bat
ronald-cron-arm Jul 15, 2024
72d1888
Adapt run-test-suites.pl
ronald-cron-arm Jul 16, 2024
375ad34
Add programs directory in tf-psa-crypto directory
ronald-cron-arm Jul 17, 2024
c29dd98
Adapt check-generated-files.sh
ronald-cron-arm Jul 16, 2024
b6f6cc8
Adapt psasim
ronald-cron-arm Jul 18, 2024
3f8275e
Scripts improvements
ronald-cron-arm Jul 19, 2024
c04c2ed
Revert "Adapt psasim"
ronald-cron-arm Jul 22, 2024
3943467
psasim: Fix doorbell file path
ronald-cron-arm Jul 22, 2024
594ab41
psasim: Fix IPCs removal
ronald-cron-arm Jul 22, 2024
e0e26f7
psasim: Move file clean-up to all.sh
ronald-cron-arm Jul 22, 2024
0b796a4
psasim: Rename kill_server.sh to kill_servers.sh
ronald-cron-arm Jul 22, 2024
7262b47
all.sh: psasim: Start server in tf-psa-crypto/tests
ronald-cron-arm Jul 22, 2024
636e9ef
Update the framework submodule to the merge of PR38
ronald-cron-arm Jul 23, 2024
b16b8c2
Updated auto-generated psa_test_wrappers.
ronald-cron-arm Jul 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ cmake_minimum_required(VERSION 3.5.1)

include(CMakePackageConfigHelpers)

# Include convenience functions for printing properties and variables, like
# cmake_print_properties(), cmake_print_variables().
include(CMakePrintHelpers)

# https://cmake.org/cmake/help/latest/policy/CMP0011.html
# Setting this policy is required in CMake >= 3.18.0, otherwise a warning is generated. The OLD
# policy setting is deprecated, and will be removed in future versions.
Expand Down Expand Up @@ -401,6 +405,7 @@ if(ENABLE_TESTING)
enable_testing()

add_subdirectory(tests)
add_subdirectory(tf-psa-crypto/tests)

# additional convenience targets for Unix only
if(UNIX)
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Tests
-----
As mentioned, tests that show the correctness of the feature or bug fix should be added to the pull request, if no such tests exist.

Mbed TLS includes a comprehensive set of test suites in the `tests/` directory that are dynamically generated to produce the actual test source files (e.g. `test_suite_rsa.c`). These files are generated from a `function file` (e.g. `suites/test_suite_rsa.function`) and a `data file` (e.g. `suites/test_suite_rsa.data`). The function file contains the test functions. The data file contains the test cases, specified as parameters that will be passed to the test function.
Mbed TLS includes a comprehensive set of test suites in the `tests/` directory that are dynamically generated to produce the actual test source files (e.g. `test_suite_ssl.c`). These files are generated from a `function file` (e.g. `suites/test_suite_ssl.function`) and a `data file` (e.g. `suites/test_suite_ssl.data`). The function file contains the test functions. The data file contains the test cases, specified as parameters that will be passed to the test function.

[A Knowledge Base article describing how to add additional tests is available on the Mbed TLS website](https://mbed-tls.readthedocs.io/en/latest/kb/development/test_suites/).

Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ C_SOURCE_FILES = $(wildcard \
tests/include/*/*.h tests/include/*/*/*.h \
tests/src/*.c tests/src/*/*.c \
tests/suites/*.function \
tf-psa-crypto/tests/suites/*.function \
)
# Exuberant-ctags invocation. Other ctags implementations may require different options.
CTAGS = ctags --langmap=c:+.h.function --line-directives=no -o
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ Please note that the goal of these sample programs is to demonstrate specific fe
Tests
-----

Mbed TLS includes an elaborate test suite in `tests/` that initially requires Python to generate the tests files (e.g. `test\_suite\_mpi.c`). These files are generated from a `function file` (e.g. `suites/test\_suite\_mpi.function`) and a `data file` (e.g. `suites/test\_suite\_mpi.data`). The `function file` contains the test functions. The `data file` contains the test cases, specified as parameters that will be passed to the test function.
Mbed TLS includes an elaborate test suite in `tests/` that initially requires Python to generate the tests files (e.g. `test\_suite\_ssl.c`). These files are generated from a `function file` (e.g. `suites/test\_suite\_ssl.function`) and a `data file` (e.g. `suites/test\_suite\_ssl.data`). The `function file` contains the test functions. The `data file` contains the test cases, specified as parameters that will be passed to the test function.

For machines with a Unix shell and OpenSSL (and optionally GnuTLS) installed, additional test scripts are available:

Expand Down
4 changes: 2 additions & 2 deletions library/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ endif

static: libmbedcrypto.a libmbedx509.a libmbedtls.a
cd ../tests && echo "This is a seedfile that contains 64 bytes (65 on Windows)......" > seedfile
cd ../tf-psa-crypto/tests && echo "This is a seedfile that contains 64 bytes (65 on Windows)......" > seedfile

shared: libmbedcrypto.$(DLEXT) libmbedx509.$(DLEXT) libmbedtls.$(DLEXT)

Expand Down Expand Up @@ -397,11 +398,10 @@ clean:
ifndef WINDOWS
rm -f *.o libmbed*
rm -f $(OBJS_CRYPTO)
rm -f $(THIRDPARTY_CRYPTO_OBJECTS)
else
if exist *.o del /Q /F *.o
if exist libmbed* del /Q /F libmbed*
del /Q /F del_errors_out_if_the_file_list_is_empty_but_not_if_a_file_does_not_exist $(subst /,\,$(THIRDPARTY_CRYPTO_OBJECTS))
del /Q /F del_errors_out_if_the_file_list_is_empty_but_not_if_a_file_does_not_exist $(subst /,\,$(OBJS_CRYPTO))
endif

neat: clean
Expand Down
3 changes: 2 additions & 1 deletion programs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ generated_files: $(GENERATED_FILES)
psa/psa_constant_names_generated.c: $(gen_file_dep) ../scripts/generate_psa_constants.py
psa/psa_constant_names_generated.c: $(gen_file_dep) ../tf-psa-crypto/include/psa/crypto_values.h
psa/psa_constant_names_generated.c: $(gen_file_dep) ../tf-psa-crypto/include/psa/crypto_extra.h
psa/psa_constant_names_generated.c: $(gen_file_dep) ../tests/suites/test_suite_psa_crypto_metadata.data
psa/psa_constant_names_generated.c: $(gen_file_dep) ../tf-psa-crypto/tests/suites/test_suite_psa_crypto_metadata.data
psa/psa_constant_names_generated.c:
echo " Gen $@"
$(PYTHON) ../scripts/generate_psa_constants.py
Expand Down Expand Up @@ -417,6 +417,7 @@ x509/req_app$(EXEXT): x509/req_app.c $(DEP)
clean:
ifndef WINDOWS
rm -f $(EXES)
rm -f */*.o
-rm -f ssl/ssl_pthread_server$(EXEXT)
-rm -f test/cpp_dummy_build.cpp test/cpp_dummy_build$(EXEXT)
-rm -f test/dlopen$(EXEXT)
Expand Down
4 changes: 1 addition & 3 deletions programs/fuzz/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ ifdef FUZZINGENGINE
LOCAL_LDFLAGS += -lFuzzingEngine
endif

# A test application is built for each suites/test_suite_*.data file.
# Application name is same as .data file's base name and can be
# constructed by stripping path 'suites/' and extension .data.
# A test application is built for each fuzz_*.c file.
APPS = $(basename $(wildcard fuzz_*.c))

# Construct executable name by adding OS specific suffix $(EXEXT).
Expand Down
12 changes: 9 additions & 3 deletions scripts/abi_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,9 +350,15 @@ def _get_storage_format_tests(self, version, git_worktree_path):
"""
# Existing test data files. This may be missing some automatically
# generated files if they haven't been generated yet.
storage_data_files = set(glob.glob(
'tests/suites/test_suite_*storage_format*.data'
))
if os.path.isdir(os.path.join(git_worktree_path, 'tf-psa-crypto',
'tests', 'suites')):
storage_data_files = set(glob.glob(
'tf-psa-crypto/tests/suites/test_suite_*storage_format*.data'
))
else:
storage_data_files = set(glob.glob(
'tests/suites/test_suite_*storage_format*.data'
))
# Discover and (re)generate automatically generated data files.
to_be_generated = set()
for filename in self._list_generated_test_data_files(git_worktree_path):
Expand Down
4 changes: 2 additions & 2 deletions scripts/bump_version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ cat include/mbedtls/build_info.h | \
mv tmp include/mbedtls/build_info.h

[ $VERBOSE ] && echo "Bumping version in tests/suites/test_suite_version.data"
sed -e "s/version:\".\{1,\}/version:\"$VERSION\"/g" < tests/suites/test_suite_version.data > tmp
mv tmp tests/suites/test_suite_version.data
sed -e "s/version:\".\{1,\}/version:\"$VERSION\"/g" < tf-psa-crypto/tests/suites/test_suite_version.data > tmp
Copy link
Contributor

Choose a reason for hiding this comment

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

Not a blocker for this PR, but I will take this opportunity to note that this will become more complicated once we split the repo.

In fact, we may want to move this testsuite back to Mbed TLS if TF-PSA-Crypto is going to have a separate version number.

Copy link
Contributor Author

@ronald-cron-arm ronald-cron-arm Jul 23, 2024

Choose a reason for hiding this comment

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

I think we will eventually have one mbedtls_version.c in Mbed TLS, one tf_psa_crypto_version.c in tf-psa-crypto and one version test suite in both of them.

mv tmp tf-psa-crypto/tests/suites/test_suite_version.data

[ $VERBOSE ] && echo "Bumping PROJECT_NAME in doxygen/mbedtls.doxyfile and doxygen/input/doc_mainpage.h"
for i in doxygen/mbedtls.doxyfile doxygen/input/doc_mainpage.h;
Expand Down
1 change: 1 addition & 0 deletions scripts/code_style.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def get_src_files(since: Optional[str]) -> List[str]:
"""
file_patterns = ["*.[hc]",
"tests/suites/*.function",
"tf-psa-crypto/tests/suites/*.function",
"scripts/data_files/*.fmt"]
output = subprocess.check_output(["git", "ls-files"] + file_patterns,
universal_newlines=True)
Expand Down
9 changes: 5 additions & 4 deletions scripts/make_generated_files.bat
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ perl scripts\generate_features.pl || exit /b 1
python scripts\generate_ssl_debug_helpers.py || exit /b 1
perl scripts\generate_visualc_files.pl || exit /b 1
python scripts\generate_psa_constants.py || exit /b 1
python framework\scripts\generate_bignum_tests.py || exit /b 1
python framework\scripts\generate_config_tests.py || exit /b 1
python framework\scripts\generate_ecp_tests.py || exit /b 1
python framework\scripts\generate_psa_tests.py || exit /b 1
python framework\scripts\generate_bignum_tests.py --directory tf-psa-crypto\tests\suites || exit /b 1
python framework\scripts\generate_config_tests.py tests\suites\test_suite_config.mbedtls_boolean.data || exit /b 1
python framework\scripts\generate_config_tests.py --directory tf-psa-crypto\tests\suites tests\suites\test_suite_config.psa_boolean.data || exit /b 1
python framework\scripts\generate_ecp_tests.py --directory tf-psa-crypto\tests\suites || exit /b 1
python framework\scripts\generate_psa_tests.py --directory tf-psa-crypto\tests\suites || exit /b 1
python framework\scripts\generate_test_keys.py --output tests\src\test_keys.h || exit /b 1
python framework\scripts\generate_test_cert_macros.py --output tests\src\test_certs.h || exit /b 1
3 changes: 0 additions & 3 deletions tests/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@
# Generated source files
/suites/*.generated.data
/suites/test_suite_config.mbedtls_boolean.data
/suites/test_suite_config.psa_boolean.data
/suites/test_suite_psa_crypto_storage_format.v[0-9]*.data
/suites/test_suite_psa_crypto_storage_format.current.data
/src/test_keys.h
/src/test_certs.h
###END_GENERATED_FILES###
Loading