test: Update optee to do init and uninit from tests
Rather than having an init function and then running the tests, create a test-init function to do it. This will allow us to get rid of the command function. Fix the comment abotu 'environment' while we are here. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
@@ -8,7 +8,9 @@
|
|||||||
|
|
||||||
#include <test/test.h>
|
#include <test/test.h>
|
||||||
|
|
||||||
/* Declare a new environment test */
|
/* Declare a new optee test */
|
||||||
#define OPTEE_TEST(_name, _flags) UNIT_TEST(_name, _flags, optee)
|
#define OPTEE_TEST(_name, _flags) UNIT_TEST(_name, _flags, optee)
|
||||||
|
#define OPTEE_TEST_INIT(_name, _flags) UNIT_TEST_INIT(_name, _flags, optee)
|
||||||
|
#define OPTEE_TEST_UNINIT(_name, _flags) UNIT_TEST_UNINIT(_name, _flags, optee)
|
||||||
|
|
||||||
#endif /* __TEST_OPTEE_H__ */
|
#endif /* __TEST_OPTEE_H__ */
|
||||||
|
@@ -26,6 +26,41 @@ extern u32 __dtb_test_optee_no_optee_begin;
|
|||||||
static void *fdt;
|
static void *fdt;
|
||||||
static bool expect_success;
|
static bool expect_success;
|
||||||
|
|
||||||
|
static int optee_test_init(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;
|
||||||
|
|
||||||
|
ut_assertok(fdt_check_header(fdt_base));
|
||||||
|
ut_assertok(fdt_check_header(fdt_optee));
|
||||||
|
ut_assertok(fdt_check_header(fdt_no_optee));
|
||||||
|
|
||||||
|
fdt = malloc(FDT_COPY_SIZE);
|
||||||
|
if (!fdt)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Resize the FDT to 4k so that we have room to operate on
|
||||||
|
*
|
||||||
|
* (and relocate it since the memory might be mapped
|
||||||
|
* read-only)
|
||||||
|
*/
|
||||||
|
ut_assertok(fdt_open_into(fdt_base, fdt, FDT_COPY_SIZE));
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
OPTEE_TEST_INIT(optee_test_init, 0);
|
||||||
|
|
||||||
|
static int optee_test_uninit(struct unit_test_state *uts)
|
||||||
|
{
|
||||||
|
free(fdt);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
OPTEE_TEST_UNINIT(optee_test_uninit, 0);
|
||||||
|
|
||||||
static int optee_fdt_firmware(struct unit_test_state *uts)
|
static int optee_fdt_firmware(struct unit_test_state *uts)
|
||||||
{
|
{
|
||||||
const void *prop;
|
const void *prop;
|
||||||
@@ -101,26 +136,6 @@ int do_ut_optee(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
|
|||||||
void *fdt_base = &__dtb_test_optee_base_begin;
|
void *fdt_base = &__dtb_test_optee_base_begin;
|
||||||
int ret = -ENOMEM;
|
int ret = -ENOMEM;
|
||||||
|
|
||||||
uts = calloc(1, sizeof(*uts));
|
|
||||||
if (!uts)
|
|
||||||
return -ENOMEM;
|
|
||||||
|
|
||||||
ut_assertok(fdt_check_header(fdt_base));
|
|
||||||
ut_assertok(fdt_check_header(fdt_optee));
|
|
||||||
ut_assertok(fdt_check_header(fdt_no_optee));
|
|
||||||
|
|
||||||
fdt = malloc(FDT_COPY_SIZE);
|
|
||||||
if (!fdt)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Resize the FDT to 4k so that we have room to operate on
|
|
||||||
*
|
|
||||||
* (and relocate it since the memory might be mapped
|
|
||||||
* read-only)
|
|
||||||
*/
|
|
||||||
ut_assertok(fdt_open_into(fdt_base, fdt, FDT_COPY_SIZE));
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (1) Try to copy optee nodes from empty dt.
|
* (1) Try to copy optee nodes from empty dt.
|
||||||
* This should still run successfully.
|
* This should still run successfully.
|
||||||
|
Reference in New Issue
Block a user