-
Notifications
You must be signed in to change notification settings - Fork 199
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
xtest: Add test of gcov #457
Conversation
Adds test for gcov in the range 31000 This patch adds a set of test of the generation of code coverage: (At the font of the test suite) - 31001: Check the code coverage is enabled for the core: - 31002: Check the code coverage is enabled for the TA: - 31003: Dump the current code coverage of the core - 31004: Reset the code coverage of the core (Normal execution in order, should be at the end) - 31005: Dump different code coverage: - 31005.1: Core code coverage from xtest - 31005.2: Core code coverage from TA - 31005.3: TA code coverage from TA The test are added using ADBG_CASE_DEFINE_FRONT to the test suite so the code coverage of the core is resetted before executing xtest suite and dump at the end. It allows to capture the code coverage of the core when running xtest. Signed-off-by: Franck LENORMAND <franck.lenormand@nxp.com>
@@ -0,0 +1,160 @@ | |||
/* |
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.
license tag? (bsd2? gpl2?)
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.
I will add the GPL tags to all the files
host/xtest/gcov.c
Outdated
|
||
#include <tee_client_api.h> | ||
#include <ta_gcov.h> | ||
#include <pta_gcov.h> |
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.
sort these group:
#include <pta_gcov.h>
#include <ta_gcov.h>
#include <tee_client_api.h>
If not i unique alpha Maybe a unique list of #include <>
(with those from line 4 to 12) sorted alphabetically , at your will.
(edited)
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.
ok
host/xtest/gcov.c
Outdated
{ | ||
TEEC_Session session = { }; | ||
TEEC_Operation op = TEEC_OPERATION_INITIALIZER; | ||
uint32_t ret_orig; |
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.
prefer with an init value. 0 is fine.
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.
ok
Do_ADBG_EndSubCase(c, "Dump %s", conf->desc); | ||
} | ||
} | ||
ADBG_CASE_DEFINE(regression, 31005, xtest_tee_test_31005, |
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.
regression
tests are currently all from regression_.c source files.
Either use a new suite gcov
(for this gcov.c)?
or more simply rename gcov.c to regression_3000.c? where we maybe start putting debug tools tests in regression 3xxx.
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.
There is a few constraints I want to have for the gcov test:
- Dump the coverage of the core at boot
- Clear the core code coverage
- execute xtest
- Dump the code coverage of the core
This way, running gcov allowed to dump the relevent code coverage without the need for another app called by the user.
this is why the tests for gcov are added last as object file so I can place the test 1 to 4 at the start of the list to run (ADBG_CASE_DEFINE_FRONT) and the 5th at the end.
I could make an implementation more flexible by having the following:
- current tests in regression_3000.c
- test suite gcov with copy of test 3 and 5
So the user would have to do: - xtest gcov 0 (dump core code coverage and clean)
- xtest
- xtest gcov 1 (dump core code coverage corresponding to the execution of xtest)
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.
I think having extra xtest arguments would be flexible, i.e.:
xtest --gcov-version
to get the 2 gcov version info
xtest --gcov-core
to collect gcov data for the core
xtest --gcov-clean
to clean gcov data
xtest --gcov-collect
to collect gcov data
ta/CMakeLists.txt
Outdated
@@ -20,4 +20,5 @@ target_include_directories(${PROJECT_NAME} | |||
INTERFACE socket/include | |||
INTERFACE storage_benchmark/include | |||
INTERFACE tpm_log_test/include | |||
INTERFACE gcov/include |
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.
move to line 13, in alpha ordering
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.
sure
if (res != TEE_SUCCESS) { | ||
EMSG("TEE_OpenTASession failed with code 0x%x origin 0x%x", | ||
res, err_origin); | ||
goto exit; |
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.
shoudl return, not close an invalid sess
handle.
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.
I have fixed the fail path
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.
ok as-is but it think it would be easier to return res;
straight here.
ta/gcov/ta_gcov.c
Outdated
TEE_TASessionHandle sess; | ||
uint32_t err_origin; | ||
uint32_t int_ptypes = 0; | ||
TEE_Param int_params[TEE_NUM_PARAMS] = {0}; |
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.
s/{0}/{ 0 }/ (with space chars)
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.
ok
ta/gcov/ta_gcov.c
Outdated
TEE_PARAM_TYPE_NONE); | ||
uint32_t cRT = TEE_TIMEOUT_INFINITE; | ||
TEE_UUID uuid = (TEE_UUID)PTA_GCOV_UUID; | ||
TEE_TASessionHandle sess; |
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.
prefer always an init vlaue. (ret
above also, and those below)
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.
ok
|
||
#define TA_FLAGS (TA_FLAG_USER_MODE | TA_FLAG_EXEC_DDR | \ | ||
TA_FLAG_SECURE_DATA_PATH | \ | ||
TA_FLAG_CACHE_MAINTENANCE) |
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.
These flags are not needed. #define TA_FLAGS 0
should be fine here.
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.
yes, thanks
@@ -0,0 +1,143 @@ | |||
/* |
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.
Please add an SPDX license tag.
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.
sure
Signed-off-by: Franck LENORMAND <franck.lenormand@nxp.com>
This pull request has been marked as a stale pull request because it has been open (more than) 30 days with no activity. Remove the stale label or add a comment, otherwise this pull request will automatically be closed in 5 days. Note that you can always re-open a closed pull request at any time. |
I have pushed a patch to addresse etienne comment. |
This pull request has been marked as a stale pull request because it has been open (more than) 30 days with no activity. Remove the stale label or add a comment, otherwise this pull request will automatically be closed in 5 days. Note that you can always re-open a closed pull request at any time. |
@etienne-lms ping? |
(void)ADBG_EXPECT_TEEC_SUCCESS(c, | ||
TEEC_InvokeCommand(&session, cmd, &op, &ret_orig)); | ||
|
||
ADBG_EXPECT_TRUE(c, (op.params[0].value.a != 0)); |
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.
can drop inner parentheses.
op.paramTypes = TEEC_PARAM_TYPES(TEEC_VALUE_OUTPUT, TEEC_NONE, | ||
TEEC_NONE, TEEC_NONE); | ||
|
||
(void)ADBG_EXPECT_TEEC_SUCCESS(c, |
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.
can remove (void)
.
Do_ADBG_EndSubCase(c, "Dump %s", conf->desc); | ||
} | ||
} | ||
ADBG_CASE_DEFINE(regression, 31005, xtest_tee_test_31005, |
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.
I think having extra xtest arguments would be flexible, i.e.:
xtest --gcov-version
to get the 2 gcov version info
xtest --gcov-core
to collect gcov data for the core
xtest --gcov-clean
to clean gcov data
xtest --gcov-collect
to collect gcov data
TEE_PARAM_TYPE_NONE, | ||
TEE_PARAM_TYPE_NONE, | ||
TEE_PARAM_TYPE_NONE); | ||
if (param_types != exp_param_types) { |
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.
add an empty line above
} | ||
|
||
TEE_Result TA_OpenSessionEntryPoint(uint32_t param_types, | ||
TEE_Param params[4], void **sess_ctx) |
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.
checkpatch would require indentation to parenthesis.
res = TEE_InvokeTACommand(sess, cRT, PTA_CMD_GCOV_CORE_DUMP_ALL, | ||
int_ptypes, int_params, &err_origin); | ||
if (res != TEE_SUCCESS) | ||
EMSG("TEE_InvokeTACommand failed with code 0x%x origin 0x%x", |
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.
EMSG("... code %#"PRIx32" origin %#"PRIx32",
even if more than 80 char in this line
if (res != TEE_SUCCESS) { | ||
EMSG("TEE_OpenTASession failed with code 0x%x origin 0x%x", | ||
res, err_origin); | ||
goto exit; |
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.
ok as-is but it think it would be easier to return res;
straight here.
case TA_GCOV_CMD_DUMP_TA: | ||
return dump_ta(param_types, params); | ||
default: | ||
EMSG("Command %d not supported", cmd_id); |
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.
s/%d/%"PRIu32"/
TEE_PARAM_TYPE_NONE, | ||
TEE_PARAM_TYPE_NONE, | ||
TEE_PARAM_TYPE_NONE); | ||
uint32_t cRT = TEE_TIMEOUT_INFINITE; |
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.
s/cRT/c_rt/ prefer snake case in OP-TEE C source files.
TEE_PARAM_TYPE_NONE, | ||
TEE_PARAM_TYPE_NONE); | ||
if (param_types != exp_param_types) { | ||
EMSG("Wrong param_types, exp %x, got %x", exp_param_types, |
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.
EMSG("Wrong param_types, exp %#"PRIx32", got #"PRIx32,
exp_param_types, param_types);
Must use PRIx32
and PRIu32
with uint32_t
typed arguments.
This pull request has been marked as a stale pull request because it has been open (more than) 30 days with no activity. Remove the stale label or add a comment, otherwise this pull request will automatically be closed in 5 days. Note that you can always re-open a closed pull request at any time. |
Adds test for gcov in the range 31000
This patch adds a set of test of the generation of code coverage:
(At the font of the test suite)
(Normal execution in order, should be at the end)
The test are added using ADBG_CASE_DEFINE_FRONT to the test suite
so the code coverage of the core is resetted before executing xtest
suite and dump at the end.
It allows to capture the code coverage of the core when running
xtest.