Commit graph

11 commits

Author SHA1 Message Date
Marc-André Lureau
aa522da9ff tests: allow out-of-tree test run
meson runs out-of-tree, add absolute path location where necessary.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20191009102025.10179-3-marcandre.lureau@redhat.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-10-14 16:19:29 +11:00
David Gibson
00f9febf9c tests: Rename tests.sh to testutils.sh
tests.sh has a bunch of shell setup that's sourced in a number of other
scripts.  It _doesn't_ actually run a bunch of tests, which is kind of what
the name suggests.  So rename it to be more obvious.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-29 16:31:39 +11:00
Stephen Warren
1760e7ca03 fdtget-runtest.sh: use printf instead of /bin/echo -e
Not all /bin/echo implementations support the -e option. Instead, use
printf, which appears to be more widely available than /bin/echo -e.

See commit eaec1db "fdtget-runtest.sh: Fix failures when /bin/sh isn't
bash" for history.

I have tested this on Ubuntu 10.04 with /bin/sh pointing to both dash
and bash.

Reported-by: Mike Frysinger <vapier@gentoo.org> # and implemented-by
Signed-off-by: Stephen Warren <swarren@nvidia.com>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
2013-01-06 16:02:42 -06:00
Stephen Warren
eaec1dbc59 fdtget-runtest.sh: Fix failures when /bin/sh isn't bash
On Ubuntu, /bin/sh is dash (at least by default), and dash's echo doesn't
accept the -e option. This means that fdtget-runtest.sh's EXPECT file will
contain "-e foo" rather than just "foo", which causes a test failure.

To work around this, run /bin/echo instead of (builtin) echo, which has
more chance of supporting the -e option.

Another possible fix is to change all the #! lines to /bin/bash rather
than /bin/sh, and change run_tests.sh to invoke sub-scripts using $SHELL
instead of just "sh". However, that would require bash specifically, which
may not be desirable.

Signed-off-by: Stephen Warren <swarren@wwwdotorg.org>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
2012-03-31 09:00:29 -05:00
Simon Glass
097ec97c1a 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>
2012-03-07 13:25:03 -06:00
David Gibson
c34e88354a Don't use diff to check fdt{get,put} results
Currently the fdt{get,put}-runtest.sh scripts invoke diff to check if
fdt{get,put} did the right thing.  This isn't great though: it's not
obvious from the diff output which is the expected and which is the
actual result; diff's line by line behaviour is useless here, since all
the results are a single line and finally, when there is a difference
it always prints information even when the tests are supposed to be
running in quiet mode.

This patch uses cmp instead, and explicitly prints the expected results,
when running in verbose mode (the invocation of fdtget itself will have
already displayed the actual results in this mode.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2012-02-03 08:41:23 -06:00
David Gibson
15b23d21a6 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>
2012-02-03 08:39:50 -06:00
David Gibson
c879a8a28b Factor signal checks out of test scripts
Several test scripts now have some code to check for a program returning
a signal, and reporting a suitable failure.  This patch moves this
duplicated code into a helper function in tests.sh.  At the same time we
remove a bashism found in the current copies (using the non portablr $[ ]
construct for arithmetic).

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2012-02-03 08:38:40 -06:00
David Gibson
2ca83614e7 Use 'trap' builtin to clean up temporaries in test scripts
Some of the test scripts create temporary files, which we remove at the
end.  Except that we usually forgot to remove them on some exit paths. To
avoid this problem in future, this modifies the scripts to use the shell's
trap 0 functionality to automatically remove the temporaries on any exit.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2012-02-03 08:36:35 -06:00
David Gibson
9a50d82c4e Remove unused variable from test scripts
Several of the test scripts remove $TMPFILE, without ever having set
the TMPFILE variable. This patch fixes it.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2012-02-03 08:35:38 -06:00
Simon Glass
68d057f20d 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>
2012-01-21 15:08:36 -06:00