mirror of
https://github.com/dgibson/dtc.git
synced 2026-07-10 13:29:48 -04:00
tests: Dont have test cases link directly against example dtb data
Several tests (truncated_property, truncated_string, truncated_memrsv and unterminated_memrsv), rather than loading their example dtb from a file, instead link directly to trees.o and get the data from directly in their own data segment. This was a clever trick once, but it's kind of awkward, and makes it harder to generalise how we generate those trees. Change them to load their example data from file, like most of the tests already do. Assisted-by: Claude:claude-opus-4-6 Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
parent
9b53b9a4c2
commit
f116f4800e
7 changed files with 18 additions and 29 deletions
|
|
@ -29,20 +29,17 @@ LIB_TESTS_L = get_mem_rsv \
|
|||
subnode_iterate \
|
||||
overlay overlay_bad_fixup \
|
||||
check_path check_header check_full \
|
||||
fs_tree1
|
||||
LIB_TESTS = $(LIB_TESTS_L:%=$(TESTS_PREFIX)%)
|
||||
|
||||
LIBTREE_TESTS_L = truncated_property truncated_string \
|
||||
fs_tree1 \
|
||||
truncated_property truncated_string \
|
||||
truncated_memrsv unterminated_memrsv
|
||||
|
||||
LIBTREE_TESTS = $(LIBTREE_TESTS_L:%=$(TESTS_PREFIX)%)
|
||||
LIB_TESTS = $(LIB_TESTS_L:%=$(TESTS_PREFIX)%)
|
||||
|
||||
ifneq ($(STATIC_BUILD),1)
|
||||
DL_LIB_TESTS_L = asm_tree_dump value-labels
|
||||
DL_LIB_TESTS = $(DL_LIB_TESTS_L:%=$(TESTS_PREFIX)%)
|
||||
endif
|
||||
|
||||
TESTS = $(LIB_TESTS) $(LIBTREE_TESTS) $(DL_LIB_TESTS)
|
||||
TESTS = $(LIB_TESTS) $(DL_LIB_TESTS)
|
||||
|
||||
TESTS_TREES_L = test_tree1.dtb bad_node_char.dtb bad_node_format.dtb \
|
||||
bad_prop_char.dtb ovf_size_strings.dtb truncated_property.dtb \
|
||||
|
|
@ -74,9 +71,6 @@ $(DL_LIB_TESTS): %: %.o $(TESTS_PREFIX)testutils.o util.o $(LIBFDT_dep)
|
|||
@$(VECHO) LD [libdl] $@
|
||||
$(LINK.c) -o $@ $^ $(LIBDL)
|
||||
|
||||
$(LIBTREE_TESTS): %: $(TESTS_PREFIX)testutils.o $(TESTS_PREFIX)trees.o \
|
||||
util.o $(LIBFDT_dep)
|
||||
|
||||
$(TESTS_PREFIX)dumptrees: $(TESTS_PREFIX)trees.o
|
||||
|
||||
$(TESTS_TREES): $(TESTS_PREFIX)dumptrees
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ dumptrees_dtb = custom_target(
|
|||
]
|
||||
)
|
||||
|
||||
testutil_dep = declare_dependency(sources: ['testutils.c'], link_with: trees)
|
||||
testutil_dep = declare_dependency(sources: ['testutils.c'])
|
||||
|
||||
tests = [
|
||||
'add_subnode_with_nops',
|
||||
|
|
@ -90,14 +90,11 @@ tests = [
|
|||
'supernode_atdepth_offset',
|
||||
'sw_states',
|
||||
'sw_tree1',
|
||||
'utilfdt_test',
|
||||
]
|
||||
|
||||
tests += [
|
||||
'truncated_memrsv',
|
||||
'truncated_property',
|
||||
'truncated_string',
|
||||
'unterminated_memrsv',
|
||||
'utilfdt_test',
|
||||
]
|
||||
|
||||
test_deps = [testutil_dep, util_dep, libfdt_dep]
|
||||
|
|
|
|||
|
|
@ -492,10 +492,10 @@ libfdt_tests () {
|
|||
run_test appendprop_addrrange unit-addr-without-reg.dtb 2 1 3
|
||||
|
||||
# Tests for behaviour on various sorts of corrupted trees
|
||||
run_test truncated_property
|
||||
run_test truncated_string
|
||||
run_test truncated_memrsv
|
||||
run_test unterminated_memrsv
|
||||
run_test truncated_property truncated_property.dtb
|
||||
run_test truncated_string truncated_string.dtb
|
||||
run_test truncated_memrsv truncated_memrsv.dtb
|
||||
run_test unterminated_memrsv unterminated_memrsv.dtb
|
||||
|
||||
# Check aliases support in fdt_path_offset
|
||||
run_dtc_test -I dts -O dtb -o aliases.dtb "$SRCDIR/aliases.dts"
|
||||
|
|
|
|||
|
|
@ -19,12 +19,13 @@
|
|||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
void *fdt = &truncated_memrsv;
|
||||
void *fdt;
|
||||
void *buf;
|
||||
int err;
|
||||
uint64_t addr, size;
|
||||
|
||||
test_init(argc, argv);
|
||||
fdt = load_blob_arg(argc, argv);
|
||||
|
||||
err = fdt_check_header(fdt);
|
||||
if (err != 0)
|
||||
|
|
|
|||
|
|
@ -13,17 +13,15 @@
|
|||
#include <libfdt.h>
|
||||
|
||||
#include "tests.h"
|
||||
#include "testdata.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
void *fdt = &truncated_property;
|
||||
void *fdt;
|
||||
const void *prop;
|
||||
int len;
|
||||
|
||||
test_init(argc, argv);
|
||||
|
||||
vg_prepare_blob(fdt, fdt_totalsize(fdt));
|
||||
fdt = load_blob_arg(argc, argv);
|
||||
|
||||
prop = fdt_getprop(fdt, 0, "truncated", &len);
|
||||
if (prop)
|
||||
|
|
|
|||
|
|
@ -13,18 +13,16 @@
|
|||
#include <libfdt.h>
|
||||
|
||||
#include "tests.h"
|
||||
#include "testdata.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
void *fdt = &truncated_string;
|
||||
void *fdt;
|
||||
const struct fdt_property *good, *bad;
|
||||
int off, len;
|
||||
const char *name;
|
||||
|
||||
test_init(argc, argv);
|
||||
|
||||
vg_prepare_blob(fdt, fdt_totalsize(fdt));
|
||||
fdt = load_blob_arg(argc, argv);
|
||||
|
||||
off = fdt_first_property_offset(fdt, 0);
|
||||
good = fdt_get_property_by_offset(fdt, off, NULL);
|
||||
|
|
|
|||
|
|
@ -22,12 +22,13 @@
|
|||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
void *fdt = &unterminated_memrsv;
|
||||
void *fdt;
|
||||
void *buf;
|
||||
int err;
|
||||
uint64_t addr, size;
|
||||
|
||||
test_init(argc, argv);
|
||||
fdt = load_blob_arg(argc, argv);
|
||||
|
||||
err = fdt_check_header(fdt);
|
||||
if (err != 0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue