-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
PSA client-server: support in the unit test framework #9237
base: development
Are you sure you want to change the base?
Conversation
cdde639
to
21150f3
Compare
5c8728a
to
d530744
Compare
9f1136c
to
2a52677
Compare
Question for reviewers: perhaps 81dd9b0 can be set as a separate PR as we did for other commits which were not strictly related to |
@@ -0,0 +1,8 @@ | |||
#!/bin/bash |
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.
Missing copyright headers
@@ -0,0 +1,17 @@ | |||
#!/bin/bash |
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.
Missing copyright headers
2d401be
to
587977b
Compare
tests/scripts/all.sh
Outdated
|
||
msg "build library for client" | ||
helper_crypto_client_build client | ||
|
||
msg "build psasim to test psa_client" | ||
rm -f tests/psa-client-server/psasim/test/psa_client # In case left behind | ||
make -C tests/psa-client-server/psasim CFLAGS="$ASAN_CFLAGS" LDFLAGS="$ASAN_CFLAGS" test/psa_client | ||
rm -f $PSASIM_PATH/test/psa_client # In case left behind |
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 feels like it could be done in the cleanup_before_psasim_client()
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.
No, if kept, this should be before make
is called - specifically, because we were changing what was being built as psa_client, we want to make sure any existing such executable is removed, because make
uses timestamps to determine what to build, and timestamps on other .c
files might be older than when the last psa_client
program was built.
If we're getting rid of all that (haven't reviewed in detail) we probably don't need this rm
at all
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.
cleanup_before_psasim_client
is meant to be called after the server has been built and before building the client. However please note that test/psa_client
is only built in test_psasim
not with standard test_suite_xxx
and since test_suite_xxx
is the preferred way of testing for the future, I think we can keep this command only here.
Besides I also think that once we'll have a good coverage of test_suite_xxx
in the future we can also remove test_psasim
because that will be superseded by those tests.
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.
in the future we can also remove test_psasim
I think it will be useful to keep this as a smoke test, as if something goes wrong (i.e. we break psasim somehow) it will be very hard to debug once the whole test machinery is involved
tests/scripts/all.sh
Outdated
|
||
msg "test psasim running psa_hash_compute" | ||
tests/psa-client-server/psasim/test/run_test.sh | ||
$PSASIM_PATH/test/run_test.sh | ||
|
||
|
||
# Next APIs under test: psa_hash_*(). Use our copy of the PSA hash example. |
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 whole block could be a helper function
build_psasim() {
msg "build psasim to test $1"
rm tests/psa-client-server/psasim/test/psa_client
rm $PSASIM_PATH/test/psa_client
make -C $PSASIM_PATH CFLAGS="$ASAN_CFLAGS" LDFLAGS="$ASAN_CFLAGS" MAIN="src/$1.c" test/psa_client
$PSASIM_PATH/test/run_test.sh
}
This could scale easier and we could even use an iterator to go through all the tests
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.
Yeah, I like this
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.
As for the comment above, please note that run_test.sh
is only useful for test_psasim
component not for test_suite_with_psasim
and all other upcoming tests relying on test_suite_xxx
. Once all PSA functions will be supported, make PSASIM=1 test
will be the way to test with psasim (as it is done in test_suite_with_psasim
). No need to manually iterate of test_suite_xxx
; this is done "for free" by the current test framework. All test_suite_xxx
will be linked against our client side implementation of psasim and they will connect to the server that has previously been launched in background.
What can be moved as helper is starting/stopping the PSA server in test_suite_with_psasim
:
(
cd tests
msg "start server"
psa-client-server/psasim/test/start_server.sh
)
and
(
cd tests
msg "terminate server and cleanup"
psa-client-server/psasim//test/kill_server.sh
)
scripts/common.make
Outdated
@@ -132,4 +153,13 @@ MBEDTLS_TLS_TEST_OBJS = $(patsubst %.c,%.o,$(wildcard \ | |||
${MBEDTLS_TEST_PATH}/src/test_helpers/*.c \ | |||
)) | |||
|
|||
# THIS IS A TEMPORARY FIX!!!!!!! | |||
# IT MUST BE REMOVED AS SOON AS LIBPSACLIENT WILL SUPPORT ALL PSA | |||
# FUNCTIONS. |
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.
So what is preventing this fix being removed now?
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
Now that we have PSASIM we can really test CRYPTO_CLIENT functionality and those functions are not needed anymore. Moreover new test suites that are going to rely on CRYPTO_CLIENT && !CRYPTO_C would be tested from test_default_psa_crypto_client_without_crypto_provider() leading to failures due to stub functions being empty. Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
8f333c2
to
446acd0
Compare
- do not try to close a connection that was never started - fix data chunks length for psa_write (prevent memcpy-ing to large blocks of data) Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
This commit includes the following changes: - on the psasim side it clears a certain operation slot on "finish()" and "abort()" operations - in all.sh it builds all the test suites, but it just executes the constant_time_hmac one because it's one of those that quickly show the problem Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
446acd0
to
bb27fb8
Compare
I've updated I've also removed the changes to Instead, on server serialisation, when serialising the operation to send back to the client, we have an extra parameter There's also a bit of extra testing code added to |
Note that |
Description
This is a first attempt to link already existing 'test_suite_xxx' source files to the 'psasim' simulation. So far only a limited subset of
test_suite_xxx
are tested because of the limited number of PSA APIs functions inpsasim
. This limit will be lifted oncepsasim
will support all PSA APIs so that's why this PR is to be kept as work-in-progress as long as this support is improved.Resolves #8968
Resolves #8966
PR checklist