History log of /external/dtc/tests/run_tests.sh
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
3b9c97093d6e1067f4d24d2bff32f3dd24e0751e 30-Jan-2017 Stephen Boyd <stephen.boyd@linaro.org> dtc: Fix NULL pointer use in dtlabel + dtref case

If we have a construct like this:

label: &handle {
...
};

Running dtc on it will cause a segfault, because we use 'target'
when it could be NULL. Move the add_label() call into the if
statement to fix this potentially bad use of a NULL pointer.

Signed-off-by: Stephen Boyd <stephen.boyd@linaro.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
e3c769aa9c16e7b94051c5eaae6635e79ac19385 09-Dec-2016 David Gibson <david@gibson.dropbear.id.au> dtc: Don't always generate __symbols__ for plugins

At the moment we generate a __symbols__ node if -@ is specified OR if the
dts has the /plugin/ tag. That difference in behaviour from handling base
trees is unnecessary and slightly confusing. It also means it's impossible
to create a plugin without symbols. Since symbols in a plugin are only
useful in the case of stacked plugins - and libfdt doesn't even support
merging plugin symbols as part of overlay application yet - that's a thing
that might be useful.

So make __symbols__ generation depend only on -@. We also remove remove
the testcases that checked explicitly for this not very useful behaviour.
Instead we don't use -@ for our basic overlay testcase, and check that
symbols are not generated.

At some point in the future we should add support for symbol merging to
libfdt and add testcases for stacked overlay application.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
c96cb3c0169ed01bef684b49092b5b6cfab5054d 09-Dec-2016 David Gibson <david@gibson.dropbear.id.au> tests: Don't use -@ on plugin de/recompile tests

Using -@ again here obscures what's going on, because at the end we can't
know which run actually generated the symbols node. We should just
generate the symbols on the first run and leave it at that.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
66381538ce24d7ca275edaf00303e09b653b3a4b 09-Dec-2016 David Gibson <david@gibson.dropbear.id.au> tests: Remove "suppression of fixups" tests

I think these were for an additional command line option which got dropped
during development. At this point all they're testing is that fixups don't
get generated for a non /plugin/ tree, which is already tested with one of
the simpler cases previously.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
ba765b273f0f89dd0a2ffb74b96f08d117ce2915 09-Dec-2016 David Gibson <david@gibson.dropbear.id.au> tests: Clarify dtc overlay tests

This changes the names of the testfiles for a number of the testcases of
the dtc overlay generation functionality to make them shorter and a bit
cleaerer what's going on. In addition we move some of the check_path
sanity checks closer to the dtc commands they verify.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
6ea8cd944fcd09dfbda672c6bf6205ec8a5fc152 09-Dec-2016 David Gibson <david@gibson.dropbear.id.au> tests: More thorough tests of libfdt overlay application without dtc

At the moment we have some rudimentary tests of the fdt_overlay_apply()
function which don't rely on overlay generation support in dtc. This is
done by avoiding any external references in the sample overlay, in
particularly using the 'target-path' syntax instead of 'target' to avoid
needing external references in the fragment targets. Thus this test case
doesn't exercise libfdt's processing of the __fixups__ node at all.

We do test that somewhat in combination with dtc's overlay support.
However, in the interests of being able to quickly determine which side a
bug is on, it would be nice to exercise this without requiring the dtc
support.

This adds testcases to do so, by making some examples with manually
constructed __symbols__ and __fixups__ nodes. In addition we rename some
of the test data files and add some extra check_path tests to make it a bit
clearer what's going on here.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
3ea879dc0c8f86e57cac0ab8768aaa08b00940ea 09-Dec-2016 David Gibson <david@gibson.dropbear.id.au> tests: Split overlay tests into those with do/don't exercise dtc plugin generation

The various tests for overlay/plugin support are currently lumped together
in the overlay_tests shell function, which is executed by libfdt_tests.

However, this includes both tests designed primarily to exercise libfdt's
overlay application, and tests designed to exercise dtc's overlay
generation. Split these up for improved clarity.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
47b4d66a2f116208493d37f8232bb55abacd803e 09-Dec-2016 David Gibson <david@gibson.dropbear.id.au> tests: Test auto-alias generation on base tree, not overlay

The current testcases for the -A "auto alias generation" option operate on
a "plugin" tree. Although not technically wrong, this is an odd approach,
since a plugin will almost certainly need the __symbols__ and/or __fixups__
syntax instead of aliases. On the other hand -A may be useful simply for
generating aliases on a tree which is not using the overlay / plugin
mechanism at all.

Therefore change the tests to operate on a base tree example instead of a
plugin.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
72e1ad81152372f444133cca3686da1cf436ebbc 09-Dec-2016 David Gibson <david@gibson.dropbear.id.au> tests: Make overlay/plugin tests unconditional

When overlay apply supprt was added to libfdt the testcases included some
which could only be executed with the (then) out of tree dtc with overlay
output support. So, the test script automatically skipped those tests if
it wasn't available.

Now that the overlay support is merged into dtc mainline there's no reason
to keep this logic. Instead run all the overlay tests unconditionally.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
e7b3c3b5951b606cfbbb3d680cc7566b6d3badbb 07-Dec-2016 Pantelis Antoniou <pantelis.antoniou@konsulko.com> tests: Add overlay tests

Add a number of tests for dynamic objects/overlays.

Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
9637e3f772a944d28ab5b039f110763a25665fd6 07-Dec-2016 Pantelis Antoniou <pantelis.antoniou@konsulko.com> tests: Add check_path test

Add a test that checks for existence or not of a node.
It is useful for testing the various cases when generating
symbols and fixups for dynamic device tree objects.

Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
ae97c7722840148b636ac8fde2de3d0a24c04cfc 11-Oct-2016 Maxime Ripard <maxime.ripard@free-electrons.com> tests: overlay: Rename the device tree blobs to be more explicit

Rename the blobs to have a more explicit output that will give us a clearer
idea about whether a DT (and the test) has been compiled using a dtc with
our without overlays support.

Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
96162d2bd9cbea74c57a523b3145b8abbfd32c8d 11-Oct-2016 Maxime Ripard <maxime.ripard@free-electrons.com> tests: overlay: Add test suffix to the compiled blobs

The compiled blobs in the overlay tests do not have the test suffix which
is usually used to clean up and ignore the test artifacts.

Let's add that suffix.

Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
e8c3a1a493fa96153badd4b8a831edfb96d5bdc7 06-Oct-2016 Maxime Ripard <maxime.ripard@free-electrons.com> tests: overlay: Move back the bad fixup tests

The bad fixups tests were meant to be usable even for a non-overlay-enabled
dtc.

Move them out of that check.

Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
aea8860d831ed05a147a1896c15e1312a9a66917 30-Sep-2016 Maxime Ripard <maxime.ripard@free-electrons.com> tests: Add tests cases for the overlay code

Add some test infrastructure to test that the overlay can be merged, but
also that poorly formatted fixups would fail as expected.

Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
[dwg: Don't execute bad overlay tests without overlay aware dtc]
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
a34bb721caca10964cb7d22b9d9322b0424c9042 22-Sep-2016 David Gibson <david@gibson.dropbear.id.au> dtc: Fix assorted problems in the testcases for the -a option

We just added the -a option to allow padding of the output dtb's size to
a specified alignment. Unfortunately the test cases for this had several
bugs:
* Didn't actually test anything since "alignbase" instead of $alignbase
was passed to the checker function
* Introduced an unnecessary run_local_test wrapper
* Didn't provide very helpful output on failure
* Only attempted to check one alignment value

This patch fixes up these problems.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
874f40588d3eb7e406521117c6e24d5a3376a77e 18-Jul-2016 Tim Wang <timwang@asrmicro.com> Implement the -a option to pad dtb aligned

There is one condition that need cat the dtb files
into one dtb.img which can support several boards
use same SoC platform.

And the original dtb file size is not aligned to any base.
This may cause "Synchronous Abort" when load from a unligned
address on some SoC machine, such as ARM.

So this patch implement the -a <aligned number> option to
pad zero at the end of dtb files and make the dtb size aligned
to <aligned number>.

Then, the aligned dtbs can cat together and load without "Synchronous
Abort".

Signed-off-by: Tim Wang <timwang@asrmicro.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
d29126c90acb0d705d695b2be07162f38ee48d69 27-Jul-2016 Maxime Ripard <maxime.ripard@free-electrons.com> libfdt: Add iterator over properties

Implement a macro based on fdt_first_property_offset and
fdt_next_property_offset that provides a convenience to iterate over all
the properties of a given node.

Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Acked-by: Simon Glass <sjg@chromium.org>
[dwg: Removed a stray trailing blank line]
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
c9d9121683b35281239305e15adddfff2b462cf9 19-Feb-2016 Stephen Warren <swarren@nvidia.com> Warn on node name unit-address presence/absence mismatch

ePAPR 1.1 section 2.2.1.1 "Node Name Requirements" specifies that any
node that has a reg property must include a unit address in its name
with value matching the first entry in its reg property. Conversely, if
a node does not have a reg property, the node name must not include a
unit address. Also allow ranges property as it is deemed valid, but ePAPR
is not clear about it.

Implement a check for this. The code doesn't validate the format of the
unit address; ePAPR implies this may vary from (containing bus) binding
to binding, so doing so would be much more complex.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
[robh: also allow non-empty ranges]
Signed-off-by: Rob Herring <robh@kernel.org>
[moved new test in check_table]
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
2e53f9d2f0a8faab6cec0d78958d52c155f6c6eb 02-Jan-2016 Anton Blanchard <anton@samba.org> Catch unsigned 32bit overflow when parsing flattened device tree offsets

We have a couple of checks of the form:

if (offset+size > totalsize)
die();

We need to check that offset+size doesn't overflow, otherwise the check
will pass, and we may access past totalsize.

Found with AFL.

Signed-off-by: Anton Blanchard <anton@samba.org>
[Added a testcase]
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
b43345039b03ac5691961e1ce37dfb8c4c03a863 04-Jan-2016 David Gibson <david@gibson.dropbear.id.au> Fix some bugs in processing of line directives

In order to work with preprocessed dts files more easily, dts will parse
line number information in the form emitted by cpp.

Anton Blanchard (using a fuzzer) reported that including a line number
directive with a nul character (a literal nul in the input file, not a \0
sequence) would cause dtc to SEGV. I spotted several more problems on
examining the code:
* It modified yytext in place which seems to work, but is ugly and I'm
not sure if it's safe on all lex/flex versions
* The regexp used in the lexer to recognize line number information
accepts strings with escape characters, but it won't process these
escapes.
- GNU cpp at least, will generate \ escapes in line number
information, at least with files containing " or \ in the name

This patch reworks the handling of line number information to address
these problems. \ escapes should now be handled directly. nuls in file
names (either with a literal nul in the input file, or with a \0 escape
sequence) are still not permitted, but will now result in a lexical error
rather than a SEGV.

Reported-by: Anton Blanchard <anton@samba.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
d728ad59f53e72be21fe9bc419953c94aea798cc 03-Jan-2016 David Gibson <david@gibson.dropbear.id.au> Fix crash on nul character in string escape sequence

If a dts file contains a string with \ followed by a nul byte - an actual
nul in the input file, not the \\0 escape - then the assert() in
get_escape_char() will trip, crashing dtc.

As far as I can tell, there isn't any valid need for this assert(), so just
remove it.

Reported-by: Anton Blanchard <anton@samba.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
1ab2205a6f0f9e826a623e639da02787d372de37 03-Jan-2016 David Gibson <david@gibson.dropbear.id.au> Gracefully handle bad octal literals

The code handling integer literals in dtc-lexer.l assumes that the flex
regexp means that strtoull() can't fail to interpret the string as a valid
integer (either decimal, octal, or hexadecimal). This is not true for
octals. For example '09' is accepted as a literal by the regexp,
strtoull() attempts to handle it as octal, but it has a bad digit.

This changes the code to give a more useful error in this case.

Reported-by: Anton Blanchard <anton@samba.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
19370955884ff0c49328956227c302225f4a014b 03-Jan-2016 David Gibson <david@gibson.dropbear.id.au> Prevent crash on division by zero

Currently, attempting to divide by zero in an integer expression in a dts
file will cause dtc to crash with a division by zero (SIGFPE).

This patch corrects this to properly detect this case and raise an error.

Reported-by: Anton Blanchard <anton@samba.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
2218387a8cb9270a688775350a07b02db6d03103 30-Sep-2015 Thierry Reding <treding@nvidia.com> fdt: Add a function to count strings

Given a device tree node and a property name, the fdt_stringlist_count()
function counts the number of strings found in the property value.

This also adds a new error code, FDT_ERR_BADVALUE, that the function
returns when it encounters a non-NUL-terminated string list.

Signed-off-by: Thierry Reding <treding@nvidia.com>
[Changed testcase name --dwg]
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
067829ea5fa9a6d22d4d09fa38ffbef16d21de78 09-Jul-2015 David Gibson <david@gibson.dropbear.id.au> Remove redundant fdtdump test code

The overall test runner script, for the fdtdump tests invokes the helper
script fdtdump-runtest.sh. It then includes directly some code very
similar to fdtdump-runtest.sh, which is never reached due to a "return".

Remove the never-reached test code.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
897a429199da12eb8b071a497ffd02538ada26b5 09-Jul-2015 David Gibson <david@gibson.dropbear.id.au> Move fdt_path_offset alias tests to right tests section

The test script includes several specific tests for the handling of aliases
in fdt_path_offset(). These are primarily tests of the fdt_path_offset()
libfdt function itself, although dtc is used to generate a test file for
convenience.

Move these from the dtc tests section to the libfdt tests section
accordingly.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
8b927bf3b80de4b0a49e6b6e4a56293e9baec364 25-May-2015 Mike Frysinger <vapier@chromium.org> tests: convert `echo -n` to `printf`

The -n option is not standard in POSIX, so convert to printf which should
work the same in every shell.

Signed-off-by: Mike Frysinger <vapier@chromium.org>
/external/dtc/tests/run_tests.sh
64c46b098b969502a74c8b0fd97e6f5e4aa07e21 29-Apr-2015 Jack Miller <jack@codezen.org> Fix crash with poorly defined #size-cells

If you have a parent block with #size-cells improperly set to 0, and
then subsequently try to include a regs property in the child, dtc will
crash with SIGFPE while validating it. This patch fixes that crash,
instead printing the same invalid length warning that was causing it.

Test included.

Signed-off-by: Jack Miller <jack@codezen.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
3346e065aacb1f05bdfb3872e3ba709b5f895846 22-Feb-2015 Nikhil Devshatwar <nikhil.nd@ti.com> dtc: parser: Add label while overriding nodes

This patch changes the dtc grammar to allow following syntax

i2cexp: &i2c2 {
...
};

Current device tree compiler allows to define multiple labels when defining
the device node the first time. Typically device nodes are defined in
DTSI files. Now these nodes can be overwritten for updating some of the
properties. Typically, device nodes are overridden in DTS files.

When working with adapter boards, most of the time adapter board can fit to
multiple base boards. But depending on which base board it is connected to,
the devices on the adapter board would be children of different devices.

e.g. On dra7-evm.dts, i2c2 is exported for expansion connector whereas
on dra72-evm.dts, i2c5 is exported for expansion connector.
This causes a problem when writing a generic device tree file for
the adapter board. Because, you cannot know whether all the devices on
adapter board are present on i2c or i2c5.

The problem can be solved by adding a common label (e.g. i2cexp) in both
of the DTS files when overriding the device nodes for i2c2 or i2c5.
This way, generic adapter board file would override the i2cexp. And
depending on which base board you use the adapter board, all the devices
are automatically added for correct device nodes.

Signed-off-by: Nikhil Devshatwar <nikhil.nd@ti.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
aa719618a8b7c748be659717a9fd003bfa186017 23-Jan-2015 Wang Long <long.wanglong@huawei.com> fdtput: add delete node and property function

add the delete node and property function for fdtput.

usage:
1) delete nodes
fdtput -r <options> <dt file> [<node>...]
2) delete properties
fdtput -d <options> <dt file> <node> [<property>...]

Signed-off-by: Wang Long <long.wanglong@huawei.com>
/external/dtc/tests/run_tests.sh
5d4a8b9c4c5145bd509bff20780270e00547c80a 06-Aug-2014 Jack Miller <jack@codezen.org> Properly handle embedded nul delimited string lists

For example:

reserved-names="res1\0res2\0res3";

Where \0 is an actual embedded NUL in the source instead of a string
escape. To achieve this, use the len given by the lexer instead of
strlen.

Without this patch dtc will mangle the output and possibly hang on
realloc.
/external/dtc/tests/run_tests.sh
fa928fba7e1ce94aef58798e77a9261192fdbb01 18-Jun-2014 David Gibson <david@gibson.dropbear.id.au> Fix an off-by-2 error in the source output code

This has been there for ages, but the assertion makes no sense in the
context of the test immediately preceding it. This caused an abort()
when in -I dts -O dts mode with the right sort of internal labels in a
string property value.

Add a testcase for this and another candidate edge case (though this one
we already get right).

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
76a65b14d1bb10f300f518c11aed231575521c2e 18-Jun-2014 Simon Glass <sjg@chromium.org> Add a basic test for fdtdump

We can test fdtdump by comparing its output with the source file that was
compiled by dtc. Add a simple test that should at least catch regressions
in basic functionality.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
40f7f576c8e7df395ed25f0f3df61fac85f1adf9 11-May-2014 David Gibson <david@gibson.dropbear.id.au> libfdt: Add helpers to read #address-cells and #size-cells

This patch makes a small start on libfdt functions which actually help to
parse the contents of device trees, rather than purely manipulating the
tree's structure.

We add simple helpers to read and sanity check the #address-cells and
#size-cells values for a given node.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
edb10bcf1cd5be7251fc87ed5fc622f620008ceb 30-Dec-2013 David Gibson <david@gibson.dropbear.id.au> Add option to run_tests.sh to stop immediately on a failing test

This is a debugging convenience option, which makes it much easier to find
the failing tests and fix them one by one.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
79eebb23dbf1f6eeff1789cd0d6f1c1fe620a487 25-Oct-2013 David Gibson <david@gibson.dropbear.id.au> libfdt: Add function to resize the buffer for a sequential write tree

At present, when using sequential write mode, there's no straightforward
means of resizing the buffer the fdt is being built into. This patch
adds an fdt_resize() function for this purpose.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
d214655904b49938dafcb83797de3f6a0dc725c8 28-May-2013 Srinivas Kandagatla <srinivas.kandagatla@st.com> fdtput: expand fdt if value does not fit

If you try to insert a new node or extend a property with large value,
using fdtput you will notice that it always fails.

example:
fdtput -v -p -ts ./tst.dtb "/node-1" "property-1" "value-1
Error at 'node-1': FDT_ERR_NOSPACE

or

fdtput -v -c ./tst.dtb "/node-1"
Error at 'node-1': FDT_ERR_NOSPACE

or

fdtput -v -ts ./tst.dtb "/node" "property" "very big value"
Decoding value:
string: 'very big value'
Value size 15
Error at 'property': FDT_ERR_NOSPACE

All these error are returned from libfdt, as the size of the fdt passed
has no space to accomdate these new properties.
This patch adds realloc functions in fdtput to allocate new space in fdt
when it detects a shortage in space for new value or node. With this
patch, fdtput can insert a new node or property or extend a property
with new value greater than original size. Also it packs the final blob
to clean up any extra padding.

Without this patch fdtput tool complains with FDT_ERR_NOSPACE when we
try to add a node/property or extend the value of a property.

Testcases for the new behaviour added by David Gibson.

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@st.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
a58afe2eb28645641367f4eacdea2c124d291f6e 28-May-2013 David Gibson <david@gibson.dropbear.id.au> Remove some tests for misfeatures

There are a couple of fdtput related tests which are rather pointless -
they explicitly test for the presence of an undesirable limitation in
fdtput, which will cause test failures when we fix it. This patch removes
the tests.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
1c76ec3c090f230fa8a45a5ef84bda600fc4d064 28-May-2013 David Gibson <david@gibson.dropbear.id.au> Use shorten_echo for wrap_tests

We have certain tests which generate extremely long command lines, which
are shortened in the testsuite output with the 'shorten_echo' function.
Currently that is used in run_fdtput_test and run_wrap_test, this patch
uses it for run_wrap_test as well, allowing more general tests with long
command lines.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
4e76ec796c90d44d417f82d9db2d67cfe575f8ed 26-Apr-2013 Simon Glass <sjg@chromium.org> libfdt: Add fdt_next_subnode() to permit easy subnode iteration

Iterating through subnodes with libfdt is a little painful to write as we
need something like this:

for (depth = 0, count = 0,
offset = fdt_next_node(fdt, parent_offset, &depth);
(offset >= 0) && (depth > 0);
offset = fdt_next_node(fdt, offset, &depth)) {
if (depth == 1) {
/* code body */
}
}

Using fdt_next_subnode() we can instead write this, which is shorter and
easier to get right:

for (offset = fdt_first_subnode(fdt, parent_offset);
offset >= 0;
offset = fdt_next_subnode(fdt, offset)) {
/* code body */
}

Also, it doesn't require two levels of indentation for the loop body.

Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
8055d77a5be3a4204b3aa5cd73ce5cc03362e193 27-Jan-2013 Simon Glass <sjg@chromium.org> Adjust util_is_printable_string() comment and fix test

This commit which changed the behaviour of this function broke one
of the tests. Also the comment should be updated to reflect its new
behaviour.

Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
1762ab42ef77db7ab2776d0d6cba3515150f518a 05-Oct-2012 Stephen Warren <swarren@nvidia.com> dtc: fix for_each_*() to skip first object if deleted

The previous definition of for_each_*() would always include the very
first object within the list, irrespective of whether it was marked
deleted, since the deleted flag was not checked on the first object,
but only on any "next" object.

Fix for_each_*() to check the deleted flag in the loop body every
iteration to correct this.

Incidentally, this change is why commit 45013d8 dtc: "Add ability to
delete nodes and properties" only caused two "make checkm" failures;
only two tests actually use multiple labels on the same property or
node. With this current change applied, but commit 317a5d9 "dtc: zero
out new label objects" reverted, "make checkm" fails 29 times; i.e.
for every test that uses any labels at all.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
1b6d1941dc5b589632c254ee6e960404d7cef5f2 28-Sep-2012 Stephen Warren <swarren@nvidia.com> dtc: cpp co-existence: add support for #line directives

Line control directives of the following formats are supported:
#line LINE "FILE"
# LINE "FILE" [FLAGS]

This allows dtc to consume the output of pre-processors, and to provide
error messages that refer to the original filename, including taking
into account any #include directives that the pre-processor may have
performed.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
1ff3d3f8de701ed107e908030b5c1fed9d17125a 28-Sep-2012 Stephen Warren <swarren@nvidia.com> dtc: cpp co-existence: allow names starting with # to be escaped

The device tree language as currently defined conflicts with the C pre-
processor in one aspect - when a property or node name begins with a #
character, a pre-processor would attempt to interpret it as a directive,
fail, and most likely error out.

This change allows a property/node name to be prefixed with \. This
prevents a pre-processor from seeing # as the first non-whitespace
character on the line, and hence prevents the conflict. \ was previously
an illegal character in property/node names, so this change is
backwards compatible. The \ is stripped from the name during parsing
by dtc.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
45013d86197fea96810a7ae1b920d22b4c887688 08-Aug-2012 Stephen Warren <swarren@nvidia.com> dtc: Add ability to delete nodes and properties

dtc currently allows the contents of properties to be changed, and the
contents of nodes to be added to. There are situations where removing
properties or nodes may be useful. This change implements the following
syntax to do that:

/ {
/delete-property/ propname;
/delete-node/ nodename;
};

or:

/delete-node/ &noderef;

Signed-off-by: Stephen Warren <swarren@nvidia.com>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
f807af192828222dee7a5c9f94d999673bb4d8a1 12-Jul-2012 Simon Glass <sjg@chromium.org> fdtput: Add -p option to create subnodes along entire path

This option mimics mkdir's -p option. It automatically creates nodes
as needed along the path provided. If the node already exists, no
error is given.

Signed-off-by: Simon Glass <sjg@chromium.org>
/external/dtc/tests/run_tests.sh
d46c2de5700fd8d43de67ca3709c276beba39b39 12-Jul-2012 Simon Glass <sjg@chromium.org> fdtput: Add -c option to create nodes

This option allows the creation of new nodes in a dtb file. The syntax
is:

fdtput -c <dtb_file> <node_path>

The node_path contains the path of the node to be created. All path
components up to the final one must exist already. The final one must
not exist already.

Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
d5399197e9e0d8bad13de5c41df3b93804c0558a 08-Jul-2012 David Gibson <david@gibson.dropbear.id.au> Allow toggling of semantic checks

This patch adds -W and -E options to dtc which allow toggling on and off
of the various built in semantic checks on the tree.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
f67dfe845930b32ea14df6ff18d69799828a5909 03-Jul-2012 Stephen Warren <swarren@nvidia.com> Add test for re-defining an identical label

When merging one device tree over the top of a previous tree, it is
possible to define a duplicate label that has the same name and points
to the same property or node. This is currently allowed by the duplicate
label checking code. However, alternative duplicate label checking
algorithms might not allow this. Add an explicit test to ensure this
capability is maintained.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
4adbb5336b0eed99f30c852d9dcf3cd125cae921 01-Jun-2012 David Gibson <david@gibson.dropbear.id.au> Remove test_tree1_dts0 testcases

The testcases based on test_tree1_dts0.dts were added purely to test dtc's
backwards compatibility handling of the old dts-v0 format. Since that
support has been removed, the dts has been updated to use the current
dts-v1 syntax, which makes the testcases pass, but be completely useless.

This patch removes the now obsolete testcases.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
5f0c3b2d6235dec65fff1628a97f45e21680b36d 04-Apr-2012 Stephen Warren <swarren@wwwdotorg.org> dtc: Basic integer expressions

Written by David Gibson <david@gibson.dropbear.id.au>. Additions by me:
* Ported to ToT dtc.
* Renamed cell to integer throughout.
* Implemented value range checks.
* Allow U/L/UL/LL/ULL suffix on literals.
* Enabled the commented test.

Signed-off-by: Stephen Warren <swarren@wwwdotorg.org>
/external/dtc/tests/run_tests.sh
de6b76240e91b9288cdce63ab81e51a7232d0927 15-Mar-2012 Simon Glass <sjg@chromium.org> dtc: Add -i option to support search paths

It is often inconvenient to place device tree files in the same directory
as their includes, or to specify the full path to include files.

An example of this is in U-Boot where we have a .dtsi file for each SOC
type, and this is included by the board .dts file. We need to either use
a mechanism like:

/include/ ARCH_CPU_DTS

with sed or cpp to perform the replacement with the correct path, or
we must specify the full path in the file:

/include/ "../../arch/arm/dts/tegra20.dtsi"

The first option is not desirable since it requires anyone compiling the
file to first pre-process it. The second is not desirable since it
introduces a path which is project-specific into a file which is supposed
to be a hardware description. For example Linux and U-Boot are unlikely to
put these include files in the same place.

It is much more convenient to specify the search patch on the command line
as is done with C pre-processors, for example.

Introduce a -i option to add to the list of search paths used to find
source and include files.

We cannot use -I as it is already in use. Other suggestions welcome.

Signed-off-by: Simon Glass <sjg@chromium.org>
/external/dtc/tests/run_tests.sh
7fcbef275741793064268cf0a1bdcd59144a9a10 07-Mar-2012 Simon Glass <sjg@chromium.org> fdtget: Add -d to provide a default value

Sometimes the requested node or property is not present in the device
tree. This option provides a way of reporting a default value in this
case, rather than halting with an error.

Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
097ec97c1a35685957210adb93692c3e210bc82c 03-Mar-2012 Simon Glass <sjg@chromium.org> fdtget: Fix multiple arg bug and add test for it

There is a rather unfortunate bug in fdtget in that if multiple argument
sets are provided, it just repeats displaying the first set ones for
each set.

Fix this bug and add a test for it.

Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
0b3b46e019f546a24927bb7ca009670762c00107 03-Feb-2012 David Gibson <david@gibson.dropbear.id.au> Generate test data for fdtput more sensibly

Currently run_tests.sh generates several files of text test data. The
procedure it uses for this is somewhat torturous and has several problems:
* Since the test data is derived from a dts file, a cursory glance at the
test output suggests something is wrong with the processing of that dts.
This is misleading since in fact it's just being used as an arbirary
string.
* Since the base input has linefeeds removed, the head and sort commands
used later have no effect.
* Although an attempt is made to get rid of characters which the shell
will mangle, it's not thorough enough. Specifically it leaves in \ which
means that some string escapes found in the input data can get expanded
somewhere along the line in some shells.

This patch, therefore, replaces this generation of test data with a
pre-canned "Lorem ipsum" of approximately 2k. On my system, where /bin/sh
is dash, this fixes a test failure due to the aforementioned string
escapes being evaluated on one but not the other of the two comparison
paths (I haven't tracked down exactly where the expansion is happening).

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
15b23d21a62b5a0295ee08b54d0842889ce94c92 03-Feb-2012 David Gibson <david@gibson.dropbear.id.au> Clean up invocation of fdt{get,put} tests

This patch cleans up how the fdtget and fdtput tests are invoked.
Specifically we no longer hide the full command lines with a wrapper
function - this makes it possible to distinguish fdtget from similar
fdtput tests and makes it easier to work out how to manually invoke an
individual failing test.

In addition, we remove the testing for errors from the
fdt{get,put}-runtest.sh script, instead using an internal wrapper
analagous to run_wrap_test which can test for any program invocation
that's expected to return an error.

For a couple of the fdtput tests this would result in printing out
ludicrously large command lines. Therefore we introduce a new
mechanism to cut those down to something reasonable.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
a90b5b149197a8b38bd569c6a8abc9fc0363fa4b 03-Feb-2012 David Gibson <david@gibson.dropbear.id.au> Remove bashism from run_tests.sh

The patches introducing fdtget and fdtput inserted a peculiar bashism to
run_tests.sh using non-portable assignment within an (( )) expression.
This patch fixes it.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
1ede50c3559bbfca79fadcbfd8acb9388f4aac87 21-Jan-2012 Simon Glass <sjg@chromium.org> Add fdtput utility to write property values to a device tree

This simple utility allows writing of values into a device tree from the
command line. It aimes to be the opposite of fdtget.

What is it for:
- Updating fdt values when a binary blob already exists
(even though source may be available it might be easier to use this
utility rather than sed, etc.)
- Writing machine-specific fdt values within a build system

To use it, specify the fdt binary file on command line followed by the node
and property to set. Then, provide a list of values to put into that
property. Often there will be just one, but fdtput also supports arrays and
string lists.

fdtput does not try to guess the type of the property based on looking at
the arguments. Instead it always assumes that an integer is provided. To
indicate that you want to write a string, use -ts. You can also provide
hex values with -tx.

The command line arguments are joined together into a single value. For
strings, a nul terminator is placed between each string when it is packed
into the property. To avoid this, pass the string as a single argument.

Usage:
fdtput <options> <dt file> <<node> <property> [<value>...]
Options:
-t <type> Type of data
-v Verbose: display each value decoded from command line
-h Print this help

<type> s=string, i=int, u=unsigned, x=hex
Optional modifier prefix:
hh or b=byte, h=2 byte, l=4 byte (default)

To read from stdin and write to stdout, use - as the file. So you can do:

cat somefile.dtb | fdtput -ts - /node prop "My string value" > newfile.dtb

This commit also adds basic tests to verify the major features.

Signed-off-by: Simon Glass <sjg@chromium.org>
/external/dtc/tests/run_tests.sh
68d057f20d7c3a93b441d2892c4749392bc83b45 21-Jan-2012 Simon Glass <sjg@chromium.org> Add fdtget utility to read property values from a device tree

This simply utility makes it easy for scripts to read values from the device
tree. It is written in C and uses the same libfdt as the rest of the dtc
package.

What is it for:
- Reading fdt values from scripts
- Extracting fdt information within build systems
- Looking at particular values without having to dump the entire tree

To use it, specify the fdt binary file on command line followed by a list of
node, property pairs. The utility then looks up each node, finds the property
and displays the value.

Each value is printed on a new line.

fdtget tries to guess the type of each property based on its contents. This
is not always reliable, so you can use the -t option to force fdtget to decode
the value as a string, or byte, etc.

To read from stdin, use - as the file.

Usage:
fdtget <options> <dt file> [<node> <property>]...
Options:
-t <type> Type of data
-h Print this help

<type> s=string, i=int, u=unsigned, x=hex
Optional modifier prefix:
hh or b=byte, h=2 byte, l=4 byte (default)

Signed-off-by: Simon Glass <sjg@chromium.org>
/external/dtc/tests/run_tests.sh
69df9f0de25db1c37970850115cdf48335d41802 12-Jan-2012 Stephen Warren <swarren@nvidia.com> dtc: Implement -d option to write out a dependency file

This will allow callers to rebuild .dtb files when any of the /include/d
.dtsi files are modified, not just the top-level .dts file.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
97b909f852039daaae267a66f5df2c90ed05b586 11-Jan-2012 David Gibson <david@gibson.dropbear.id.au> libfdt: Activate testcase for appending properties

Commit a31e3ef83bfce62d07695355e5f06cd4d0e44b86 introduced new libfdt
functions to append to existing properties. It also included a test case
for this, but neglected to update the Makefile and run_tests.sh script
to actually build and execute this testcase.

This patch corrects the oversight.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
033089f29099bdfd5c2d6986cdb9fd07b16cfde0 11-Oct-2011 Anton Staaf <robotboy@chromium.org> dtc: Add support for variable sized elements

Elements of size 8, 16, 32, and 64 bits are supported. The new
/bits/ syntax was selected so as to not pollute the reserved
keyword space with uint8/uint16/... type names.

With this patch the following property assignment:

property = /bits/ 16 <0x1234 0x5678 0x0 0xffff>;

is equivalent to:

property = <0x12345678 0x0000ffff>;

It is now also possible to directly specify a 64 bit literal in a
cell list, also known as an array using:

property = /bits/ 64 <0xdeadbeef00000000>;

It is an error to attempt to store a literal into an element that is
too small to hold the literal, and the compiler will generate an
error when it detects this. For instance:

property = /bits/ 8 <256>;

Will fail to compile. It is also an error to attempt to place a
reference in a non 32-bit element.

The documentation has been changed to reflect that the cell list
is now an array of elements that can be of sizes other than the
default 32-bit cell size.

The sized_cells test tests the creation and access of 8, 16, 32,
and 64-bit sized elements. It also tests that the creation of two
properties, one with 16 bit elements and one with 32 bit elements
result in the same property contents.

Signed-off-by: Anton Staaf <robotboy@chromium.org>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
36204fdf742cabc074617648a5b2cf62409dc40b 22-Sep-2011 Simon Glass <sjg@chromium.org> Add fdt read/write utility functions

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>
/external/dtc/tests/run_tests.sh
a4ea2fa9518ff0f4d7f4a08647599a727faac2e0 09-Sep-2011 Anton Staaf <robotboy@chromium.org> dtc: Support character literals in cell lists

With this patch the following property assignment:

property = <0x12345678 'a' '\r' 100>;

is equivalent to:

property = <0x12345678 0x00000061 0x0000000D 0x00000064>

Signed-off-by: Anton Staaf <robotboy@chromium.org>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
37c0b6a0916c31a5eae0a9ddfcc5d0b8fb4569c6 09-Nov-2010 David Gibson <david@gibson.dropbear.id.au> dtc: Add code to make diffing trees easier

This patch adds a "dtdiff" script to do a useful form diff of two
device trees. This automatically converts the tree to dts form (if
it's not already) and uses a new "-s" option in dtc to "sort" the
tree. That is, it sorts the reserve entries, it sorts the properties
within each node by name, and it sorts nodes by name within their
parent.

This gives a pretty sensible diff between the trees, which will ignore
semantically null internal rearrangements (directly diffing the dts
files can give a lot of noise due to the order changes).

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
73ae43ea44a40c2ac00dd94523f270177a1e72e9 02-Nov-2010 John Bonesio <bones@secretlab.ca> Allow nodes to be referenced by path at the top level.

When nodes are modified by merging device trees, nodes to be updated/merged can
be specified by a label. Specifying nodes by full path (instead of label)
doesn't quite work. This patch fixes that.

Signed-off-by: John Bonesio <bones@secretlab.ca>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
8773e12fa9f5109172a779aa2a83b4464e5273cc 21-Sep-2010 David Gibson <david@gibson.dropbear.id.au> Add merging of labelled subnodes. This patch allows the following

syntax:

/ {
child {
label: subchild {
};
};
};

&label {
prop = "value";
};

which will result in the following tree:

/ {
child {
label: subchild {
prop = "value";
};
};
};

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
/external/dtc/tests/run_tests.sh
390635762d97502bda9c295fcb61b45d04d3d8d2 29-Aug-2010 David Gibson <david@gibson.dropbear.id.au> Remove another bashism from run_tests.sh

Current we check for various error codes with [ $x == "NN" ]. However
'==' is not actually a correct operator for the [ (test) command. It
should be either '=' for string comparison or '-eq' for integer
comparison. It appears that the bash builtin version of test
implements '==' though, so we were getting away with it, as long as
/bin/sh was bash - or the testsuite generated no errors.

This patch fixes the usage of test so that it should work on non-bash
shells.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
e3b32b75b54834bc4d55db22636b6504eabb788e 30-Apr-2010 David Gibson <david@gibson.dropbear.id.au> dtc: Extend and better test dtbs_equal utility programs (resend)

The dtbs_equal_ordered test program is used to implement a number of
testcases. However, the test program itself has never been
particularly well tested. In addition there are testcases coming in
future for which it would be useful to have a corresponding
"dtbs_equal_unordered" which checks for equality of device trees, not
considering the internal ordering of elements. Finally, for some
tests we may want it would be useful to check trees for equality with
the PASS case being when they are *not* equal.

This patch addresses all of the above. A dtbs_equal_unordered is
added, and both it and the existing dtbs_equal_ordered program now
take a -n option to make the PASS case be where the trees are not
equal. A number of example trees with slight modifications from
test_tree1 are used to verify that both these programs correctly
identify when the tree is altered, and a dtb_reverse program is used
to verify that the unordered version does not depend on internal
ordering. These new testcases for the equality testing programs are
split out into a new test group in run_tests.sh.

dtbs_equal_unordered uses the new property iteration functions, and so
this also acts as further testing for those functions.
dtbs_equal_unordered will be useful for further testing the recently
added tree-merging code and its upcoming extensions.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
83da1b2a4ee272ac97647a82fc652d9b4b1505ee 25-Feb-2010 Grant Likely <grant.likely@secretlab.ca> Allow device tree to be modified by additonal device tree sections

This patch allows the following construct:

/ {
property-a = "old";
property-b = "does not change";
};

/ {
property-a = "changed";
property-c = "new";
node-a {
};
};

Where the later device tree overrides the properties found in the
earlier tree. This is useful for laying down a template device tree
in an include file and modifying it for a specific board without having
to clone the entire tree.

Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
/external/dtc/tests/run_tests.sh
05898c67c15d73fe50bd87fc939bd9ee6a4275ce 24-Feb-2010 David Gibson <david@gibson.dropbear.id.au> dtc: Allow multiple labels on nodes and properties

At present, both the grammar and our internal data structures mean
that there can be only one label on a node or property. This is a
fairly arbitrary constraint, given that any number of value labels can
appear at the same point, and that in C you can have any number of
labels on the same statement.

This is pretty much a non-issue now, but it may become important with
some of the extensions that Grant and I have in mind. It's not that
hard to change, so this patch does so, allowing an arbitrary number of
labels on any given node or property. As usual a testcase is added
too.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Acked-by: Grant Likely <grant.likely@secretlab.ca>
/external/dtc/tests/run_tests.sh
49c2da308534a4bffb67d53b5a7f8e5f05c305b9 23-Feb-2010 David Gibson <david@gibson.dropbear.id.au> Remove obsolete references_dts0 test

The only purpose of the dtc_references_dts0 testcase was to check
handling of references in the old dts v0 syntax. Since we no longer
support the old syntax, and the references_dts0.dts has been converted
to the new format, it's entirely redundant. This patch removes it.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
329055dbbc3c09e21386ceae788256991f4c8aec 23-Feb-2010 David Gibson <david@gibson.dropbear.id.au> Disallow re-use of the same label within a dts file

Currently, nothing will stop you from re-using the same label string
multiple times in a dts, e.g.:
/ {
samelabel: prop1 = "foo";
samelabel: prop2 = "bar";
};

or
/ {
samelabel: prop1 = "foo";
samelabel: subnode {
};
};

When using node references by label, this could lead to confusing
results (with no warning), and in -Oasm mode will result in output
which the assembler will complain about (since it too will have
duplicate labels).

This patch, therefore, adds code to checks.c to give errors if you
attempt to re-use the same label. It treats all labels (node,
property, and value) as residing in the same namespace, since the
assembler will treat them so for -Oasm mode.

Testcases for the new code are also added.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
15ad6d862ec7f66dc00783798705a8db1c5d9aca 19-Feb-2010 David Gibson <david@gibson.dropbear.id.au> dtc: Automatically pick a sensible boot_cpuid_phys

Currently, when in -Idts -Odtb or -Ifs -Odtb modes, dtc always
defaults to using 0 as the value for the boot_cpuid_phys header field.
That's correct quite often, but there are some systems where there is
no CPU with hardware ID of 0, or where we don't want to use the CPU
with hardware ID 0 at all (e.g. for AMP-style partitioning). The only
way to override this default currently, is with the -b command line
option.

This patch improves dtc to instead base the default boot_cpuid_phys
value on the reg property of the first listed subnode of /cpus. This
means that dtc will get boot_cpuid_phys correct by default in a
greater proportion of cases (since the boot cpu is usually listed
first, and this way at least the boot_cpuid_phys default will match
some existing cpu node). If the node doesn't exist or has an invalid
'reg' property (missing or not 4 bytes in length), then
boot_cpuid_phys is set to 0.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
d75b33af676d0beac8398651a7f09037555a550b 26-Nov-2009 David Gibson <david@gibson.dropbear.id.au> Support ePAPR compliant phandle properties

Currently, the Linux kernel, libfdt and dtc, when using flattened
device trees encode a node's phandle into a property named
"linux,phandle". The ePAPR specification, however - aiming as it is
to not be a Linux specific spec - requires that phandles be encoded in
a property named simply "phandle".

This patch adds support for this newer approach to dtc and libfdt.
Specifically:

- fdt_get_phandle() will now return the correct phandle if it
is supplied in either of these properties

- fdt_node_offset_by_phandle() will correctly find a node with
the given phandle encoded in either property.

- By default, when auto-generating phandles, dtc will encode
it into both properties for maximum compatibility. A new -H
option allows either only old-style or only new-style
properties to be generated.

- If phandle properties are explicitly supplied in the dts
file, dtc will not auto-generate ones in the alternate format.

- If both properties are supplied, dtc will check that they
have the same value.

- Some existing testcases are updated to use a mix of old and
new-style phandles, partially testing the changes.

- A new phandle_format test further tests the libfdt support,
and the -H option.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
b31b271f91b867343fe21a20da4d24b03c1ef421 12-Nov-2009 David Gibson <david@gibson.dropbear.id.au> Fix dtc bugs for 64-bit compile

I've just tested building dtc as an x86_64 binary on a 32-bit i386
host by using:
make CC="gcc -m64"
This patch fixes a handful of minor bugs thus discovered:

* There is a printf() type mismatch on 64-bit in value-labels.c

* For the tests which use libdl, we were using the GNU make feature
where it will find libdl.so given a dependency in the form '-ldl'.
But this built-in make logic doesn't know we're compiling 64-bit so
finds the 32-bit version of the library. We avoid using this and
instead explicitly pass -ldl to CC, which being the 64-bit version
does know where to look.

* To process dtc's asm output into .so files, run_tests.sh was
directly invoking the (default instance of) the assembler and linker.
Instead invoke these via the CC driver, and allow that to be overriden
from the make environment.

* The x86_64 assembler doesn't 0 fill with the .balign directive
(presumably it is NOP filling). That doesn't produce strictly
incorrect trees, but it is confusing and confounds are testcases which
do byte-by-byte comparison of the trees produced by asm output with
direct dtb output (which does 0 pad where necessary, of course). This
patch uses the optional second argument to .balign to force gas to
zero-fill instead.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
f2f6d0f2f02b4713e9d0cdc840e211535689a2e6 12-Nov-2009 David Gibson <david@gibson.dropbear.id.au> Don't use echo -e in run_tests.sh

In one section, the run_tests script attempts to use the -e (interpret
escapes) option to echo. This option is not portable - for example
the echo built into dash, now the default /bin/sh on several
distributions does not support it and will just echo "-e" literally.

Since we don't actually use any of the escapes that -e enables, this
patch simply removes it.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
c623fe5c21e0358fc38a4e8ddb0d51379f0733e8 09-Sep-2009 David Gibson <david@gibson.dropbear.id.au> Fix bug in -Odts with properties containing multiple terminating nulls

When in -Odts mode, dtc will not produce correct output for
string-like properties which have more than one \0 character at the
end of the property's bytestring. In fact, it generates output which
is not syntactically correct. This patch fixes the bug, and adds a
testcase for future regressions here.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
bae93e8992fef3cfaff681fe85b26fd35e432e31 08-Jan-2009 David Gibson <david@gibson.dropbear.id.au> dtc: Add testcases for labels within values

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>
/external/dtc/tests/run_tests.sh
26d93f6c922c5b199682f9808c933462c1b97855 08-Jan-2009 David Gibson <david@gibson.dropbear.id.au> dtc: Make asm output more portable and add testcases

This patch adds some testcases for dtc's -Oasm mode. Specifically it
checks that building the asm will result in the same device tree blob
in memory as -Odtb mode would produce, for a variety of trees. This
test uncovered two difficulties with our current -Oasm output, both of
which are addressed in this patch as well.

First, -Oasm output would only be correct if assembled for a
big-endian target. Usually that would be the case, when building
device trees into a firmware or similar. However this makes life
inconvenient for testing on a little-endian target, and one can think
up use cases where a program running on a little endian host might
want to embed a device tree for a big-endian target. This patch
therefore changes -Oasm output to use .byte directives instead of
.long throughout in order to generate byte-for-byte identical trees
regardless of the endianness of the assembler target.

Second, -Oasm output emitted several #define statements which were
then used in the innards of the output - i.e. it assumed the output
would be processed by cpp before being assembled. That may not be
convenient in all build environments, and in any case doesn't work
well with the above fix. So, -Oasm output no longer needs to be
preprocessed before assembling.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
9878f30f311cb56d1ab1914670b38672476916ac 06-Nov-2008 David Gibson <david@gibson.dropbear.id.au> dtc: Handle linux,phandle properties which self-reference

Currently, dtc will generate phandles for nodes which are referenced
elsewhere in the tree. phandles can also be explicitly assigned by
defining the linux,phandle property. However, there is no way,
currently to tell dtc to generate a phandle for a node if it is not
referenced elsewhere. This is inconvenient when it's expected that
later processing on the flat tree might add nodes which _will_
the node in question.

One way one might attempt to do this is with the construct:
mynode: mynode {
linux,phandle = <&mynode>;
/* ... */
};
Though it's a trifle odd, there's really only one sensible meaning
which can be assigned to this construct: allocate a unique phandle to
"mynode" and put that in its linux,phandle property (as always).

Currently, however, dtc will choke on this self-reference. This patch
corrects this, making the construct above give the expected results.
It also ensures a more meaningful error message is given if you
attempt to process the nonsensical construct:
mynode: mynode {
linux,phandle = <&someothernode>;
/* ... */
};

The 'references' testcase is extended to cover this case, as well.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
4e1a0a0129b3d197a6f9086df6e5c3874bf6f1f7 15-Aug-2008 Jon Loeliger <jdl@jdl.com> Remove support for the legacy DTS source file format.

Now that all in-kernel-tree DTS files are properly /dts-v1/,
remove direct support for the older, un-numbered DTS
source file format.

Convert existing tests to /dts-v1/ and remove support
for the conversion tests themselves.

For now, though, the conversion tool still exists.

Signed-off-by: Jon Loeliger <jdl@freescale.com>
/external/dtc/tests/run_tests.sh
9c83115351443a132c5c1cbad6cda79d52f63489 20-Aug-2008 David Gibson <david@gibson.dropbear.id.au> libfdt: Add function to explicitly expand aliases

Kumar has already added alias expansion to fdt_path_offset().
However, in some circumstances it may be convenient for the user of
libfdt to explicitly get the string expansion of an alias. This patch
adds a function to do this, fdt_get_alias(), and uses it to implement
fdt_path_offset().

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
02cc83540bd7aed689560908da2e4e7f6a39e9b4 14-Aug-2008 Kumar Gala <galak@kernel.crashing.org> libfdt: Add support for using aliases in fdt_path_offset()

If the path doesn't start with '/' check to see if it matches some alias
under "/aliases" and substitute the matching alias value in the path
and retry the lookup.

Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
4d7bea7873590ee3a2bfc2905bef3ed8e84a0902 07-Jul-2008 David Gibson <david@gibson.dropbear.id.au> dtc: Run relevant checks on dtb input as well as dts

This patch adjusts the testsuite to run most of the tests for the tree
checking code on input in dtb form as well as dts form. Some checks
which only make sense for dts input (like reference handling) are
excluded, as are those which currently take dtb input because they
rely on things which cannot be lexically constructed in a dts file.

This shows up two small bugs in dtc, which are also corrected.

First, the name_properties test which was is supposed to remove
correctly formed 'name' properties (because they can be reconstructed
from tne node name) was instead removing 'name' properties even if
they weren't correct.

Secondly, when using dtb or fs input, the runtime tree in dtc did not
have the parent pointer initialized propertly because.built
internally. The appropriate initialization is added to the
add_child() function.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
cdcb415851dc6c3e9550f27139c933fcaeb2d6a7 26-Jun-2008 David Gibson <david@gibson.dropbear.id.au> dtc: Address an assortment of portability problems

I've recently worked with a FreeBSD developer, getting dtc and libfdt
working on FreeBSD. This showed up a number of portability problems
in the dtc package which this patch addresses. Changes are as
follows:

- the parent_offset and supernode_atdepth_offset testcases
used the glibc extension functions strchrnul() and strndupa(). Those
are removed, using slightly longer coding with standard C functions
instead.

- some other testcases had a #define _GNU_SOURCE for no
particular reason. This is removed.

- run_tests.sh has bash specific constructs removed, and the
interpreter changed to /bin/sh. This apparently now runs fine on
FreeBSD's /bin/sh, and I've also tested it with both ash and dash.

- convert-dtsv0-lexer.l has some extra #includes added. These
must have been included indirectly with Linux and glibc, but aren't on
FreeBSD.

- the endian handling functions in libfdt_env.h, based on
endian.h and byteswap.h are replaced with some portable open-coded
versions. Unfortunately, these result in fairly crappy code when
compiled, but as far as I can determine there doesn't seem to be any
POSIX, SUS or de facto standard way of determining endianness at
compile time, nor standard names for byteswapping functions.

- some more endian handling, from testdata.h using the
problematic endian.h is simply removed, since it wasn't actually being
used anyway.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
f8e52fe6d87cadbaf0b440073fb9137bef36ee98 24-Jun-2008 David Gibson <david@gibson.dropbear.id.au> dtc: Testcase for /include/ directive

This patch adds a testcase for the /include/ directive. It assembles
a sample dts file with many /include/ directives at a variety of
different lexical / grammatical contexts.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
e37ec7d5889fa04047daaa7a4ff55150ed7954d4 11-Jun-2008 David Gibson <david@gibson.dropbear.id.au> dtc: Add support for binary includes.

On Wed, Jun 04, 2008 at 09:26:23AM -0500, Jon Loeliger wrote:
> David Gibson wrote:
>
>> But as I said that can be dealt with in the future without breaking
>> compatibility. Objection withdrawn.
>>
>
> And on that note, I officially implore Scott to
> re-submit his binary include patch!

Scott's original patch does still have some implementation details I
didn't like. So in the interests of saving time, I've addressed some
of those, added a testcase, and and now resubmitting my revised
version of Scott's patch.

dtc: Add support for binary includes.

A property's data can be populated with a file's contents
as follows:

node {
prop = /incbin/("path/to/data");
};

A subset of a file can be included by passing start and size parameters.
For example, to include bytes 8 through 23:

node {
prop = /incbin/("path/to/data", 8, 16);
};

As with /include/, non-absolute paths are looked for in the directory
of the source file that includes them.

Implementation revised, and a testcase added by David Gibson

Signed-off-by: Scott Wood <scottwood@freescale.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Acked-by: Scott Wood <scottwood@freescale.com>
/external/dtc/tests/run_tests.sh
050e6f0cff5b93a15fefbc0b554cad9a9ab5ea82 30-May-2008 David Gibson <david@gibson.dropbear.id.au> dtc: Add a testcase for 'reg' or 'ranges' in /

This patch adds an extra testcase to dtc to ensure that the
"reg_format" and "ranges_format" checks trigger as they should if a
'reg' or 'ranges' property appears in the root node.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
a84c065f44ea0f4dcd75ae4ecb8dd1e25a5f87f7 15-May-2008 David Gibson <david@gibson.dropbear.id.au> dtc: Add program to convert dts files from v0 to v1

This patch adds a new utility program, convert-dtsv0, to the dtc
sources. This program will convert dts files from v0 to v1,
preserving comments and spacing. It also includes some heuristics to
guess an appropriate base to use in the v1 output (so it will use hex
for the contents of reg properties and decimal for clock-frequency
properties, for example). They're limited and imperfect, but not
terrible.

The guts of the converter program is a modified version of the lexer
from dtc itself.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
548767f42eb00a2bac6f2a1361b7fd49f7b76908 16-May-2008 David Gibson <david@gibson.dropbear.id.au> dtc: Rework handling of boot_cpuid_phys

Currently, dtc will put the nonsense value 0xfeedbeef into the
boot_cpuid_phys field of an output blob, unless explicitly given
another value with the -b command line option. As well as being a
totally unuseful default value, this also means that dtc won't
properly preserve the boot_cpuid_phys field in -I dtb -O dtb mode.

This patch reworks things to improve the boot_cpuid handling. The new
semantics are that the output's boot_cpuid_phys value is:
the value given on the command line if -b is used
otherwise
the value from the input, if in -I dtb mode
otherwise
0

Implementation-wise we do the following:
- boot_cpuid_phys is added to struct boot_info, so that
structure now contains all of the blob's semantic information.
- dt_to_blob() and dt_to_asm() output the cpuid given in
boot_info
- dt_from_blob() fills in boot_info based on the input blob
- The other dt_from_*() functions just record 0, but we can
change this easily if e.g. we invent a way of specifying the boot cpu
in the source format.
- main() overrides the cpuid in the boot_info between input
and output if -b is given

We add some testcases to check this new behaviour.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
6c2e4d61f83af4233c3270e4f1ec1da01d90466e 05-Mar-2008 David Gibson <david@gibson.dropbear.id.au> dtc: Testcases for input handling

This patch adds some testcases checking corner cases of dtc's input
file handling. Specifically it checks that dtc works correctly when
given input via stdin, and it checks that dtc fails gracefully if
given a nonexistent input file (or directory, in the case of -Ifs
mode).

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
68fe10ba4efc86c4bd388f5ba68d1b3e2e9e3be2 05-Mar-2008 David Gibson <david@gibson.dropbear.id.au> dtc: Assorted improvements to test harness

This patch makes several small improvements to the test harness.

* An altered way of invoking shell script testcases from run_tests.sh
means scripts no longer need to me marked executable in the
repository to work properly.

* dtc.sh never did anything that was really dtc specific - with the
exception of messages, it would work equally well for any binary
that returns 0 in the successful case. Therefore, generalise dtc.sh
and fold it into run_tests.sh so we don't need a separate script any
more.

* Tweak various things so that the valgrind options are properly
propagated down to invoke dtc under valgrind when called via wrapper
scripts.

* Tweak the valgrind suppressions to work properly on a wider range of
systems (this was necessary on my machine running Ubuntu Hardy).

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
a266e5c1e105487795aa2e6fe0b52cfdb8a0a71d 28-Feb-2008 David Gibson <david@gibson.dropbear.id.au> dtc: Test and fix conversion to/from old dtb versions

This patch adds testcases which test dtc when used to convert between
different dtb versions. These tests uncovered a couple of bugs
handling old dtb versions, which are also fixed.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
fa5b520ccb5e8da8d67ebc1926416753684f4e70 27-Feb-2008 David Gibson <david@gibson.dropbear.id.au> dtc: Implement checks for the format of node and property names

This patch adds checks to the checking framework to verify that node
and property names contain only legal characters, and in the case of
node names there is at most one '@'.

At present when coming from dts input, this is mostly already ensured
by the grammer, however putting the check later means its easier to
generate helpful error messages rather than just "syntax error". For
dtb input, these checks replace the older similar check built into
flattree.c.

Testcases for the checks are also implemented.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
a90b5905fede1ebd2d6365103cc1d9b78f76217c 18-Feb-2008 David Gibson <david@gibson.dropbear.id.au> libfdt: More tests of NOP handling behaviour

In light of the recently discovered bug with NOP handling, this adds
some more testcases for NOP handling. Specifically, it adds a helper
program which will add a NOP tag after every existing tag in a dtb,
and runs the standard battery of tests over trees mangled in this way.

For now, this does not add a NOP at the very beginning of the
structure block. This causes problems for libfdt at present, because
we assume in many places that the root node's BEGIN_NODE tag is at
offset 0. I'm still contemplating what to do about this (with one
option being simply to declare such dtbs invalid).

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
d8b69426662f29f0cdaf67d380a0b366ba420abd 15-Feb-2008 David Gibson <david@gibson.dropbear.id.au> dtc: Fold comment handling test into testsuite

For ages dtc has included a sample dts, comment-test.dts, for checking
various lexical corner cases in comment processing. In fact, it
predates the automated testsuite, and has never been integrated into
it. This patch addresses this oversight, folding the comment handling
test in with the rest of the testsuite.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
089adb9964a222499eb204198b579c231c59c42f 14-Feb-2008 David Gibson <david@gibson.dropbear.id.au> libfdt: Fix NOP handling bug in fdt_add_subnode_namelen()

fdt_add_subnode_namelen() has a bug if asked to add a subnode to a
node which has NOP tags interspersed with its properties. In this
case fdt_add_subnode_namelen() will put the new subnode before the
first NOP tag, even if there are properties after it, which will
result in an invalid blob.

This patch fixes the bug, and adds a testcase for it.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
82b327d38062cdb4e5628856f9b440ad6c96e7f8 11-Jan-2008 David Gibson <david@gibson.dropbear.id.au> libfdt: Add fdt_set_name() function

This patch adds an fdt_set_name() function to libfdt, mirroring
fdt_get_name(). This is a r/w function which alters the name of a
given device tree node.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
e4ffc1443d23d57babde8413f53e001e84610c4f 07-Dec-2007 David Gibson <david@gibson.dropbear.id.au> dtc: Convert check for obsolete /chosen property

This converts the test for the obsolete "interrupt-controller"
property in /chosen to the new framework. That was the only thing
left in the old-style check_chosen() function, so that function is
removed, too.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
7e089d9473989bc6dadfdfa81fa3fc029abf26db 07-Dec-2007 David Gibson <david@gibson.dropbear.id.au> dtc: Convert #address-cells and #size-cells related checks

This patch converts checks related to #address-cells and #size-cells
to the new framework. Specifically, it reimplements the check that
"reg" properties have a valid size based on the relevant
#address-cells and #size-cells values. The new implementation uses
the correct default value, unlike the old-style check which assumed
the values were inherited by default.

It also implements a new, similar test for "ranges" properties.

Finally, since relying on the default values of these variables is
considered not-good-practice these days, it implements a "style" check
which will give a warning if the tree ever relies on the default
values (that is if any node with either "reg" or "ranges" appears
under a parent which has no #address-cells or #size-cells property).
/external/dtc/tests/run_tests.sh
faf037f0ef294412a3bb04be4032bf2f008a5945 06-Dec-2007 David Gibson <david@gibson.dropbear.id.au> dtc: Migrate "string property" checks to new framework

This patch converts to the new tree checking framework those checks
which verify that certain properties (device_type, model) have a
string value, when present.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
c21acabc40ff1edf8c01f4452c79eaf338b4c13e 06-Dec-2007 David Gibson <david@gibson.dropbear.id.au> dtc: Migrate "one cell" checks to new framework

This patch converts to the new tree checking framework those checks
which verify that certain properties (#address-cells and #size-cells)
are exactly one cell in size, when present.

We also drop the old-style check for "linux,phandle" being one cell,
since that is already implied in the the existing new-style checks on
the linux,phandle property.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
5ba0086bfd0fa6ab25f7ce1870417301a26c104f 06-Dec-2007 David Gibson <david@gibson.dropbear.id.au> dtc: More detailed testing of tree checks

This patch modifies the dtc-checkfails.sh testcase wrapper so that
instead of testing just that dtc fails with a particular error code on
the sample input, it scans dtc's stderr output looking for a message
that dtc failed a specific check or checks. This has several advantages:
- It means we more precisely check dtc's checking behaviour
- It means we can check for generation of warnings using the
same script
- It means we can test cases where dtc should generate
multiple errors or warnings from different checks

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
efbbef8e4f86f8043760f1e48b25ab2795ba3524 05-Dec-2007 David Gibson <david@gibson.dropbear.id.au> dtc: Implement path references

This patch extends dtc syntax to allow references (&label, or
&{/full/path}) directly within property definitions, rather than
inside a cell list. Such references are expanded to the full path of
the referenced node, as a string, instead of to a phandle as
references within cell lists are evaluated.

A testcase is also included.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
459c955cca6adfa393b9279ee595c60e199dbffe 04-Dec-2007 David Gibson <david@gibson.dropbear.id.au> dtc: Convert "name" property checking to new infrastructure

This patch removes the old-style checking code for the "name" property
- i.e. verifying that the "name" property, if present, matches the
node name. It replaces it with a pair of more-or-less equivalent
checks in the new checking framework.

This also promotes this check to a "structural" check, or at least an
error-rather-than-warning test, since the structural/semantic
distinction doesn't really apply in the new framework.

A testcase for the check is also added.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
7c44c2f9cb1cc2df7aacd13decfc4e64b73d1730 22-Nov-2007 David Gibson <david@gibson.dropbear.id.au> dtc: Fix some lexical problems with references

The recent change to the lexer to only recognize property and node
names in the appropriate context removed a number of lexical warts in
our language that would have gotten ugly as we add expression support
and so forth.

But there's one nasty one remaining: references can contain a full
path, including the various problematic node name characters (',', '+'
and '-', for example). This would cause trouble with expressions, and
it also causes trouble with the patch I'm working on to allow
expanding references to paths rather than phandles. This patch
therefore reworks the lexer to mitigate these problems.

- References to labels cause no problems. These are now
recognized separately from references to full paths. No syntax change
here.

- References to full paths, including problematic characters
are allowed by "quoting" the path with braces
e.g. &{/pci@10000/somedevice@3,8000}. The braces protect any internal
problematic characters from being confused with operators or whatever.

- For compatibility with existing dts files, in v0 dts files
we allow bare references to paths as before &/foo/bar/whatever - but
*only* if the path contains no troublesome characters. Specifically
only [a-zA-Z0-9_@/] are allowed.

This is an incompatible change to the dts-v1 format, but since AFAIK
no-one has yet switched to dts-v1 files, I think we can get away with
it. Better to make the transition when people to convert to v1, and
get rid of the problematic old syntax.

Strictly speaking, it's also an incompatible change to the v0 format,
since some path references that were allowed before are no longer
allowed. I suspect no-one has been using the no-longer-supported
forms (certainly none of the kernel dts files will cause trouble).
We might need to think about this harder, though.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
b16a2bd89dbf109b9c8d1c9e047b9afa72af6d2f 22-Nov-2007 David Gibson <david@gibson.dropbear.id.au> dtc: Flexible tree checking infrastructure (v2)

dtc: Flexible tree checking infrastructure

Here, at last, is a substantial start on revising dtc's infrastructure
for checking the tree; this is the rework I've been saying was
necessary practically since dtc was first release.

In the new model, we have a table of "check" structures, each with a
name, references to checking functions, and status variables. Each
check can (in principle) be individually switched off or on (as either
a warning or error). Checks have a list of prerequisites, so if
checks need to rely on results from earlier checks to make sense (or
even to avoid crashing) they just need to list the relevant other
checks there.

For now, only the "structural" checks and the fixups for phandle
references are converted to the new mechanism. The rather more
involved semantic checks (which is where this new mechanism will
really be useful) will have to be converted in future patches.

At present, there's no user interface for turning on/off the checks -
the -f option now forces output even if "error" level checks fail.
Again, future patches will be needed to add the fine-grained control,
but that should be quite straightforward with the infrastructure
implemented here.

Also adds a testcase for the handling of bad references, which catches
a bug encountered while developing this patch.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
67b6b33b9b413a450a72135b5dc59c0a1e33e647 21-Nov-2007 David Gibson <david@gibson.dropbear.id.au> dtc: Add valgrind support to testsuite

This patch adds some options to the run_tests.sh script allowing it to
run all the testcases under valgrind to check for pointer corruption
bugs and memory leaks. Invoking "make checkm" will run the testsuite
with valgrind.

It include a mechanism for specifying valgrind errors to be suppressed
on a per-testcase basis, and adds a couple of such suppression files
for the mangle-layout and open_pack testcases which dump for use by
other testcases a buffer which may contain uninitialized sections. We
use suppressions rather than initializing the buffer so that valgrind
will catch any internal access s to the uninitialized data, which
would be a bug.

The patch also fixes one genuine bug caught by valgrind -
_packblocks() in fdt_rw.c was using memcpy() where it should have been
using memmove().

At present the valgrinding won't do anything useful for testcases
invoked via a shell script - which includes all the dtc testcases. I
plan to fix that later.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
3ce53633871584ad93528fdf5cdcb939bb24ffc3 21-Nov-2007 David Gibson <david@gibson.dropbear.id.au> dtc: Remove some redundant testcases

This patch removes a number of testcases from the testsuite that are
extremely unlikely to find any bugs that won't be found by the other
tests. This speeds up the testsuite.

- Both loops across the various tree block layouts run the
tree1_tests on the basic mangled tree. This is completely redundant,
so remove the second copy. This removes 456 testcases.

- We currently run tree1_tests on various trees manipulated by
move_and_save. We replace those with just a dtbs_equal_ordered test
to check that the manipulated tree is equal to the original. What
we're testing here is that fdt_move() operates correctly - it's very
unlikely it would succeed well enough for the ordered_equal test to
succeed, but the tree1_tests would fail on the result. This removes
162 testcases.

- Currently we re-ordered with mangle-layout both the basic
test_tree1.dtb and sw_tree1.test.dtb. Since we've already checked
that these dtbs are equivalent with dtbs_ordered_equal, it's very
unlikely that the tests would fail on one but not the other.
Therefore reduce this to only using test_tree1.dtb. This removes 828
testcases.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
b2e61bde9fa50428380f7d9e170781499fe462f1 20-Nov-2007 David Gibson <david@gibson.dropbear.id.au> dtc: Don't use env(1) in testsuite

The run_tests.sh script currently invokes the testcase binaries via
env(1). This behaviour is inherited from the libhugetlbfs testsuite
which uses this approach to easily set various configuration
environment variables in testcases.

We don't use that for dtc, and are unlikely to ever want to.
Therefore this patch removes that technique, which substantially
speeds up the testsuite.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
0d6ade254773aa4798fed1b2f1639ea2b8bdeb89 20-Nov-2007 David Gibson <david@gibson.dropbear.id.au> dtc: Add testcases for tree checks

This patch adds a group of testcases to check that dtc correctly
rejects trees with various structural errors.

To make things easier to test, we change dtc so that failing checks
(as opposed to other errors) result in exit code 2.

This patch also fixes an embarrasing bug uncovered by these new tests:
check_phandles() worked out if the tree's phandles were valid, then
throws that information away and returns success always.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
7346858f8139cb143269bbc728b77072074ae997 12-Nov-2007 David Gibson <david@gibson.dropbear.id.au> libfdt: Add phandle related functions

This patch adds fdt_get_phandle() and fdt_node_offset_by_phandle()
functions to libfdt. fdt_get_phandle() will retreive the phandle
value of a given node, and fdt_node_offset_by_phandle() will locate a
node given a phandle.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
9138db565adeb2fbba3181fb589f1c9a3f818dde 07-Nov-2007 David Gibson <david@gibson.dropbear.id.au> dtc: Switch dtc to C-style literals

dtc: Switch dtc to C-style literals

This patch introduces a new version of dts file, distinguished from
older files by starting with the special token /dts-v1/. dts files in
the new version take C-style literals instead of the old bare hex or
OF-style base notation. In addition, the "range" for of memreserve entries
(/memreserve/ f0000-fffff) is no longer recognized in the new format.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Jon Loeliger <jdl@freescale.com>
/external/dtc/tests/run_tests.sh
b433db0fc74bc7b4c04fcfb014bfaac0f5f29a14 07-Nov-2007 David Gibson <david@gibson.dropbear.id.au> dtc: Add testcases exercising -Odts mode

This patch adds a batch of testcases exercising dtc's -Odts mode.
Specifically it checks that using dtc to convert dtb->dts->dtb
preserves the original dtb for a number of example dtb files.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
d79d4e280f008a02b4da030b32189b5efbff7d89 06-Nov-2007 David Gibson <david@gibson.dropbear.id.au> libfdt: Fix sw_tree1 testcase

There is a bug in the sw_tree1 testcase / utility which puts two
"compatible" properties in one node in the output tree. This patch
fixes the bug, and also adds a new test checking that the sw_tree1
output is equal to test_tree1.dtb as its supposed to be, which should
catch future errors of this type.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
a041dcdc48453f26b76bccdb5e2a1ebb3a0ea987 01-Nov-2007 David Gibson <david@gibson.dropbear.id.au> libfdt: Handle v16 and re-ordered trees for r/w

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>
/external/dtc/tests/run_tests.sh
3bef796b449320cefb8e52838ca90163df698722 25-Oct-2007 David Gibson <david@gibson.dropbear.id.au> libfdt: Test on trees with different block layouts

At present, all the example dtbs we use in the testsuite are version
17 and have reservation map, then structure block then strings block
(the natural ordering based on alignment constraints). However, all
libfdt's read-only and in-place write functions should also work on
v16 trees, and on trees with other layouts.

This patch adds a testcase / utility function to rearrange the blocks
of a dtb and/or regress a v17 tree to v16, and uses it to run tests on
trees with different layouts and versions.

Signed-off-by: David Gibson <david@tgibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
3c44c87bdeacc66f46c55090d765a9766475ee50 24-Oct-2007 David Gibson <david@gibson.dropbear.id.au> libfdt: Rename and publish _fdt_next_tag()

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>
/external/dtc/tests/run_tests.sh
169f0b183d45b87ba6dfc194792aee6170ffb54d 18-Oct-2007 David Gibson <david@gibson.dropbear.id.au> dtc: Disable semantic checks by default

At present, dtc makes a lot of semantic checks on the device tree by
default, and will refuse to produce output if they fail. This means
people tend to need -f to force output despite failing semantic checks
rather a lot.

This patch splits the device tree checks into structural checks (no
bad or duplicate names or phandles) and semantic checks (everything
else). By default, only the structural checks are performed, and are
fatal. -f will force output even with structural errors (using this
in -Idts mode would essentially always be a bad idea, but it might be
useful in -Idtb mode for examining a malformed dtb).

Semantic checks are only performed if the new -c command line option
is supplied, and are always warnings only. Semantic checks will never
be performed on a tree with structural errors.

This patch is only a stopgap before implementing proper fine-grained
error/warning handling, but it should at least get rid of the
far-too-frequent need for -f for the time being.

This patch removes the -f from the dtc testcases now that it's no
longer necessary.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
a756c12bea9e39acbed483d9008852f3a371e4a4 16-Oct-2007 David Gibson <david@gibson.dropbear.id.au> dtc: Improve support for string escapes

dtc supports the use of C-style escapes (\n, \t and so forth) in
string property definitions via the data_copy_escape_string()
function. However, while it supports the most common escape
characters, it doesn't support the full set that C does, which is a
potential gotcha.

Worse, a bug in the lexer means that while data_copy_escape_string()
can handle the \" escape, a string with such an escape won't lex
correctly.

This patch fixes both problems, extending data_copy_escape_string() to
support the missing escapes, and fixing the regex for strings in the
lexer to handle internal escaped quotes.

This also adds a testcase for string escape functionality.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
333542fabf8720b881e992a5abca32ef4bcb841a 16-Oct-2007 David Gibson <david@gibson.dropbear.id.au> libfdt: Add functions for handling the "compatible" property

This patch adds functions for dealing with the compatible property.
fdt_node_check_compatible() can be used to determine whether a node is
compatible with a given string and fdt_node_offset_by_compatible()
locates nodes with a given compatible string.

Testcases for these functions are also included.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
121acdec91f269b3efb4b5ac45820f0d1a3b37a1 16-Oct-2007 David Gibson <david@gibson.dropbear.id.au> dtc: Don't delete *.test.dtb between testgroups

The dtc/libfdt testsuite creates a number of .dtb files during its
run. To ensure a clean test run, these are currently deleted before
each group of tests.

This is, in fact, a mistake, since if something goes wrong in the
first group of tests, deleting the .dtb at the beginning of the second
group of tests makes it harder to figure out what the problem was.

This patch changes the script to only delete the files once, before
the whole test run.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
fd1bf3a5ae46962528ef89a824261a88830758a2 10-Oct-2007 David Gibson <david@gibson.dropbear.id.au> libfdt: Add functions to get/add/delete memory reservemap entries

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>
/external/dtc/tests/run_tests.sh
02a5556850bbb64a73cd45b2dbca6579880bb424 28-Sep-2007 David Gibson <david@gibson.dropbear.id.au> libfdt: Test rw functions on more trees

At present, the testcases for read/write functions (setprop,
del_property and del_node) are only invoked on the single
asm-generated tree, not on any of the other tree images which should
be equivalent. The functions in question will (correctly) not work on
the "unfinished" tree output from sw_tree1, but should work on most of
the others.

This patch extends the run_tests script to invoke the r/w testcases on
more example trees. The testsuite still passes clean with this
addition.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
8d59bd3b17ba04dc9bc906742ebe74e69fb0d1ad 18-Sep-2007 David Gibson <david@gibson.dropbear.id.au> dtc: Add basic testcases for dtc

This patch adds a handful of simple testcases for dtc. It adds a dts
file which should generate the same sample tree as is used for the
libfdt testcases, and tests invoking dtc on this dts, plus the
standard batch of libfdt cases on the resulting dtb, which effectively
checks that the dtb is correct.

Because the test framework assumes each testcase is an executable with
the right output conventions, we use a little shell script, dtc.sh, as
a wrapper around dtc itself. It simply invokes dtc and returns a PASS
or FAIL depending on whether dtc returned an error.

It's not much, but it's a start.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
ef90baa0c6405fe6d9400d2f091576ac0df87155 17-Sep-2007 David Gibson <david@gibson.dropbear.id.au> dtc: Cleanup testsuite organization

run_tests.sh from the dtc testsuite currently has a facility ro run
just "functional" or just "stress" tests. This distinction is carried
over from libhugetlbfs where the test framework originated, and where
it made sense.

In dtc, we have no stress tests, so running these subsections isn't
particularly interesting. This patch removes these test subsets,
instead defining a single "libfdt" test subset for testcases related
to libfdt (and not dtc proper only. Currently that's all of the
testcases, but with any luck we'll have some dtc testcases in the
future.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
ae1454b3111e4653895dbba18d594bd78c91d086 17-Sep-2007 David Gibson <david@gibson.dropbear.id.au> libfdt: Add fdt_node_offset_by_prop_value()

This patch adds a function to libfdt to locate nodes containing a
property with a specific value.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
7ca330865e9e4bf0f32a9875a364d00951373999 28-Aug-2007 David Gibson <david@gibson.dropbear.id.au> dtc: Fix summary calculation in testsuite

The bookkeeping for producing the testsuite summary (total number of
tests passed, failed and so forth) is broken. It uses $? across
several tests, but for checks after the first, the value of $? will no
longer contain the original return code, but just that from the
previous test. This patch fixes the problem.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
1248237c7e3f949e974e42927645f82e03f9b115 30-Aug-2007 David Gibson <david@gibson.dropbear.id.au> libfdt: Add fdt_parent_offset() and supporting functions

This patch adds an fdt_parent_offset() function which returns an
offset to the parent node of a given node. It also adds two helper
functions which are used to implement fdt_parent_offset() but are also
exported: fdt_supernode_atdepth_offset() which returns the ancestor of
a given node at a specified depth from the root of the tree, and
fdt_node_depth() which returns the depth of a given node.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
037db263e04f43cb113064fa24e1b441ff761528 30-Aug-2007 David Gibson <david@gibson.dropbear.id.au> libfdt: Add fdt_get_path() function

This patch adds an fdt_get_path() function to libfdt, which returns
the full path of a given node in a caller supplied buffer.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
9d26eabdc6ff9d9676436596876c732de741b9af 30-Aug-2007 David Gibson <david@gibson.dropbear.id.au> libfdt: Add fdt_get_name() to retrieve a node's name

This patch adds a new fdt_get_name() function to libfdt which will
return a node's name string (including unit address, if any).

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
0c7cd1a08783b8efea84bdb78c38521f9cb89125 26-Jun-2007 David Gibson <david@gibson.dropbear.id.au> dtc: Count testcases and results in the dtc/libfdt testsuite

There are quite a lot of testcases in the dtc testsuite (recently
imported from libfdt). It can be easy to miss a stray FAIL result in
the midst of all the rest. To improve this, this patch adds a summary
to the end of the testsuite results giving the total number of tests
along with the number of PASSes FAILs and other results.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
/external/dtc/tests/run_tests.sh
12578976fe9cef82f0c08db3f9a4f550f5085ba4 14-Jun-2007 David Gibson <dgibson@mulberryst.seuss> Merge libfdt into dtc.

Having pulled the libfdt repository into dtc, merge the makefiles and
testsuites so that they build together usefully.
/external/dtc/tests/run_tests.sh