aboutsummaryrefslogtreecommitdiff
path: root/tests/tests.h
AgeCommit message (Collapse)AuthorFilesLines
2019-06-21tests: Replace license boilerplate with SPDX tagsRob Herring1-14/+1
Replace instances in tests of mostly LGPL-2.1 license boilerplate with SPDX tags. Signed-off-by: Rob Herring <robh@kernel.org> Message-Id: <20190620211944.9378-5-robh@kernel.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-29libfdt: add fdt_append_addrrange()AKASHI Takahiro1-0/+3
This function will append an address range property using parent node's "#address-cells" and "#size-cells" properties. It will be used in implementing kdump with kexec_file_load system call at linux kernel for arm64 once it is merged into kernel tree. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Message-Id: <20190327061552.17170-2-takahiro.akashi@linaro.org> [dwg: Correct a SEGV error in the testcase] Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-11-24libfdt: Add a test for fdt_getprop_by_offset()Simon Glass1-0/+10
This function does not have its own test at present. Add one. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-06-07tests: Use valgrind client requests for better checkingDavid Gibson1-0/+1
libfdt is never supposed to access memory outside the the blob, or outside the sub-blocks within it, even if the blob is badly corrupted. We can leverage valgrind's client requests to do better testing of this. This adds a vg_prepare_blob() function which marks just the valid parts of an fdt blob as properly initialized, explicitly marking the rest as uninitialized. This means valgrind should catch any bad accesses. We add a call to vg_prepare_blob() to load_blob() so that lots of the existing testcases will benefit from the extra checking. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Tested-by: Alexey Kardashevskiy <aik@ozlabs.ru> Reviewed-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2017-10-26Remove leading underscores from identifiersDavid Gibson1-3/+3
In a number of places, dtc and associated tools and test code use leading _ characters on identifiers to flag them as "internal", an idiom taken from the Linux kernel. This is a bad idea in a userspace program, because identifiers with a leading _ are reserved for the C library / system. In some cases, the extra _ served no real purpose, so simply drop it. In others move to the end of the identifier, which is a convention we're free to use for our own purposes. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-03-06Fix assorted sparse warningsDavid Gibson1-3/+3
This fixes a great many sparse warnings on the fdt and libfdt sources. These are mostly due to incorrect mixing of endian annotated and native integer types. This includes fixing a couple of quasi-bugs where we had endian conversions the wrong way around (this will have the right effect in practice, but is certainly conceptually incorrect). This doesn't make the whole tree sparse clean: there are many warnings in bison and lex generated code, and there are a handful of other remaining warnings that are (for now) more trouble than they're worth to fix (and are not genuine bugs). Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2012-06-03libfdt: Add helpers for 64-bit integer propertiesDavid Gibson1-0/+5
In device trees in the world, properties consisting of a single 64-bit integer are not as common as those consisting of a single 32-bit, cell sized integer, but they're common enough that they're worth including convenience functions for. This patch adds helper wrappers of fdt_setprop_inplace(), fdt_setprop() and fdt_appendprop() for handling 64-bit integer quantities in properties. For better consistency with the names of these new *_u64() functions we also add *_u32() functions as alternative names for the existing *_cell() functions handling 32-bit integers. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2011-09-22Add fdt read/write utility functionsSimon Glass1-16/+2
This adds higher-level libfdt operations for reading/writing an fdt blob from/to a file, as well as a function to decode a data type string as will be used by fdtget, fdtput. This also adds a few tests for the simple type argument supported by utilfdt_decode_type. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: David Gibson <david@gibson.dropbear.id.au>
2009-02-03dtc: Add testcases for labels within valuesDavid Gibson1-0/+1
This patch adds a testcase using asm output mode to check that labels within property values are correctly processed. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-11-20libfdt: Abolish _typed() variants, add _cell() variantsDavid Gibson1-4/+4
In a number of places through libfdt and its tests, we have *_typed() macro variants on functions which use gcc's typeof and statement expression extensions to allow passing literals where the underlying function takes a buffer and size. These seemed like a good idea at the time, but in fact they have some problems. They use typeof and statement expressions, extensions I'd prefer to avoid for portability. Plus, they have potential gotchas - although they'll deal with the size of the thing passed, they won't deal with other representation issues (like endianness) and results could be very strange if the type of the expression passed isn't what you think it is. In fact, the only users of these _typed() macros were when the value passed is a single cell (32-bit integer). Therefore, this patch removes all these _typed() macros and replaces them with explicit _cell() variants which handle a single 32-bit integer, and which also perform endian convesions as appropriate. With this in place, it now becomes easy to use standardized big-endian representation for integer valued properties in the testcases, regardless of the platform we're running on. We therefore do that, which has the additional advantage that all the example trees created during a test run are now byte-for-byte identical regardless of platform. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-11-01libfdt: Handle v16 and re-ordered trees for r/wDavid Gibson1-0/+1
Currently all the read/write functions in libfdt require that the given tree be v17, and further, that the tree has the memory reservation block, structure block and strings block stored in that physical order. This patch eases these constraints, by making fdt_open_int() reorder the blocks, and/or convert the tree to v17, so that it will then be ready for the other read-write functions. It also extends fdt_pack() to actually remove any gaps between blocks that might be present. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-10-24libfdt: Rename and publish _fdt_next_tag()David Gibson1-1/+1
Although it's a low-level function that shouldn't normally be needed, there are circumstances where it's useful for users of libfdt to use the _fdt_next_tag() function. Therefore, this patch renames it to fdt_next_tag() and publishes it in libfdt.h. In addition, this patch adds a new testcase using fdt_next_tag(), dtbs_equal_ordered. This testcase tests for structural equality of two dtbs, including the order of properties and subnodes, but ignoring NOP tags, the order of the dtb sections and the layout of strings in the strings block. This will be useful for testing other dtc functionality in the future. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-10-15libfdt: Add functions to get/add/delete memory reservemap entriesDavid Gibson1-0/+2
This patch adds functions to libfdt for accessing the memory reservation map section of a device tree blob. fdt_num_mem_rsv() retreives the number of reservation entries in a dtb, and fdt_get_mem_rsv() retreives a specific reservation entry. fdt_add_mem_rsv() adds a new entry, and fdt_del_mem_rsv() removes a specific numbered entry. Testcases for these new functions are also included. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-10-15libfdt: Make unit address optional for finding nodesDavid Gibson1-0/+1
At present, the fdt_subnode_offset() and fdt_path_offset() functions in libfdt require the exact name of the nodes in question be passed, including unit address. This is contrary to traditional OF-like finddevice() behaviour, which allows the unit address to be omitted (which is useful when the device name is unambiguous without the address). This patch introduces similar behaviour to fdt_subnode_offset_namelen(), and hence to fdt_subnode_offset() and fdt_path_offset() which are implemented in terms of the former. The unit address can be omitted from the given node name. If this is ambiguous, the first such node in the flattened tree will be selected (this behaviour is consistent with IEEE1275 which specifies only that an arbitrary node matching the given information be selected). This very small change is then followed by many more diffs which change the test examples and testcases to exercise this behaviour. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-06-14Merge libfdt into dtc.David Gibson1-0/+133
Having pulled the libfdt repository into dtc, merge the makefiles and testsuites so that they build together usefully.