mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-17 10:24:49 +00:00

The UT_TESTF_ macros read as 'unit test test flags' which is not right. Rename to UTF ('unit test flags'). This has the benefit of being shorter, which helps keep UNIT_TEST() declarations on a single line. Give the enum a name and reference it from the UNIT_TEST() macros while we are here. Signed-off-by: Simon Glass <sjg@chromium.org>
48 lines
1.4 KiB
C
48 lines
1.4 KiB
C
// SPDX-License-Identifier: GPL-2.0+
|
|
/*
|
|
* Copyright (c) 2020 Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
|
|
*/
|
|
|
|
#include <dm.h>
|
|
#include <dm/device.h>
|
|
#include <dm/ofnode.h>
|
|
#include <dm/root.h>
|
|
#include <dm/test.h>
|
|
#include <dm/uclass-internal.h>
|
|
#include <test/ut.h>
|
|
|
|
static int dm_test_dma_ranges(struct unit_test_state *uts)
|
|
{
|
|
struct udevice *dev;
|
|
phys_addr_t cpu;
|
|
dma_addr_t bus;
|
|
ofnode node;
|
|
u64 size;
|
|
|
|
/* dma-ranges are on the device's node */
|
|
node = ofnode_path("/mmio-bus@0");
|
|
ut_assert(ofnode_valid(node));
|
|
ut_assertok(uclass_get_device_by_ofnode(UCLASS_TEST_BUS, node, &dev));
|
|
ut_assertok(dev_get_dma_range(dev, &cpu, &bus, &size));
|
|
ut_asserteq_64(0x40000, size);
|
|
ut_asserteq_64(0x0, cpu);
|
|
ut_asserteq_64(0x10000000, bus);
|
|
|
|
/* dma-ranges are on the bus' node */
|
|
node = ofnode_path("/mmio-bus@0/subnode@0");
|
|
ut_assert(ofnode_valid(node));
|
|
ut_assertok(uclass_get_device_by_ofnode(UCLASS_TEST_FDT, node, &dev));
|
|
ut_assertok(dev_get_dma_range(dev, &cpu, &bus, &size));
|
|
ut_asserteq_64(0x40000, size);
|
|
ut_asserteq_64(0x0, cpu);
|
|
ut_asserteq_64(0x10000000, bus);
|
|
|
|
/* No dma-ranges available */
|
|
node = ofnode_path("/mmio-bus@1");
|
|
ut_assert(ofnode_valid(node));
|
|
ut_assertok(uclass_get_device_by_ofnode(UCLASS_TEST_BUS, node, &dev));
|
|
ut_asserteq(-ENOENT, dev_get_dma_range(dev, &cpu, &bus, &size));
|
|
|
|
return 0;
|
|
}
|
|
DM_TEST(dm_test_dma_ranges, UTF_SCAN_PDATA | UTF_SCAN_FDT);
|