mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2026-05-04 12:21:03 +02:00
test: Split optee tests into three functions
These tests run three different checks on the nodes, but the logic is currently all in one tests. Split the code out into three different tests, which do different setup and then run the same checks. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
1c05e2c0eb
commit
ba2feaf414
@ -81,7 +81,6 @@ static int optee_fdt_firmware(struct unit_test_state *uts)
|
||||
|
||||
return CMD_RET_SUCCESS;
|
||||
}
|
||||
OPTEE_TEST(optee_fdt_firmware, 0);
|
||||
|
||||
static int optee_fdt_protected_memory(struct unit_test_state *uts)
|
||||
{
|
||||
@ -124,38 +123,62 @@ static int optee_fdt_protected_memory(struct unit_test_state *uts)
|
||||
|
||||
return CMD_RET_SUCCESS;
|
||||
}
|
||||
OPTEE_TEST(optee_fdt_protected_memory, 0);
|
||||
|
||||
/* (1) Try to copy optee nodes from empty dt */
|
||||
static int optee_fdt_copy_empty(struct unit_test_state *uts)
|
||||
{
|
||||
void *fdt_no_optee = &__dtb_test_optee_no_optee_begin;
|
||||
|
||||
/* This should still run successfully */
|
||||
ut_assertok(optee_copy_fdt_nodes(fdt_no_optee, fdt));
|
||||
|
||||
expect_success = false;
|
||||
ut_assertok(optee_fdt_firmware(uts));
|
||||
ut_assertok(optee_fdt_protected_memory(uts));
|
||||
|
||||
return 0;
|
||||
}
|
||||
OPTEE_TEST(optee_fdt_copy_empty, 0);
|
||||
|
||||
/* (2) Try to copy optee nodes from prefilled dt */
|
||||
static int optee_fdt_copy_prefilled(struct unit_test_state *uts)
|
||||
{
|
||||
void *fdt_optee = &__dtb_test_optee_optee_begin;
|
||||
|
||||
ut_assertok(optee_copy_fdt_nodes(fdt_optee, fdt));
|
||||
|
||||
expect_success = true;
|
||||
ut_assertok(optee_fdt_firmware(uts));
|
||||
ut_assertok(optee_fdt_protected_memory(uts));
|
||||
|
||||
return 0;
|
||||
}
|
||||
OPTEE_TEST(optee_fdt_copy_prefilled, 0);
|
||||
|
||||
/* (3) Try to copy OP-TEE nodes into a already filled DT */
|
||||
static int optee_fdt_copy_already_filled(struct unit_test_state *uts)
|
||||
{
|
||||
void *fdt_optee = &__dtb_test_optee_optee_begin;
|
||||
|
||||
ut_assertok(fdt_open_into(fdt_optee, fdt, FDT_COPY_SIZE));
|
||||
ut_assertok(optee_copy_fdt_nodes(fdt_optee, fdt));
|
||||
|
||||
expect_success = true;
|
||||
ut_assertok(optee_fdt_firmware(uts));
|
||||
ut_assertok(optee_fdt_protected_memory(uts));
|
||||
|
||||
return 0;
|
||||
}
|
||||
OPTEE_TEST(optee_fdt_copy_already_filled, 0);
|
||||
|
||||
int do_ut_optee(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
|
||||
{
|
||||
struct unit_test *tests = UNIT_TEST_SUITE_START(optee);
|
||||
const int n_ents = UNIT_TEST_SUITE_COUNT(optee);
|
||||
struct unit_test_state *uts;
|
||||
void *fdt_optee = &__dtb_test_optee_optee_begin;
|
||||
void *fdt_no_optee = &__dtb_test_optee_no_optee_begin;
|
||||
void *fdt_base = &__dtb_test_optee_base_begin;
|
||||
int ret = -ENOMEM;
|
||||
|
||||
/*
|
||||
* (1) Try to copy optee nodes from empty dt.
|
||||
* This should still run successfully.
|
||||
*/
|
||||
ut_assertok(optee_copy_fdt_nodes(fdt_no_optee, fdt));
|
||||
|
||||
expect_success = false;
|
||||
ret = cmd_ut_category("optee", "", tests, n_ents, argc, argv);
|
||||
|
||||
/* (2) Try to copy optee nodes from prefilled dt */
|
||||
ut_assertok(optee_copy_fdt_nodes(fdt_optee, fdt));
|
||||
|
||||
expect_success = true;
|
||||
ret = cmd_ut_category("optee", "", tests, n_ents, argc, argv);
|
||||
|
||||
/* (3) Try to copy OP-TEE nodes into a already filled DT */
|
||||
ut_assertok(fdt_open_into(fdt_optee, fdt, FDT_COPY_SIZE));
|
||||
ut_assertok(optee_copy_fdt_nodes(fdt_optee, fdt));
|
||||
|
||||
expect_success = true;
|
||||
ret = cmd_ut_category("optee", "", tests, n_ents, argc, argv);
|
||||
|
||||
free(fdt);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user