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

xtest: Add test of gcov #457

Closed
wants to merge 2 commits into from

Conversation

lenormandfranck
Copy link

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.

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 @@
/*
Copy link
Contributor

Choose a reason for hiding this comment

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

license tag? (bsd2? gpl2?)

Copy link
Author

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


#include <tee_client_api.h>
#include <ta_gcov.h>
#include <pta_gcov.h>
Copy link
Contributor

@etienne-lms etienne-lms Nov 6, 2020

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)

Copy link
Author

Choose a reason for hiding this comment

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

ok

{
TEEC_Session session = { };
TEEC_Operation op = TEEC_OPERATION_INITIALIZER;
uint32_t ret_orig;
Copy link
Contributor

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.

Copy link
Author

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,
Copy link
Contributor

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.

Copy link
Author

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)

Copy link
Contributor

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

@@ -20,4 +20,5 @@ target_include_directories(${PROJECT_NAME}
INTERFACE socket/include
INTERFACE storage_benchmark/include
INTERFACE tpm_log_test/include
INTERFACE gcov/include
Copy link
Contributor

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

Copy link
Author

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;
Copy link
Contributor

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.

Copy link
Author

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

Copy link
Contributor

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.

TEE_TASessionHandle sess;
uint32_t err_origin;
uint32_t int_ptypes = 0;
TEE_Param int_params[TEE_NUM_PARAMS] = {0};
Copy link
Contributor

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)

Copy link
Author

Choose a reason for hiding this comment

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

ok

TEE_PARAM_TYPE_NONE);
uint32_t cRT = TEE_TIMEOUT_INFINITE;
TEE_UUID uuid = (TEE_UUID)PTA_GCOV_UUID;
TEE_TASessionHandle sess;
Copy link
Contributor

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)

Copy link
Author

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)
Copy link
Contributor

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.

Copy link
Author

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 @@
/*
Copy link
Contributor

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.

Copy link
Author

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>
@github-actions
Copy link

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.

@github-actions github-actions bot added the Stale label Dec 10, 2020
@lenormandfranck
Copy link
Author

I have pushed a patch to addresse etienne comment.
I plan to keep the test part of gcov calls in xtest however I will move the calls which cannot really be tested (generation of data coverage) in its own test suite to avoid the workaround I am doing which will not be stable on the long term.

@github-actions github-actions bot removed the Stale label Dec 15, 2020
@github-actions
Copy link

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.

@jenswi-linaro
Copy link
Contributor

@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));
Copy link
Contributor

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,
Copy link
Contributor

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,
Copy link
Contributor

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) {
Copy link
Contributor

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)
Copy link
Contributor

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",
Copy link
Contributor

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;
Copy link
Contributor

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);
Copy link
Contributor

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;
Copy link
Contributor

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,
Copy link
Contributor

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.

@github-actions
Copy link

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.

@github-actions github-actions bot added the Stale label Feb 15, 2021
@github-actions github-actions bot closed this Feb 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants