mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-10 15:14:43 +00:00
test: dm: add tests for tag support
The new test covers all tag-related interfaces. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
b77324d831
commit
8ff50227be
2 changed files with 85 additions and 0 deletions
|
@ -102,6 +102,7 @@ obj-y += syscon.o
|
|||
obj-$(CONFIG_RESET_SYSCON) += syscon-reset.o
|
||||
obj-$(CONFIG_SYSINFO) += sysinfo.o
|
||||
obj-$(CONFIG_SYSINFO_GPIO) += sysinfo-gpio.o
|
||||
obj-$(CONFIG_UT_DM) += tag.o
|
||||
obj-$(CONFIG_TEE) += tee.o
|
||||
obj-$(CONFIG_TIMER) += timer.o
|
||||
obj-$(CONFIG_DM_USB) += usb.o
|
||||
|
|
84
test/dm/tag.c
Normal file
84
test/dm/tag.c
Normal file
|
@ -0,0 +1,84 @@
|
|||
// SPDX-License-Identifier: GPL-2.0+
|
||||
/*
|
||||
* DM tag test
|
||||
*
|
||||
* Copyright (c) 2021 Linaro Limited
|
||||
* Author: AKASHI Takahiro
|
||||
*/
|
||||
|
||||
#include <common.h>
|
||||
#include <dm/tag.h>
|
||||
#include <dm/test.h> /* DM_TEST() */
|
||||
#include <test/test.h> /* struct unit_test_state */
|
||||
#include <test/ut.h> /* assertions */
|
||||
|
||||
/*
|
||||
* Test dm_tag_ptr() API
|
||||
*/
|
||||
static int dm_test_tag_ptr(struct unit_test_state *uts)
|
||||
{
|
||||
ulong val;
|
||||
void *ptr = NULL;
|
||||
|
||||
ut_assertok(dev_tag_set_ptr(uts->root, DM_TAG_EFI, &val));
|
||||
|
||||
ut_assertok(dev_tag_get_ptr(uts->root, DM_TAG_EFI, &ptr));
|
||||
|
||||
ut_asserteq_ptr(&val, ptr);
|
||||
|
||||
ut_assertok(dev_tag_del(uts->root, DM_TAG_EFI));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
DM_TEST(dm_test_tag_ptr, 0);
|
||||
|
||||
/*
|
||||
* Test dm_tag_val() API
|
||||
*/
|
||||
static int dm_test_tag_val(struct unit_test_state *uts)
|
||||
{
|
||||
ulong val1 = 0x12345678, val2 = 0;
|
||||
|
||||
ut_assertok(dev_tag_set_val(uts->root, DM_TAG_EFI, val1));
|
||||
|
||||
ut_assertok(dev_tag_get_val(uts->root, DM_TAG_EFI, &val2));
|
||||
|
||||
ut_asserteq_64(val1, val2);
|
||||
|
||||
ut_assertok(dev_tag_del(uts->root, DM_TAG_EFI));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
DM_TEST(dm_test_tag_val, 0);
|
||||
|
||||
/*
|
||||
* Test against an invalid tag
|
||||
*/
|
||||
static int dm_test_tag_inval(struct unit_test_state *uts)
|
||||
{
|
||||
ulong val;
|
||||
|
||||
ut_asserteq(-EINVAL, dev_tag_set_ptr(uts->root, DM_TAG_COUNT, &val));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
DM_TEST(dm_test_tag_inval, 0);
|
||||
|
||||
/*
|
||||
* Test dm_tag_del_all() AP:
|
||||
*/
|
||||
static int dm_test_tag_del_all(struct unit_test_state *uts)
|
||||
{
|
||||
ulong val;
|
||||
|
||||
ut_assertok(dev_tag_set_ptr(uts->root, DM_TAG_EFI, &val));
|
||||
|
||||
ut_assertok(dev_tag_del_all(uts->root));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
DM_TEST(dm_test_tag_del_all, 0);
|
Loading…
Reference in a new issue