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>
2008-06-26 03:03:49 +02:00
|
|
|
#! /bin/sh
|
2006-11-27 06:21:28 +01:00
|
|
|
|
2019-10-09 12:20:17 +02:00
|
|
|
SRCDIR=`dirname "$0"`
|
|
|
|
. "$SRCDIR/testutils.sh"
|
2008-03-05 06:01:55 +01:00
|
|
|
|
2009-11-12 03:30:02 +01:00
|
|
|
if [ -z "$CC" ]; then
|
2019-11-15 16:51:08 +01:00
|
|
|
CC=cc
|
2009-11-12 03:30:02 +01:00
|
|
|
fi
|
|
|
|
|
2020-03-04 05:32:47 +01:00
|
|
|
if [ -z "$PYTHON" ]; then
|
|
|
|
PYTHON=python3
|
|
|
|
fi
|
|
|
|
|
2020-03-04 05:45:47 +01:00
|
|
|
if [ -n "$NO_PYTHON" ]; then
|
|
|
|
if [ "$NO_PYTHON" != "0" ]; then
|
|
|
|
no_python=true
|
|
|
|
else
|
|
|
|
no_python=false
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
if [ -f ../pylibfdt/_libfdt.so ] || [ -f ../pylibfdt/_libfdt.cpython-3*.so ]; then
|
|
|
|
no_python=false
|
|
|
|
else
|
|
|
|
no_python=true
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2020-03-04 06:10:06 +01:00
|
|
|
if [ -n "$NO_YAML" ]; then
|
|
|
|
if [ "$NO_YAML" != "0" ]; then
|
|
|
|
no_yaml=true
|
|
|
|
else
|
|
|
|
no_yaml=false
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
if pkg-config --exists yaml-0.1; then
|
|
|
|
no_yaml=false
|
|
|
|
else
|
|
|
|
no_yaml=true
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2018-01-03 03:55:32 +01:00
|
|
|
# stat differs between platforms
|
|
|
|
if [ -z "$STATSZ" ]; then
|
2018-01-03 17:34:44 +01:00
|
|
|
stat --version 2>/dev/null | grep -q 'GNU'
|
|
|
|
GNUSTAT=$?
|
|
|
|
if [ "$GNUSTAT" -ne 0 ]; then
|
|
|
|
# Assume BSD stat if we can't detect as GNU stat
|
|
|
|
STATSZ="stat -f %Uz"
|
|
|
|
else
|
|
|
|
STATSZ="stat -c %s"
|
|
|
|
fi
|
2018-01-03 03:55:32 +01:00
|
|
|
fi
|
|
|
|
|
2019-03-29 07:20:16 +01:00
|
|
|
# Help things find the libfdt shared object
|
2020-03-04 06:26:33 +01:00
|
|
|
if [ -z "$TEST_LIBDIR" ]; then
|
|
|
|
TEST_LIBDIR=../libfdt
|
|
|
|
fi
|
|
|
|
export LD_LIBRARY_PATH="$TEST_LIBDIR"
|
2019-03-29 07:20:16 +01:00
|
|
|
|
2006-11-27 06:21:28 +01:00
|
|
|
export QUIET_TEST=1
|
2013-12-30 12:42:41 +01:00
|
|
|
STOP_ON_FAIL=0
|
2006-11-27 06:21:28 +01:00
|
|
|
|
2007-11-21 01:56:14 +01:00
|
|
|
export VALGRIND=
|
|
|
|
VGCODE=126
|
|
|
|
|
2007-06-26 03:33:10 +02:00
|
|
|
tot_tests=0
|
|
|
|
tot_pass=0
|
|
|
|
tot_fail=0
|
|
|
|
tot_config=0
|
2007-11-21 01:56:14 +01:00
|
|
|
tot_vg=0
|
2007-06-26 03:33:10 +02:00
|
|
|
tot_strange=0
|
|
|
|
|
2008-03-05 06:01:55 +01:00
|
|
|
base_run_test() {
|
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>
2008-06-26 03:03:49 +02:00
|
|
|
tot_tests=$((tot_tests + 1))
|
2008-03-05 06:01:55 +01:00
|
|
|
if VALGRIND="$VALGRIND" "$@"; then
|
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>
2008-06-26 03:03:49 +02:00
|
|
|
tot_pass=$((tot_pass + 1))
|
2007-06-26 03:33:10 +02:00
|
|
|
else
|
2007-08-29 04:18:51 +02:00
|
|
|
ret="$?"
|
2013-12-30 12:42:41 +01:00
|
|
|
if [ "$STOP_ON_FAIL" -eq 1 ]; then
|
|
|
|
exit 1
|
|
|
|
fi
|
2010-08-30 04:53:03 +02:00
|
|
|
if [ "$ret" -eq 1 ]; then
|
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>
2008-06-26 03:03:49 +02:00
|
|
|
tot_config=$((tot_config + 1))
|
2010-08-30 04:53:03 +02:00
|
|
|
elif [ "$ret" -eq 2 ]; then
|
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>
2008-06-26 03:03:49 +02:00
|
|
|
tot_fail=$((tot_fail + 1))
|
2010-08-30 04:53:03 +02:00
|
|
|
elif [ "$ret" -eq $VGCODE ]; then
|
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>
2008-06-26 03:03:49 +02:00
|
|
|
tot_vg=$((tot_vg + 1))
|
2007-08-29 04:18:51 +02:00
|
|
|
else
|
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>
2008-06-26 03:03:49 +02:00
|
|
|
tot_strange=$((tot_strange + 1))
|
2007-08-29 04:18:51 +02:00
|
|
|
fi
|
2007-06-26 03:33:10 +02:00
|
|
|
fi
|
2006-11-27 06:21:28 +01:00
|
|
|
}
|
|
|
|
|
2012-02-03 06:12:07 +01:00
|
|
|
shorten_echo () {
|
|
|
|
limit=32
|
2015-05-25 03:57:32 +02:00
|
|
|
printf "$1"
|
2012-02-03 06:12:07 +01:00
|
|
|
shift
|
|
|
|
for x; do
|
|
|
|
if [ ${#x} -le $limit ]; then
|
2015-05-25 03:57:32 +02:00
|
|
|
printf " $x"
|
2012-02-03 06:12:07 +01:00
|
|
|
else
|
|
|
|
short=$(echo "$x" | head -c$limit)
|
2015-05-25 03:57:32 +02:00
|
|
|
printf " \"$short\"...<${#x} bytes>"
|
2012-02-03 06:12:07 +01:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2008-03-05 06:01:55 +01:00
|
|
|
run_test () {
|
2015-05-25 03:57:32 +02:00
|
|
|
printf "$*: "
|
2008-03-05 06:01:55 +01:00
|
|
|
if [ -n "$VALGRIND" -a -f $1.supp ]; then
|
|
|
|
VGSUPP="--suppressions=$1.supp"
|
|
|
|
fi
|
|
|
|
base_run_test $VALGRIND $VGSUPP "./$@"
|
|
|
|
}
|
|
|
|
|
|
|
|
run_sh_test () {
|
2015-05-25 03:57:32 +02:00
|
|
|
printf "$*: "
|
2008-03-05 06:01:55 +01:00
|
|
|
base_run_test sh "$@"
|
|
|
|
}
|
|
|
|
|
|
|
|
wrap_test () {
|
|
|
|
(
|
|
|
|
if verbose_run "$@"; then
|
|
|
|
PASS
|
|
|
|
else
|
|
|
|
ret="$?"
|
|
|
|
if [ "$ret" -gt 127 ]; then
|
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>
2008-06-26 03:03:49 +02:00
|
|
|
signame=$(kill -l $((ret - 128)))
|
2008-03-05 06:01:55 +01:00
|
|
|
FAIL "Killed by SIG$signame"
|
2018-11-14 06:13:30 +01:00
|
|
|
elif [ "$ret" -eq $VGCODE ]; then
|
|
|
|
echo "VALGRIND ERROR"
|
|
|
|
exit $VGCODE
|
2008-03-05 06:01:55 +01:00
|
|
|
else
|
|
|
|
FAIL "Returned error code $ret"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
run_wrap_test () {
|
2013-05-29 04:39:47 +02:00
|
|
|
shorten_echo "$@: "
|
2008-03-05 06:01:55 +01:00
|
|
|
base_run_test wrap_test "$@"
|
|
|
|
}
|
|
|
|
|
2012-02-03 06:12:07 +01:00
|
|
|
wrap_error () {
|
|
|
|
(
|
|
|
|
if verbose_run "$@"; then
|
|
|
|
FAIL "Expected non-zero return code"
|
|
|
|
else
|
|
|
|
ret="$?"
|
|
|
|
if [ "$ret" -gt 127 ]; then
|
|
|
|
signame=$(kill -l $((ret - 128)))
|
|
|
|
FAIL "Killed by SIG$signame"
|
|
|
|
else
|
|
|
|
PASS
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
run_wrap_error_test () {
|
|
|
|
shorten_echo "$@"
|
2015-05-25 03:57:32 +02:00
|
|
|
printf " {!= 0}: "
|
2012-02-03 06:12:07 +01:00
|
|
|
base_run_test wrap_error "$@"
|
|
|
|
}
|
|
|
|
|
2016-07-18 09:56:53 +02:00
|
|
|
# $1: dtb file
|
|
|
|
# $2: align base
|
2016-09-22 06:42:42 +02:00
|
|
|
check_align () {
|
|
|
|
shorten_echo "check_align $@: "
|
2018-01-03 03:55:32 +01:00
|
|
|
local size=$($STATSZ "$1")
|
2016-09-22 06:42:42 +02:00
|
|
|
local align="$2"
|
2016-07-18 09:56:53 +02:00
|
|
|
(
|
2016-09-22 06:42:42 +02:00
|
|
|
if [ $(($size % $align)) -eq 0 ] ;then
|
2016-07-18 09:56:53 +02:00
|
|
|
PASS
|
|
|
|
else
|
2016-09-22 06:42:42 +02:00
|
|
|
FAIL "Output size $size is not $align-byte aligned"
|
2016-07-18 09:56:53 +02:00
|
|
|
fi
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2008-03-05 06:01:55 +01:00
|
|
|
run_dtc_test () {
|
2015-05-25 03:57:32 +02:00
|
|
|
printf "dtc $*: "
|
2008-03-05 06:01:55 +01:00
|
|
|
base_run_test wrap_test $VALGRIND $DTC "$@"
|
|
|
|
}
|
|
|
|
|
2009-01-08 01:47:55 +01:00
|
|
|
asm_to_so () {
|
2019-10-09 12:20:17 +02:00
|
|
|
$CC -shared -o $1.test.so "$SRCDIR/data.S" $1.test.s
|
2009-01-08 01:47:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
asm_to_so_test () {
|
|
|
|
run_wrap_test asm_to_so "$@"
|
|
|
|
}
|
|
|
|
|
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 19:14:47 +01:00
|
|
|
run_fdtget_test () {
|
2012-02-03 06:12:07 +01:00
|
|
|
expect="$1"
|
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 19:14:47 +01:00
|
|
|
shift
|
2015-05-25 03:57:32 +02:00
|
|
|
printf "fdtget-runtest.sh %s $*: " "$(echo $expect)"
|
2019-10-09 12:20:17 +02:00
|
|
|
base_run_test sh "$SRCDIR/fdtget-runtest.sh" "$expect" "$@"
|
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 19:14:47 +01:00
|
|
|
}
|
|
|
|
|
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>
2012-01-21 19:14:48 +01:00
|
|
|
run_fdtput_test () {
|
2012-02-03 06:12:07 +01:00
|
|
|
expect="$1"
|
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>
2012-01-21 19:14:48 +01:00
|
|
|
shift
|
2012-02-03 06:12:07 +01:00
|
|
|
shorten_echo fdtput-runtest.sh "$expect" "$@"
|
2015-05-25 03:57:32 +02:00
|
|
|
printf ": "
|
2019-10-09 12:20:17 +02:00
|
|
|
base_run_test sh "$SRCDIR/fdtput-runtest.sh" "$expect" "$@"
|
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>
2012-01-21 19:14:48 +01:00
|
|
|
}
|
|
|
|
|
2014-06-18 13:24:32 +02:00
|
|
|
run_fdtdump_test() {
|
|
|
|
file="$1"
|
|
|
|
shorten_echo fdtdump-runtest.sh "$file"
|
2015-05-25 03:57:32 +02:00
|
|
|
printf ": "
|
2019-10-09 12:20:17 +02:00
|
|
|
base_run_test sh "$SRCDIR/fdtdump-runtest.sh" "$file" 2>/dev/null
|
2014-06-18 13:24:32 +02:00
|
|
|
}
|
|
|
|
|
2017-06-14 16:51:12 +02:00
|
|
|
run_fdtoverlay_test() {
|
|
|
|
expect="$1"
|
|
|
|
shift
|
|
|
|
shorten_echo fdtoverlay-runtest.sh "$expect" "$@"
|
|
|
|
printf ": "
|
2019-10-09 12:20:17 +02:00
|
|
|
base_run_test sh "$SRCDIR/fdtoverlay-runtest.sh" "$expect" "$@"
|
2017-06-14 16:51:12 +02:00
|
|
|
}
|
|
|
|
|
2016-09-30 15:57:17 +02:00
|
|
|
BAD_FIXUP_TREES="bad_index \
|
|
|
|
empty \
|
|
|
|
empty_index \
|
|
|
|
index_trailing \
|
|
|
|
path_empty_prop \
|
|
|
|
path_only \
|
|
|
|
path_only_sep \
|
|
|
|
path_prop"
|
|
|
|
|
2016-12-09 04:19:21 +01:00
|
|
|
# Test to exercise libfdt overlay application without dtc's overlay support
|
|
|
|
libfdt_overlay_tests () {
|
2016-12-09 05:56:44 +01:00
|
|
|
# First test a doctored overlay which requires only local fixups
|
2019-10-09 12:20:17 +02:00
|
|
|
run_dtc_test -I dts -O dtb -o overlay_base_no_symbols.test.dtb "$SRCDIR/overlay_base.dts"
|
2016-12-09 05:56:44 +01:00
|
|
|
run_test check_path overlay_base_no_symbols.test.dtb not-exists "/__symbols__"
|
|
|
|
run_test check_path overlay_base_no_symbols.test.dtb not-exists "/__fixups__"
|
|
|
|
run_test check_path overlay_base_no_symbols.test.dtb not-exists "/__local_fixups__"
|
|
|
|
|
2019-10-09 12:20:17 +02:00
|
|
|
run_dtc_test -I dts -O dtb -o overlay_overlay_no_fixups.test.dtb "$SRCDIR/overlay_overlay_no_fixups.dts"
|
2016-12-09 05:56:44 +01:00
|
|
|
run_test check_path overlay_overlay_no_fixups.test.dtb not-exists "/__symbols__"
|
|
|
|
run_test check_path overlay_overlay_no_fixups.test.dtb not-exists "/__fixups__"
|
|
|
|
run_test check_path overlay_overlay_no_fixups.test.dtb exists "/__local_fixups__"
|
|
|
|
|
|
|
|
run_test overlay overlay_base_no_symbols.test.dtb overlay_overlay_no_fixups.test.dtb
|
|
|
|
|
|
|
|
# Then test with manually constructed fixups
|
2019-10-09 12:20:17 +02:00
|
|
|
run_dtc_test -I dts -O dtb -o overlay_base_manual_symbols.test.dtb "$SRCDIR/overlay_base_manual_symbols.dts"
|
2016-12-09 05:56:44 +01:00
|
|
|
run_test check_path overlay_base_manual_symbols.test.dtb exists "/__symbols__"
|
|
|
|
run_test check_path overlay_base_manual_symbols.test.dtb not-exists "/__fixups__"
|
|
|
|
run_test check_path overlay_base_manual_symbols.test.dtb not-exists "/__local_fixups__"
|
|
|
|
|
2019-10-09 12:20:17 +02:00
|
|
|
run_dtc_test -I dts -O dtb -o overlay_overlay_manual_fixups.test.dtb "$SRCDIR/overlay_overlay_manual_fixups.dts"
|
2016-12-09 05:56:44 +01:00
|
|
|
run_test check_path overlay_overlay_manual_fixups.test.dtb not-exists "/__symbols__"
|
|
|
|
run_test check_path overlay_overlay_manual_fixups.test.dtb exists "/__fixups__"
|
|
|
|
run_test check_path overlay_overlay_manual_fixups.test.dtb exists "/__local_fixups__"
|
|
|
|
|
|
|
|
run_test overlay overlay_base_manual_symbols.test.dtb overlay_overlay_manual_fixups.test.dtb
|
2016-09-30 15:57:17 +02:00
|
|
|
|
2017-06-14 16:53:06 +02:00
|
|
|
# test simplified plugin syntax
|
2019-10-09 12:20:17 +02:00
|
|
|
run_dtc_test -@ -I dts -O dtb -o overlay_overlay_simple.dtb "$SRCDIR/overlay_overlay_simple.dts"
|
2017-06-14 16:53:06 +02:00
|
|
|
|
|
|
|
# verify non-generation of local fixups
|
|
|
|
run_test check_path overlay_overlay_simple.dtb not-exists "/__local_fixups__"
|
|
|
|
|
2016-12-09 04:19:21 +01:00
|
|
|
# Bad fixup tests
|
|
|
|
for test in $BAD_FIXUP_TREES; do
|
|
|
|
tree="overlay_bad_fixup_$test"
|
2019-10-09 12:20:17 +02:00
|
|
|
run_dtc_test -I dts -O dtb -o $tree.test.dtb "$SRCDIR/$tree.dts"
|
2016-12-09 04:19:21 +01:00
|
|
|
run_test overlay_bad_fixup overlay_base_no_symbols.test.dtb $tree.test.dtb
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
# Tests to exercise dtc's overlay generation support
|
|
|
|
dtc_overlay_tests () {
|
2016-12-09 03:35:34 +01:00
|
|
|
# Overlay tests for dtc
|
2019-10-09 12:20:17 +02:00
|
|
|
run_dtc_test -@ -I dts -O dtb -o overlay_base.test.dtb "$SRCDIR/overlay_base.dts"
|
2016-12-09 06:02:46 +01:00
|
|
|
run_test check_path overlay_base.test.dtb exists "/__symbols__"
|
|
|
|
run_test check_path overlay_base.test.dtb not-exists "/__fixups__"
|
|
|
|
run_test check_path overlay_base.test.dtb not-exists "/__local_fixups__"
|
2016-12-09 03:35:34 +01:00
|
|
|
|
2018-03-06 03:45:23 +01:00
|
|
|
# With syntactic sugar
|
2019-10-09 12:20:17 +02:00
|
|
|
run_dtc_test -I dts -O dtb -o overlay_overlay.test.dtb "$SRCDIR/overlay_overlay.dts"
|
2016-12-09 06:12:30 +01:00
|
|
|
run_test check_path overlay_overlay.test.dtb not-exists "/__symbols__"
|
2016-12-09 06:02:46 +01:00
|
|
|
run_test check_path overlay_overlay.test.dtb exists "/__fixups__"
|
|
|
|
run_test check_path overlay_overlay.test.dtb exists "/__local_fixups__"
|
|
|
|
|
2018-03-06 03:45:23 +01:00
|
|
|
# Without syntactic sugar
|
2020-12-19 15:35:21 +01:00
|
|
|
run_dtc_test -I dts -O dtb -o overlay_overlay_nosugar.test.dtb "$SRCDIR/overlay_overlay_nosugar.dts"
|
2018-03-06 03:45:23 +01:00
|
|
|
run_test check_path overlay_overlay_nosugar.test.dtb not-exists "/__symbols__"
|
|
|
|
run_test check_path overlay_overlay_nosugar.test.dtb exists "/__fixups__"
|
|
|
|
run_test check_path overlay_overlay_nosugar.test.dtb exists "/__local_fixups__"
|
|
|
|
|
Correct overlay syntactic sugar for generating target-path fragments
We've recently added "syntactic sugar" support to generate runtime dtb
overlays using similar syntax to the compile time overlays we've had for
a while. This worked with the &label { ... } syntax, adjusting an existing
labelled node, but would fail with the &{/path} { ... } syntax attempting
to adjust an existing node referenced by its path.
The previous code would always try to use the "target" property in the
output overlay, which needs to be fixed up, and __fixups__ can only encode
symbols, not paths, so the result could never work properly.
This adds support for the &{/path} syntax for overlays, translating it into
the "target-path" encoding in the output. It also changes existing
behaviour a little because we now unconditionally one fragment for each
overlay section in the source. Previously we would only create a fragment
if we couldn't locally resolve the node referenced. We need this for
path references, because the path is supposed to be referencing something
in the (not yet known) base tree, rather than the overlay tree we are
working with now. In particular one useful case for path based overlays
is using &{/} - but the constructed overlay tree will always have a root
node, meaning that without the change that would attempt to resolve the
fragment locally, which is not what we want.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-03-06 03:27:53 +01:00
|
|
|
# Using target-path
|
2019-10-09 12:20:17 +02:00
|
|
|
run_dtc_test -I dts -O dtb -o overlay_overlay_bypath.test.dtb "$SRCDIR/overlay_overlay_bypath.dts"
|
Correct overlay syntactic sugar for generating target-path fragments
We've recently added "syntactic sugar" support to generate runtime dtb
overlays using similar syntax to the compile time overlays we've had for
a while. This worked with the &label { ... } syntax, adjusting an existing
labelled node, but would fail with the &{/path} { ... } syntax attempting
to adjust an existing node referenced by its path.
The previous code would always try to use the "target" property in the
output overlay, which needs to be fixed up, and __fixups__ can only encode
symbols, not paths, so the result could never work properly.
This adds support for the &{/path} syntax for overlays, translating it into
the "target-path" encoding in the output. It also changes existing
behaviour a little because we now unconditionally one fragment for each
overlay section in the source. Previously we would only create a fragment
if we couldn't locally resolve the node referenced. We need this for
path references, because the path is supposed to be referencing something
in the (not yet known) base tree, rather than the overlay tree we are
working with now. In particular one useful case for path based overlays
is using &{/} - but the constructed overlay tree will always have a root
node, meaning that without the change that would attempt to resolve the
fragment locally, which is not what we want.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-03-06 03:27:53 +01:00
|
|
|
run_test check_path overlay_overlay_bypath.test.dtb not-exists "/__symbols__"
|
|
|
|
run_test check_path overlay_overlay_bypath.test.dtb not-exists "/__fixups__"
|
|
|
|
run_test check_path overlay_overlay_bypath.test.dtb exists "/__local_fixups__"
|
|
|
|
|
2018-09-25 21:32:37 +02:00
|
|
|
# Make sure local target references are resolved and nodes are merged and that path references are not
|
2019-10-09 12:20:17 +02:00
|
|
|
run_dtc_test -I dts -O dtb -o overlay_overlay_local_merge.test.dtb "$SRCDIR/overlay_overlay_local_merge.dts"
|
2018-09-25 21:32:37 +02:00
|
|
|
run_test check_path overlay_overlay_local_merge.test.dtb exists "/fragment@0/__overlay__/new-node/new-merged-node"
|
|
|
|
run_test check_path overlay_overlay_local_merge.test.dtb exists "/fragment@1/__overlay__/new-root-node"
|
|
|
|
|
2018-03-06 03:45:23 +01:00
|
|
|
# Check building works the same as manual constructions
|
|
|
|
run_test dtbs_equal_ordered overlay_overlay.test.dtb overlay_overlay_nosugar.test.dtb
|
|
|
|
|
2019-10-09 12:20:17 +02:00
|
|
|
run_dtc_test -I dts -O dtb -o overlay_overlay_manual_fixups.test.dtb "$SRCDIR/overlay_overlay_manual_fixups.dts"
|
2018-03-06 03:45:23 +01:00
|
|
|
run_test dtbs_equal_ordered overlay_overlay.test.dtb overlay_overlay_manual_fixups.test.dtb
|
|
|
|
|
2019-10-09 12:20:17 +02:00
|
|
|
run_dtc_test -I dts -O dtb -o overlay_overlay_no_fixups.test.dtb "$SRCDIR/overlay_overlay_no_fixups.dts"
|
Correct overlay syntactic sugar for generating target-path fragments
We've recently added "syntactic sugar" support to generate runtime dtb
overlays using similar syntax to the compile time overlays we've had for
a while. This worked with the &label { ... } syntax, adjusting an existing
labelled node, but would fail with the &{/path} { ... } syntax attempting
to adjust an existing node referenced by its path.
The previous code would always try to use the "target" property in the
output overlay, which needs to be fixed up, and __fixups__ can only encode
symbols, not paths, so the result could never work properly.
This adds support for the &{/path} syntax for overlays, translating it into
the "target-path" encoding in the output. It also changes existing
behaviour a little because we now unconditionally one fragment for each
overlay section in the source. Previously we would only create a fragment
if we couldn't locally resolve the node referenced. We need this for
path references, because the path is supposed to be referencing something
in the (not yet known) base tree, rather than the overlay tree we are
working with now. In particular one useful case for path based overlays
is using &{/} - but the constructed overlay tree will always have a root
node, meaning that without the change that would attempt to resolve the
fragment locally, which is not what we want.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-03-06 03:27:53 +01:00
|
|
|
run_test dtbs_equal_ordered overlay_overlay_bypath.test.dtb overlay_overlay_no_fixups.test.dtb
|
|
|
|
|
|
|
|
# Check we can actually apply the result
|
2019-10-09 12:20:17 +02:00
|
|
|
run_dtc_test -I dts -O dtb -o overlay_base_no_symbols.test.dtb "$SRCDIR/overlay_base.dts"
|
2016-12-09 06:02:46 +01:00
|
|
|
run_test overlay overlay_base.test.dtb overlay_overlay.test.dtb
|
Correct overlay syntactic sugar for generating target-path fragments
We've recently added "syntactic sugar" support to generate runtime dtb
overlays using similar syntax to the compile time overlays we've had for
a while. This worked with the &label { ... } syntax, adjusting an existing
labelled node, but would fail with the &{/path} { ... } syntax attempting
to adjust an existing node referenced by its path.
The previous code would always try to use the "target" property in the
output overlay, which needs to be fixed up, and __fixups__ can only encode
symbols, not paths, so the result could never work properly.
This adds support for the &{/path} syntax for overlays, translating it into
the "target-path" encoding in the output. It also changes existing
behaviour a little because we now unconditionally one fragment for each
overlay section in the source. Previously we would only create a fragment
if we couldn't locally resolve the node referenced. We need this for
path references, because the path is supposed to be referencing something
in the (not yet known) base tree, rather than the overlay tree we are
working with now. In particular one useful case for path based overlays
is using &{/} - but the constructed overlay tree will always have a root
node, meaning that without the change that would attempt to resolve the
fragment locally, which is not what we want.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-03-06 03:27:53 +01:00
|
|
|
run_test overlay overlay_base_no_symbols.test.dtb overlay_overlay_bypath.test.dtb
|
2016-12-09 03:35:34 +01:00
|
|
|
|
|
|
|
# test plugin source to dtb and back
|
2016-12-09 06:07:39 +01:00
|
|
|
run_dtc_test -I dtb -O dts -o overlay_overlay_decompile.test.dts overlay_overlay.test.dtb
|
|
|
|
run_dtc_test -I dts -O dtb -o overlay_overlay_decompile.test.dtb overlay_overlay_decompile.test.dts
|
2016-12-09 06:02:46 +01:00
|
|
|
run_test dtbs_equal_ordered overlay_overlay.test.dtb overlay_overlay_decompile.test.dtb
|
2016-12-09 03:35:34 +01:00
|
|
|
|
2019-05-20 10:12:09 +02:00
|
|
|
# Test generation of aliases instead of symbols
|
2019-10-09 12:20:17 +02:00
|
|
|
run_dtc_test -A -I dts -O dtb -o overlay_base_with_aliases.dtb "$SRCDIR/overlay_base.dts"
|
2016-12-09 03:46:02 +01:00
|
|
|
run_test check_path overlay_base_with_aliases.dtb exists "/aliases"
|
|
|
|
run_test check_path overlay_base_with_aliases.dtb not-exists "/__symbols__"
|
|
|
|
run_test check_path overlay_base_with_aliases.dtb not-exists "/__fixups__"
|
|
|
|
run_test check_path overlay_base_with_aliases.dtb not-exists "/__local_fixups__"
|
2016-09-30 15:57:17 +02:00
|
|
|
}
|
|
|
|
|
2006-11-28 07:20:01 +01:00
|
|
|
tree1_tests () {
|
|
|
|
TREE=$1
|
|
|
|
|
2006-11-27 06:21:28 +01:00
|
|
|
# Read-only tests
|
2007-10-10 09:12:12 +02:00
|
|
|
run_test get_mem_rsv $TREE
|
2006-11-28 07:20:01 +01:00
|
|
|
run_test root_node $TREE
|
2006-12-11 06:15:34 +01:00
|
|
|
run_test find_property $TREE
|
2006-11-28 07:20:01 +01:00
|
|
|
run_test subnode_offset $TREE
|
|
|
|
run_test path_offset $TREE
|
2007-08-30 06:54:04 +02:00
|
|
|
run_test get_name $TREE
|
2006-11-28 07:20:01 +01:00
|
|
|
run_test getprop $TREE
|
2018-11-22 21:15:06 +01:00
|
|
|
run_test get_prop_offset $TREE
|
2007-11-12 23:59:38 +01:00
|
|
|
run_test get_phandle $TREE
|
2007-08-30 06:54:04 +02:00
|
|
|
run_test get_path $TREE
|
2007-08-30 06:54:04 +02:00
|
|
|
run_test supernode_atdepth_offset $TREE
|
|
|
|
run_test parent_offset $TREE
|
2007-09-17 06:28:34 +02:00
|
|
|
run_test node_offset_by_prop_value $TREE
|
2007-11-12 23:59:38 +01:00
|
|
|
run_test node_offset_by_phandle $TREE
|
2007-10-16 05:58:25 +02:00
|
|
|
run_test node_check_compatible $TREE
|
|
|
|
run_test node_offset_by_compatible $TREE
|
2006-11-28 07:20:01 +01:00
|
|
|
run_test notfound $TREE
|
2006-11-27 06:21:28 +01:00
|
|
|
|
|
|
|
# Write-in-place tests
|
2006-11-28 07:20:01 +01:00
|
|
|
run_test setprop_inplace $TREE
|
|
|
|
run_test nop_property $TREE
|
|
|
|
run_test nop_node $TREE
|
|
|
|
}
|
|
|
|
|
2007-09-28 06:57:01 +02:00
|
|
|
tree1_tests_rw () {
|
|
|
|
TREE=$1
|
|
|
|
|
|
|
|
# Read-write tests
|
2008-01-11 04:55:05 +01:00
|
|
|
run_test set_name $TREE
|
2007-09-28 06:57:01 +02:00
|
|
|
run_test setprop $TREE
|
|
|
|
run_test del_property $TREE
|
|
|
|
run_test del_node $TREE
|
|
|
|
}
|
|
|
|
|
2008-07-07 03:19:13 +02:00
|
|
|
check_tests () {
|
|
|
|
tree="$1"
|
|
|
|
shift
|
2019-10-09 12:20:17 +02:00
|
|
|
run_sh_test "$SRCDIR/dtc-checkfails.sh" "$@" -- -I dts -O dtb $tree
|
2008-07-07 03:19:13 +02:00
|
|
|
run_dtc_test -I dts -O dtb -o $tree.test.dtb -f $tree
|
2019-10-09 12:20:17 +02:00
|
|
|
run_sh_test "$SRCDIR/dtc-checkfails.sh" "$@" -- -I dtb -O dtb $tree.test.dtb
|
2008-07-07 03:19:13 +02:00
|
|
|
}
|
|
|
|
|
2007-11-01 01:37:31 +01:00
|
|
|
ALL_LAYOUTS="mts mst tms tsm smt stm"
|
|
|
|
|
2007-09-17 06:39:24 +02:00
|
|
|
libfdt_tests () {
|
2006-11-28 07:20:01 +01:00
|
|
|
tree1_tests test_tree1.dtb
|
2006-11-29 06:45:46 +01:00
|
|
|
|
2019-10-09 12:20:17 +02:00
|
|
|
run_dtc_test -I dts -O dtb -o addresses.test.dtb "$SRCDIR/addresses.dts"
|
2014-05-11 05:13:46 +02:00
|
|
|
run_test addr_size_cells addresses.test.dtb
|
2019-10-09 12:20:17 +02:00
|
|
|
run_dtc_test -I dts -O dtb -o addresses2.test.dtb "$SRCDIR/empty.dts"
|
2018-07-19 08:19:43 +02:00
|
|
|
run_test addr_size_cells2 addresses2.test.dtb
|
2014-05-11 05:13:46 +02:00
|
|
|
|
2019-10-09 12:20:17 +02:00
|
|
|
run_dtc_test -I dts -O dtb -o stringlist.test.dtb "$SRCDIR/stringlist.dts"
|
2015-09-30 05:16:12 +02:00
|
|
|
run_test stringlist stringlist.test.dtb
|
|
|
|
|
2019-05-09 11:41:22 +02:00
|
|
|
for flags in default no_name_dedup; do
|
|
|
|
# Sequential write tests
|
|
|
|
run_test sw_tree1 fixed $flags
|
|
|
|
tree1_tests sw_tree1.test.dtb
|
|
|
|
tree1_tests unfinished_tree1.test.dtb
|
|
|
|
run_test dtbs_equal_ordered test_tree1.dtb sw_tree1.test.dtb
|
|
|
|
run_test sw_states
|
|
|
|
|
|
|
|
# Resizing tests
|
|
|
|
for mode in resize realloc newalloc; do
|
|
|
|
run_test sw_tree1 $mode $flags
|
|
|
|
tree1_tests sw_tree1.test.dtb
|
|
|
|
tree1_tests unfinished_tree1.test.dtb
|
|
|
|
run_test dtbs_equal_ordered test_tree1.dtb sw_tree1.test.dtb
|
|
|
|
done
|
2013-10-25 15:17:37 +02:00
|
|
|
done
|
|
|
|
|
2006-12-01 05:07:19 +01:00
|
|
|
# fdt_move tests
|
|
|
|
for tree in test_tree1.dtb sw_tree1.test.dtb unfinished_tree1.test.dtb; do
|
|
|
|
rm -f moved.$tree shunted.$tree deshunted.$tree
|
|
|
|
run_test move_and_save $tree
|
2007-11-21 01:29:18 +01:00
|
|
|
run_test dtbs_equal_ordered $tree moved.$tree
|
|
|
|
run_test dtbs_equal_ordered $tree shunted.$tree
|
|
|
|
run_test dtbs_equal_ordered $tree deshunted.$tree
|
2006-12-01 05:07:19 +01:00
|
|
|
done
|
2006-12-01 06:59:43 +01:00
|
|
|
|
2007-10-25 07:05:58 +02:00
|
|
|
# v16 and alternate layout tests
|
2007-11-21 01:29:18 +01:00
|
|
|
for tree in test_tree1.dtb; do
|
2007-10-25 07:05:58 +02:00
|
|
|
for version in 17 16; do
|
2007-11-01 01:37:31 +01:00
|
|
|
for layout in $ALL_LAYOUTS; do
|
2007-10-25 07:05:58 +02:00
|
|
|
run_test mangle-layout $tree $version $layout
|
|
|
|
tree1_tests v$version.$layout.$tree
|
|
|
|
run_test dtbs_equal_ordered $tree v$version.$layout.$tree
|
|
|
|
done
|
|
|
|
done
|
|
|
|
done
|
|
|
|
|
2006-12-01 06:59:43 +01:00
|
|
|
# Read-write tests
|
2007-11-21 01:29:18 +01:00
|
|
|
for basetree in test_tree1.dtb; do
|
2007-11-01 01:37:31 +01:00
|
|
|
for version in 17 16; do
|
|
|
|
for layout in $ALL_LAYOUTS; do
|
|
|
|
tree=v$version.$layout.$basetree
|
|
|
|
rm -f opened.$tree repacked.$tree
|
|
|
|
run_test open_pack $tree
|
|
|
|
tree1_tests opened.$tree
|
|
|
|
tree1_tests repacked.$tree
|
|
|
|
|
|
|
|
tree1_tests_rw $tree
|
|
|
|
tree1_tests_rw opened.$tree
|
|
|
|
tree1_tests_rw repacked.$tree
|
|
|
|
done
|
|
|
|
done
|
2007-09-28 06:57:01 +02:00
|
|
|
done
|
2006-12-01 06:59:43 +01:00
|
|
|
run_test rw_tree1
|
|
|
|
tree1_tests rw_tree1.test.dtb
|
2007-09-28 06:57:01 +02:00
|
|
|
tree1_tests_rw rw_tree1.test.dtb
|
2012-01-11 13:41:32 +01:00
|
|
|
run_test appendprop1
|
|
|
|
run_test appendprop2 appendprop1.test.dtb
|
2019-10-09 12:20:17 +02:00
|
|
|
run_dtc_test -I dts -O dtb -o appendprop.test.dtb "$SRCDIR/appendprop.dts"
|
2012-01-11 13:41:32 +01:00
|
|
|
run_test dtbs_equal_ordered appendprop2.test.dtb appendprop.test.dtb
|
2016-12-09 04:19:21 +01:00
|
|
|
libfdt_overlay_tests
|
2006-12-14 05:29:25 +01:00
|
|
|
|
2008-02-18 06:09:25 +01:00
|
|
|
for basetree in test_tree1.dtb sw_tree1.test.dtb rw_tree1.test.dtb; do
|
|
|
|
run_test nopulate $basetree
|
|
|
|
run_test dtbs_equal_ordered $basetree noppy.$basetree
|
|
|
|
tree1_tests noppy.$basetree
|
|
|
|
tree1_tests_rw noppy.$basetree
|
|
|
|
done
|
|
|
|
|
2019-05-09 11:41:20 +02:00
|
|
|
run_test rw_oom
|
|
|
|
|
2019-10-09 12:20:17 +02:00
|
|
|
run_dtc_test -I dts -O dtb -o subnode_iterate.dtb "$SRCDIR/subnode_iterate.dts"
|
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>
2013-04-26 14:43:31 +02:00
|
|
|
run_test subnode_iterate subnode_iterate.dtb
|
|
|
|
|
2019-10-09 12:20:17 +02:00
|
|
|
run_dtc_test -I dts -O dtb -o property_iterate.dtb "$SRCDIR/property_iterate.dts"
|
2016-07-27 14:55:54 +02:00
|
|
|
run_test property_iterate property_iterate.dtb
|
|
|
|
|
2019-10-09 12:20:17 +02:00
|
|
|
run_dtc_test -I dts -O dtb -o unit-addr-without-reg.dtb "$SRCDIR/unit-addr-without-reg.dts"
|
2019-03-27 07:15:52 +01:00
|
|
|
run_test appendprop_addrrange unit-addr-without-reg.dtb 1 1 1
|
|
|
|
run_test appendprop_addrrange unit-addr-without-reg.dtb 2 2 2
|
|
|
|
run_test appendprop_addrrange unit-addr-without-reg.dtb 2 1 3
|
|
|
|
|
2006-12-14 05:29:25 +01:00
|
|
|
# Tests for behaviour on various sorts of corrupted trees
|
|
|
|
run_test truncated_property
|
2017-11-14 12:45:56 +01:00
|
|
|
run_test truncated_string
|
2018-03-09 13:28:56 +01:00
|
|
|
run_test truncated_memrsv
|
2008-02-14 06:50:34 +01:00
|
|
|
|
2015-07-09 05:29:42 +02:00
|
|
|
# Check aliases support in fdt_path_offset
|
2019-10-09 12:20:17 +02:00
|
|
|
run_dtc_test -I dts -O dtb -o aliases.dtb "$SRCDIR/aliases.dts"
|
2015-07-09 05:29:42 +02:00
|
|
|
run_test get_alias aliases.dtb
|
|
|
|
run_test path_offset_aliases aliases.dtb
|
|
|
|
|
2008-02-14 06:50:34 +01:00
|
|
|
# Specific bug tests
|
|
|
|
run_test add_subnode_with_nops
|
2019-10-09 12:20:17 +02:00
|
|
|
run_dtc_test -I dts -O dts -o sourceoutput.test.dts "$SRCDIR/sourceoutput.dts"
|
|
|
|
run_dtc_test -I dts -O dtb -o sourceoutput.test.dtb "$SRCDIR/sourceoutput.dts"
|
2014-06-18 14:49:43 +02:00
|
|
|
run_dtc_test -I dts -O dtb -o sourceoutput.test.dts.test.dtb sourceoutput.test.dts
|
|
|
|
run_test dtbs_equal_ordered sourceoutput.test.dtb sourceoutput.test.dts.test.dtb
|
2014-08-06 22:52:03 +02:00
|
|
|
|
2019-10-09 12:20:17 +02:00
|
|
|
run_dtc_test -I dts -O dtb -o embedded_nul.test.dtb "$SRCDIR/embedded_nul.dts"
|
|
|
|
run_dtc_test -I dts -O dtb -o embedded_nul_equiv.test.dtb "$SRCDIR/embedded_nul_equiv.dts"
|
2014-08-06 22:52:03 +02:00
|
|
|
run_test dtbs_equal_ordered embedded_nul.test.dtb embedded_nul_equiv.test.dtb
|
2015-04-29 21:02:24 +02:00
|
|
|
|
2019-10-09 12:20:17 +02:00
|
|
|
run_dtc_test -I dts -O dtb "$SRCDIR/bad-size-cells.dts"
|
2016-01-03 12:27:32 +01:00
|
|
|
|
|
|
|
run_wrap_error_test $DTC division-by-zero.dts
|
2016-01-03 12:54:37 +01:00
|
|
|
run_wrap_error_test $DTC bad-octal-literal.dts
|
2019-10-09 12:20:17 +02:00
|
|
|
run_dtc_test -I dts -O dtb "$SRCDIR/nul-in-escape.dts"
|
2016-01-04 12:56:39 +01:00
|
|
|
run_wrap_error_test $DTC nul-in-line-info1.dts
|
|
|
|
run_wrap_error_test $DTC nul-in-line-info2.dts
|
2016-01-02 22:43:35 +01:00
|
|
|
|
|
|
|
run_wrap_error_test $DTC -I dtb -O dts -o /dev/null ovf_size_strings.dtb
|
2017-10-23 05:45:56 +02:00
|
|
|
|
|
|
|
run_test check_header test_tree1.dtb
|
2018-03-17 14:12:12 +01:00
|
|
|
|
2018-09-10 04:59:53 +02:00
|
|
|
FSBASE=fs
|
|
|
|
rm -rf $FSBASE
|
|
|
|
mkdir -p $FSBASE
|
|
|
|
run_test fs_tree1 $FSBASE/test_tree1
|
|
|
|
run_dtc_test -I fs -O dts -o fs.test_tree1.test.dts $FSBASE/test_tree1
|
|
|
|
run_dtc_test -I fs -O dtb -o fs.test_tree1.test.dtb $FSBASE/test_tree1
|
|
|
|
run_test dtbs_equal_unordered -m fs.test_tree1.test.dtb test_tree1.dtb
|
2018-09-03 10:50:36 +02:00
|
|
|
|
2021-12-29 05:08:28 +01:00
|
|
|
## https://github.com/dgibson/dtc/issues/64
|
|
|
|
check_tests "$SRCDIR/phandle-args-overflow.dts" clocks_property
|
|
|
|
|
2018-03-17 14:12:12 +01:00
|
|
|
# check full tests
|
|
|
|
for good in test_tree1.dtb; do
|
|
|
|
run_test check_full $good
|
|
|
|
done
|
|
|
|
for bad in truncated_property.dtb truncated_string.dtb \
|
2021-03-23 02:04:10 +01:00
|
|
|
truncated_memrsv.dtb two_roots.dtb named_root.dtb; do
|
2018-03-17 14:12:12 +01:00
|
|
|
run_test check_full -n $bad
|
|
|
|
done
|
2006-11-27 06:21:28 +01:00
|
|
|
}
|
|
|
|
|
2007-09-18 02:33:40 +02:00
|
|
|
dtc_tests () {
|
2019-10-09 12:20:17 +02:00
|
|
|
run_dtc_test -I dts -O dtb -o dtc_tree1.test.dtb "$SRCDIR/test_tree1.dts"
|
2007-09-18 02:33:40 +02:00
|
|
|
tree1_tests dtc_tree1.test.dtb
|
2007-09-28 06:57:01 +02:00
|
|
|
tree1_tests_rw dtc_tree1.test.dtb
|
2007-10-24 03:06:09 +02:00
|
|
|
run_test dtbs_equal_ordered dtc_tree1.test.dtb test_tree1.dtb
|
2007-10-16 08:42:02 +02:00
|
|
|
|
2019-10-09 12:20:17 +02:00
|
|
|
run_dtc_test -I dts -O dtb -o dtc_escapes.test.dtb "$SRCDIR/propname_escapes.dts"
|
2012-09-28 01:11:04 +02:00
|
|
|
run_test propname_escapes dtc_escapes.test.dtb
|
|
|
|
|
2019-10-09 12:20:17 +02:00
|
|
|
run_dtc_test -I dts -O dtb -o line_directives.test.dtb "$SRCDIR/line_directives.dts"
|
2012-09-28 01:11:05 +02:00
|
|
|
|
2019-10-09 12:20:17 +02:00
|
|
|
run_dtc_test -I dts -O dtb -o dtc_escapes.test.dtb "$SRCDIR/escapes.dts"
|
2007-10-16 08:42:02 +02:00
|
|
|
run_test string_escapes dtc_escapes.test.dtb
|
2011-09-09 21:16:30 +02:00
|
|
|
|
2019-10-09 12:20:17 +02:00
|
|
|
run_dtc_test -I dts -O dtb -o dtc_char_literal.test.dtb "$SRCDIR/char_literal.dts"
|
2011-09-09 21:16:30 +02:00
|
|
|
run_test char_literal dtc_char_literal.test.dtb
|
2007-11-07 00:34:06 +01:00
|
|
|
|
2019-10-09 12:20:17 +02:00
|
|
|
run_dtc_test -I dts -O dtb -o dtc_sized_cells.test.dtb "$SRCDIR/sized_cells.dts"
|
2011-10-11 19:22:29 +02:00
|
|
|
run_test sized_cells dtc_sized_cells.test.dtb
|
|
|
|
|
2019-10-09 12:20:17 +02:00
|
|
|
run_dtc_test -I dts -O dtb -o dtc_extra-terminating-null.test.dtb "$SRCDIR/extra-terminating-null.dts"
|
2009-09-09 06:38:30 +02:00
|
|
|
run_test extra-terminating-null dtc_extra-terminating-null.test.dtb
|
|
|
|
|
2019-10-09 12:20:17 +02:00
|
|
|
run_dtc_test -I dts -O dtb -o dtc_references.test.dtb "$SRCDIR/references.dts"
|
2007-11-12 23:59:38 +01:00
|
|
|
run_test references dtc_references.test.dtb
|
|
|
|
|
2019-10-09 12:20:17 +02:00
|
|
|
run_dtc_test -I dts -O dtb -o dtc_path-references.test.dtb "$SRCDIR/path-references.dts"
|
2007-12-05 00:43:50 +01:00
|
|
|
run_test path-references dtc_path-references.test.dtb
|
|
|
|
|
2017-07-13 00:20:30 +02:00
|
|
|
run_test phandle_format dtc_references.test.dtb epapr
|
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>
2009-11-26 05:37:13 +01:00
|
|
|
for f in legacy epapr both; do
|
2019-10-09 12:20:17 +02:00
|
|
|
run_dtc_test -I dts -O dtb -H $f -o dtc_references.test.$f.dtb "$SRCDIR/references.dts"
|
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>
2009-11-26 05:37:13 +01:00
|
|
|
run_test phandle_format dtc_references.test.$f.dtb $f
|
|
|
|
done
|
|
|
|
|
2019-10-09 12:20:17 +02:00
|
|
|
run_dtc_test -I dts -O dtb -o multilabel.test.dtb "$SRCDIR/multilabel.dts"
|
2010-02-24 08:22:17 +01:00
|
|
|
run_test references multilabel.test.dtb
|
|
|
|
|
2019-10-09 12:20:17 +02:00
|
|
|
run_dtc_test -I dts -O dtb -o label_repeated.test.dtb "$SRCDIR/label_repeated.dts"
|
2012-07-03 22:09:30 +02:00
|
|
|
|
2019-10-09 12:20:17 +02:00
|
|
|
run_dtc_test -I dts -O dtb -o dtc_comments.test.dtb "$SRCDIR/comments.dts"
|
|
|
|
run_dtc_test -I dts -O dtb -o dtc_comments-cmp.test.dtb "$SRCDIR/comments-cmp.dts"
|
2008-02-15 05:14:16 +01:00
|
|
|
run_test dtbs_equal_ordered dtc_comments.test.dtb dtc_comments-cmp.test.dtb
|
|
|
|
|
2008-06-24 03:21:44 +02:00
|
|
|
# Check /include/ directive
|
2019-10-09 12:20:17 +02:00
|
|
|
run_dtc_test -I dts -O dtb -o includes.test.dtb "$SRCDIR/include0.dts"
|
2008-06-24 03:21:44 +02:00
|
|
|
run_test dtbs_equal_ordered includes.test.dtb test_tree1.dtb
|
|
|
|
|
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>
2008-06-11 03:58:39 +02:00
|
|
|
# Check /incbin/ directive
|
2019-10-09 12:20:17 +02:00
|
|
|
run_dtc_test -I dts -O dtb -o incbin.test.dtb "$SRCDIR/incbin.dts"
|
|
|
|
run_test incbin "$SRCDIR/incbin.bin" incbin.test.dtb
|
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>
2008-06-11 03:58:39 +02:00
|
|
|
|
2008-05-16 05:22:57 +02:00
|
|
|
# Check boot_cpuid_phys handling
|
2019-10-09 12:20:17 +02:00
|
|
|
run_dtc_test -I dts -O dtb -o boot_cpuid.test.dtb "$SRCDIR/boot-cpuid.dts"
|
2010-02-19 05:50:50 +01:00
|
|
|
run_test boot-cpuid boot_cpuid.test.dtb 16
|
|
|
|
|
2019-10-09 12:20:17 +02:00
|
|
|
run_dtc_test -I dts -O dtb -b 17 -o boot_cpuid_17.test.dtb "$SRCDIR/boot-cpuid.dts"
|
2010-02-19 05:50:50 +01:00
|
|
|
run_test boot-cpuid boot_cpuid_17.test.dtb 17
|
|
|
|
|
|
|
|
run_dtc_test -I dtb -O dtb -o preserve_boot_cpuid.test.dtb boot_cpuid.test.dtb
|
|
|
|
run_test boot-cpuid preserve_boot_cpuid.test.dtb 16
|
|
|
|
run_test dtbs_equal_ordered preserve_boot_cpuid.test.dtb boot_cpuid.test.dtb
|
|
|
|
|
|
|
|
run_dtc_test -I dtb -O dtb -o preserve_boot_cpuid_17.test.dtb boot_cpuid_17.test.dtb
|
|
|
|
run_test boot-cpuid preserve_boot_cpuid_17.test.dtb 17
|
|
|
|
run_test dtbs_equal_ordered preserve_boot_cpuid_17.test.dtb boot_cpuid_17.test.dtb
|
|
|
|
|
|
|
|
run_dtc_test -I dtb -O dtb -b17 -o override17_boot_cpuid.test.dtb boot_cpuid.test.dtb
|
|
|
|
run_test boot-cpuid override17_boot_cpuid.test.dtb 17
|
|
|
|
|
|
|
|
run_dtc_test -I dtb -O dtb -b0 -o override0_boot_cpuid_17.test.dtb boot_cpuid_17.test.dtb
|
|
|
|
run_test boot-cpuid override0_boot_cpuid_17.test.dtb 0
|
|
|
|
|
2008-05-16 05:22:57 +02:00
|
|
|
|
2009-01-08 01:47:55 +01:00
|
|
|
# Check -Oasm mode
|
|
|
|
for tree in test_tree1.dts escapes.dts references.dts path-references.dts \
|
2009-01-08 01:48:48 +01:00
|
|
|
comments.dts aliases.dts include0.dts incbin.dts \
|
|
|
|
value-labels.dts ; do
|
2019-10-09 12:20:17 +02:00
|
|
|
run_dtc_test -I dts -O asm -o oasm_$tree.test.s "$SRCDIR/$tree"
|
2009-01-08 01:47:55 +01:00
|
|
|
asm_to_so_test oasm_$tree
|
2019-10-09 12:20:17 +02:00
|
|
|
run_dtc_test -I dts -O dtb -o $tree.test.dtb "$SRCDIR/$tree"
|
2009-01-08 01:47:55 +01:00
|
|
|
run_test asm_tree_dump ./oasm_$tree.test.so oasm_$tree.test.dtb
|
|
|
|
run_wrap_test cmp oasm_$tree.test.dtb $tree.test.dtb
|
|
|
|
done
|
|
|
|
|
2009-01-08 01:48:48 +01:00
|
|
|
run_test value-labels ./oasm_value-labels.dts.test.so
|
|
|
|
|
2007-11-07 00:34:06 +01:00
|
|
|
# Check -Odts mode preserve all dtb information
|
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>
2008-11-07 02:49:44 +01:00
|
|
|
for tree in test_tree1.dtb dtc_tree1.test.dtb dtc_escapes.test.dtb \
|
2009-09-09 06:38:30 +02:00
|
|
|
dtc_extra-terminating-null.test.dtb dtc_references.test.dtb; do
|
2008-03-05 06:01:55 +01:00
|
|
|
run_dtc_test -I dtb -O dts -o odts_$tree.test.dts $tree
|
|
|
|
run_dtc_test -I dts -O dtb -o odts_$tree.test.dtb odts_$tree.test.dts
|
2007-11-07 00:34:06 +01:00
|
|
|
run_test dtbs_equal_ordered $tree odts_$tree.test.dtb
|
|
|
|
done
|
2007-11-12 23:59:38 +01:00
|
|
|
|
2018-06-28 23:37:01 +02:00
|
|
|
# Check -Odts preserving type information
|
|
|
|
for tree in type-preservation.dts; do
|
2019-10-09 12:20:17 +02:00
|
|
|
run_dtc_test -I dts -O dts -o $tree.test.dts "$SRCDIR/$tree"
|
2018-06-28 23:37:01 +02:00
|
|
|
run_dtc_test -I dts -O dts $tree.test.dts
|
2019-10-09 12:20:17 +02:00
|
|
|
run_wrap_test cmp "$SRCDIR/$tree" $tree.test.dts
|
2018-06-28 23:37:01 +02:00
|
|
|
done
|
2018-09-26 21:27:08 +02:00
|
|
|
for tree in path-references; do
|
2019-10-09 12:20:17 +02:00
|
|
|
run_dtc_test -I dts -O dtb -o $tree.test.dtb "$SRCDIR/$tree.dts"
|
|
|
|
run_dtc_test -I dts -O dts -o $tree.test.dts "$SRCDIR/$tree.dts"
|
2018-09-26 21:27:08 +02:00
|
|
|
run_dtc_test -I dts -O dtb -o $tree.test.dts.test.dtb $tree.test.dts
|
|
|
|
run_test dtbs_equal_ordered $tree.test.dtb $tree.test.dts.test.dtb
|
|
|
|
done
|
2018-06-28 23:37:01 +02:00
|
|
|
|
2018-09-11 22:41:31 +02:00
|
|
|
# Check -Oyaml output
|
2020-03-04 06:10:06 +01:00
|
|
|
if ! $no_yaml; then
|
2018-09-11 22:41:31 +02:00
|
|
|
for tree in type-preservation; do
|
2019-10-09 12:20:17 +02:00
|
|
|
run_dtc_test -I dts -O yaml -o $tree.test.dt.yaml "$SRCDIR/$tree.dts"
|
|
|
|
run_wrap_test cmp "$SRCDIR/$tree.dt.yaml" $tree.test.dt.yaml
|
2018-09-11 22:41:31 +02:00
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
2008-02-28 10:55:37 +01:00
|
|
|
# Check version conversions
|
|
|
|
for tree in test_tree1.dtb ; do
|
|
|
|
for aver in 1 2 3 16 17; do
|
|
|
|
atree="ov${aver}_$tree.test.dtb"
|
2008-03-05 06:01:55 +01:00
|
|
|
run_dtc_test -I dtb -O dtb -V$aver -o $atree $tree
|
2008-02-28 10:55:37 +01:00
|
|
|
for bver in 16 17; do
|
|
|
|
btree="ov${bver}_$atree"
|
2008-03-05 06:01:55 +01:00
|
|
|
run_dtc_test -I dtb -O dtb -V$bver -o $btree $atree
|
2008-02-28 10:55:37 +01:00
|
|
|
run_test dtbs_equal_ordered $btree $tree
|
|
|
|
done
|
|
|
|
done
|
|
|
|
done
|
|
|
|
|
2010-02-25 17:58:29 +01:00
|
|
|
# Check merge/overlay functionality
|
2019-10-09 12:20:17 +02:00
|
|
|
run_dtc_test -I dts -O dtb -o dtc_tree1_merge.test.dtb "$SRCDIR/test_tree1_merge.dts"
|
2010-02-25 17:58:29 +01:00
|
|
|
tree1_tests dtc_tree1_merge.test.dtb test_tree1.dtb
|
2019-10-09 12:20:17 +02:00
|
|
|
run_dtc_test -I dts -O dtb -o dtc_tree1_merge_labelled.test.dtb "$SRCDIR/test_tree1_merge_labelled.dts"
|
2010-09-21 00:33:34 +02:00
|
|
|
tree1_tests dtc_tree1_merge_labelled.test.dtb test_tree1.dtb
|
2019-10-09 12:20:17 +02:00
|
|
|
run_dtc_test -I dts -O dtb -o dtc_tree1_label_noderef.test.dtb "$SRCDIR/test_tree1_label_noderef.dts"
|
2015-02-23 02:29:19 +01:00
|
|
|
run_test dtbs_equal_unordered dtc_tree1_label_noderef.test.dtb test_tree1.dtb
|
2019-10-09 12:20:17 +02:00
|
|
|
run_dtc_test -I dts -O dtb -o multilabel_merge.test.dtb "$SRCDIR/multilabel_merge.dts"
|
2010-02-25 17:58:29 +01:00
|
|
|
run_test references multilabel.test.dtb
|
|
|
|
run_test dtbs_equal_ordered multilabel.test.dtb multilabel_merge.test.dtb
|
2019-10-09 12:20:17 +02:00
|
|
|
run_dtc_test -I dts -O dtb -o dtc_tree1_merge_path.test.dtb "$SRCDIR/test_tree1_merge_path.dts"
|
2010-11-02 23:55:04 +01:00
|
|
|
tree1_tests dtc_tree1_merge_path.test.dtb test_tree1.dtb
|
2019-10-09 12:20:17 +02:00
|
|
|
run_wrap_error_test $DTC -I dts -O dtb -o /dev/null "$SRCDIR/test_label_ref.dts"
|
2010-02-25 17:58:29 +01:00
|
|
|
|
2012-08-08 06:50:15 +02:00
|
|
|
# Check prop/node delete functionality
|
2019-10-09 12:20:17 +02:00
|
|
|
run_dtc_test -I dts -O dtb -o dtc_tree1_delete.test.dtb "$SRCDIR/test_tree1_delete.dts"
|
2012-08-08 06:50:15 +02:00
|
|
|
tree1_tests dtc_tree1_delete.test.dtb
|
|
|
|
|
2018-05-03 22:27:27 +02:00
|
|
|
# Check omit-if-no-ref functionality
|
2019-10-09 12:20:17 +02:00
|
|
|
run_dtc_test -I dts -O dtb -o omit-no-ref.test.dtb "$SRCDIR/omit-no-ref.dts"
|
2018-05-03 22:27:27 +02:00
|
|
|
run_test check_path omit-no-ref.test.dtb not-exists "/node1"
|
|
|
|
run_test check_path omit-no-ref.test.dtb not-exists "/node2"
|
|
|
|
run_test check_path omit-no-ref.test.dtb exists "/node3"
|
|
|
|
run_test check_path omit-no-ref.test.dtb exists "/node4"
|
|
|
|
|
2019-10-09 12:20:17 +02:00
|
|
|
run_dtc_test -I dts -O dts -o delete_reinstate_multilabel.dts.test.dts "$SRCDIR/delete_reinstate_multilabel.dts"
|
|
|
|
run_wrap_test cmp delete_reinstate_multilabel.dts.test.dts "$SRCDIR/delete_reinstate_multilabel_ref.dts"
|
2012-10-05 17:57:41 +02:00
|
|
|
|
2007-11-20 06:24:23 +01:00
|
|
|
# Check some checks
|
2019-10-09 12:20:17 +02:00
|
|
|
check_tests "$SRCDIR/dup-nodename.dts" duplicate_node_names
|
|
|
|
check_tests "$SRCDIR/dup-propname.dts" duplicate_property_names
|
|
|
|
check_tests "$SRCDIR/dup-phandle.dts" explicit_phandles
|
|
|
|
check_tests "$SRCDIR/zero-phandle.dts" explicit_phandles
|
|
|
|
check_tests "$SRCDIR/minusone-phandle.dts" explicit_phandles
|
|
|
|
run_sh_test "$SRCDIR/dtc-checkfails.sh" phandle_references -- -I dts -O dtb "$SRCDIR/nonexist-node-ref.dts"
|
|
|
|
run_sh_test "$SRCDIR/dtc-checkfails.sh" phandle_references -- -I dts -O dtb "$SRCDIR/nonexist-label-ref.dts"
|
|
|
|
run_sh_test "$SRCDIR/dtc-fatal.sh" -I dts -O dtb "$SRCDIR/nonexist-node-ref2.dts"
|
|
|
|
check_tests "$SRCDIR/bad-name-property.dts" name_properties
|
|
|
|
|
2021-05-26 03:03:33 +02:00
|
|
|
check_tests "$SRCDIR/bad-ncells.dts" address_cells_is_cell size_cells_is_cell interrupts_extended_is_cell
|
2019-10-09 12:20:17 +02:00
|
|
|
check_tests "$SRCDIR/bad-string-props.dts" device_type_is_string model_is_string status_is_string label_is_string compatible_is_string_list names_is_string_list
|
|
|
|
check_tests "$SRCDIR/bad-chosen.dts" chosen_node_is_root
|
|
|
|
check_tests "$SRCDIR/bad-chosen.dts" chosen_node_bootargs
|
|
|
|
check_tests "$SRCDIR/bad-chosen.dts" chosen_node_stdout_path
|
|
|
|
check_tests "$SRCDIR/bad-reg-ranges.dts" reg_format ranges_format
|
|
|
|
check_tests "$SRCDIR/bad-empty-ranges.dts" ranges_format
|
|
|
|
check_tests "$SRCDIR/reg-ranges-root.dts" reg_format ranges_format
|
2020-03-03 20:39:31 +01:00
|
|
|
check_tests "$SRCDIR/bad-dma-ranges.dts" dma_ranges_format
|
2019-10-09 12:20:17 +02:00
|
|
|
check_tests "$SRCDIR/default-addr-size.dts" avoid_default_addr_size
|
|
|
|
check_tests "$SRCDIR/obsolete-chosen-interrupt-controller.dts" obsolete_chosen_interrupt_controller
|
|
|
|
check_tests "$SRCDIR/reg-without-unit-addr.dts" unit_address_vs_reg
|
|
|
|
check_tests "$SRCDIR/unit-addr-without-reg.dts" unit_address_vs_reg
|
|
|
|
check_tests "$SRCDIR/unit-addr-leading-0x.dts" unit_address_format
|
|
|
|
check_tests "$SRCDIR/unit-addr-leading-0s.dts" unit_address_format
|
|
|
|
check_tests "$SRCDIR/unit-addr-unique.dts" unique_unit_address
|
|
|
|
check_tests "$SRCDIR/bad-phandle-cells.dts" interrupts_extended_property
|
|
|
|
check_tests "$SRCDIR/bad-gpio.dts" gpios_property
|
2021-05-04 05:59:44 +02:00
|
|
|
check_tests "$SRCDIR/good-gpio.dts" -n gpios_property
|
2019-10-09 12:20:17 +02:00
|
|
|
check_tests "$SRCDIR/bad-graph.dts" graph_child_address
|
|
|
|
check_tests "$SRCDIR/bad-graph.dts" graph_port
|
|
|
|
check_tests "$SRCDIR/bad-graph.dts" graph_endpoint
|
|
|
|
run_sh_test "$SRCDIR/dtc-checkfails.sh" deprecated_gpio_property -- -Wdeprecated_gpio_property -I dts -O dtb "$SRCDIR/bad-gpio.dts"
|
2021-05-04 05:59:44 +02:00
|
|
|
run_sh_test "$SRCDIR/dtc-checkfails.sh" -n deprecated_gpio_property -- -Wdeprecated_gpio_property -I dts -O dtb "$SRCDIR/good-gpio.dts"
|
2019-10-09 12:20:17 +02:00
|
|
|
check_tests "$SRCDIR/bad-interrupt-cells.dts" interrupts_property
|
2020-05-15 16:18:25 +02:00
|
|
|
check_tests "$SRCDIR/bad-interrupt-controller.dts" interrupt_provider
|
2021-10-15 23:35:26 +02:00
|
|
|
check_tests "$SRCDIR/bad-interrupt-map.dts" interrupt_map
|
|
|
|
check_tests "$SRCDIR/bad-interrupt-map-parent.dts" interrupt_map
|
|
|
|
check_tests "$SRCDIR/bad-interrupt-map-mask.dts" interrupt_map
|
2019-10-09 12:20:17 +02:00
|
|
|
run_sh_test "$SRCDIR/dtc-checkfails.sh" node_name_chars -- -I dtb -O dtb bad_node_char.dtb
|
|
|
|
run_sh_test "$SRCDIR/dtc-checkfails.sh" node_name_format -- -I dtb -O dtb bad_node_format.dtb
|
|
|
|
run_sh_test "$SRCDIR/dtc-checkfails.sh" property_name_chars -- -I dtb -O dtb bad_prop_char.dtb
|
|
|
|
|
|
|
|
run_sh_test "$SRCDIR/dtc-checkfails.sh" duplicate_label -- -I dts -O dtb "$SRCDIR/reuse-label1.dts"
|
|
|
|
run_sh_test "$SRCDIR/dtc-checkfails.sh" duplicate_label -- -I dts -O dtb "$SRCDIR/reuse-label2.dts"
|
|
|
|
run_sh_test "$SRCDIR/dtc-checkfails.sh" duplicate_label -- -I dts -O dtb "$SRCDIR/reuse-label3.dts"
|
|
|
|
run_sh_test "$SRCDIR/dtc-checkfails.sh" duplicate_label -- -I dts -O dtb "$SRCDIR/reuse-label4.dts"
|
|
|
|
run_sh_test "$SRCDIR/dtc-checkfails.sh" duplicate_label -- -I dts -O dtb "$SRCDIR/reuse-label5.dts"
|
|
|
|
run_sh_test "$SRCDIR/dtc-checkfails.sh" duplicate_label -- -I dts -O dtb "$SRCDIR/reuse-label6.dts"
|
2010-02-23 09:56:41 +01:00
|
|
|
|
2016-12-07 13:48:19 +01:00
|
|
|
run_test check_path test_tree1.dtb exists "/subnode@1"
|
|
|
|
run_test check_path test_tree1.dtb not-exists "/subnode@10"
|
|
|
|
|
2019-10-09 12:20:17 +02:00
|
|
|
check_tests "$SRCDIR/pci-bridge-ok.dts" -n pci_bridge
|
|
|
|
check_tests "$SRCDIR/pci-bridge-bad1.dts" pci_bridge
|
|
|
|
check_tests "$SRCDIR/pci-bridge-bad2.dts" pci_bridge
|
2017-11-11 07:52:50 +01:00
|
|
|
|
2019-10-09 12:20:17 +02:00
|
|
|
check_tests "$SRCDIR/unit-addr-simple-bus-reg-mismatch.dts" simple_bus_reg
|
|
|
|
check_tests "$SRCDIR/unit-addr-simple-bus-compatible.dts" simple_bus_reg
|
2018-09-20 23:30:03 +02:00
|
|
|
|
|
|
|
|
2012-07-08 15:25:22 +02:00
|
|
|
# Check warning options
|
2021-05-26 03:03:33 +02:00
|
|
|
run_sh_test "$SRCDIR/dtc-checkfails.sh" address_cells_is_cell interrupts_extended_is_cell -n size_cells_is_cell -- -Wno_size_cells_is_cell -I dts -O dtb "$SRCDIR/bad-ncells.dts"
|
2019-10-09 12:20:17 +02:00
|
|
|
run_sh_test "$SRCDIR/dtc-fails.sh" -n test-warn-output.test.dtb -I dts -O dtb "$SRCDIR/bad-ncells.dts"
|
|
|
|
run_sh_test "$SRCDIR/dtc-fails.sh" test-error-output.test.dtb -I dts -O dtb bad-ncells.dts -Esize_cells_is_cell
|
|
|
|
run_sh_test "$SRCDIR/dtc-checkfails.sh" always_fail -- -Walways_fail -I dts -O dtb "$SRCDIR/test_tree1.dts"
|
|
|
|
run_sh_test "$SRCDIR/dtc-checkfails.sh" -n always_fail -- -Walways_fail -Wno_always_fail -I dts -O dtb "$SRCDIR/test_tree1.dts"
|
|
|
|
run_sh_test "$SRCDIR/dtc-fails.sh" test-negation-1.test.dtb -Ealways_fail -I dts -O dtb "$SRCDIR/test_tree1.dts"
|
|
|
|
run_sh_test "$SRCDIR/dtc-fails.sh" -n test-negation-2.test.dtb -Ealways_fail -Eno_always_fail -I dts -O dtb "$SRCDIR/test_tree1.dts"
|
|
|
|
run_sh_test "$SRCDIR/dtc-fails.sh" test-negation-3.test.dtb -Ealways_fail -Wno_always_fail -I dts -O dtb "$SRCDIR/test_tree1.dts"
|
|
|
|
run_sh_test "$SRCDIR/dtc-fails.sh" -n test-negation-4.test.dtb -Esize_cells_is_cell -Eno_size_cells_is_cell -I dts -O dtb "$SRCDIR/bad-ncells.dts"
|
|
|
|
run_sh_test "$SRCDIR/dtc-checkfails.sh" size_cells_is_cell -- -Esize_cells_is_cell -Eno_size_cells_is_cell -I dts -O dtb "$SRCDIR/bad-ncells.dts"
|
2012-07-08 15:25:22 +02:00
|
|
|
|
2008-03-05 06:22:41 +01:00
|
|
|
# Check for proper behaviour reading from stdin
|
2019-10-09 12:20:17 +02:00
|
|
|
run_dtc_test -I dts -O dtb -o stdin_dtc_tree1.test.dtb - < "$SRCDIR/test_tree1.dts"
|
2008-03-05 06:22:41 +01:00
|
|
|
run_wrap_test cmp stdin_dtc_tree1.test.dtb dtc_tree1.test.dtb
|
|
|
|
run_dtc_test -I dtb -O dts -o stdin_odts_test_tree1.dtb.test.dts - < test_tree1.dtb
|
|
|
|
run_wrap_test cmp stdin_odts_test_tree1.dtb.test.dts odts_test_tree1.dtb.test.dts
|
|
|
|
|
2012-04-04 04:56:00 +02:00
|
|
|
# Check integer expresisons
|
|
|
|
run_test integer-expressions -g integer-expressions.test.dts
|
|
|
|
run_dtc_test -I dts -O dtb -o integer-expressions.test.dtb integer-expressions.test.dts
|
|
|
|
run_test integer-expressions integer-expressions.test.dtb
|
|
|
|
|
2008-03-05 06:22:41 +01:00
|
|
|
# Check for graceful failure in some error conditions
|
2019-10-09 12:20:17 +02:00
|
|
|
run_sh_test "$SRCDIR/dtc-fatal.sh" -I dts -O dtb nosuchfile.dts
|
|
|
|
run_sh_test "$SRCDIR/dtc-fatal.sh" -I dtb -O dtb nosuchfile.dtb
|
|
|
|
run_sh_test "$SRCDIR/dtc-fatal.sh" -I fs -O dtb nosuchfile
|
2012-01-12 19:31:00 +01:00
|
|
|
|
|
|
|
# Dependencies
|
2019-10-09 12:20:17 +02:00
|
|
|
run_dtc_test -I dts -O dtb -o dependencies.test.dtb -d dependencies.test.d "$SRCDIR/dependencies.dts"
|
2019-11-14 21:36:15 +01:00
|
|
|
sed -i.bak "s,$SRCDIR/,,g" dependencies.test.d
|
2019-10-09 12:20:17 +02:00
|
|
|
run_wrap_test cmp dependencies.test.d "$SRCDIR/dependencies.cmp"
|
2012-03-15 04:04:13 +01:00
|
|
|
|
|
|
|
# Search paths
|
2019-10-09 12:20:17 +02:00
|
|
|
run_wrap_error_test $DTC -I dts -O dtb -o search_paths.dtb "$SRCDIR/search_paths.dts"
|
|
|
|
run_dtc_test -i "$SRCDIR/search_dir" -I dts -O dtb -o search_paths.dtb \
|
|
|
|
"$SRCDIR/search_paths.dts"
|
|
|
|
run_wrap_error_test $DTC -i "$SRCDIR/search_dir_b" -I dts -O dtb \
|
|
|
|
-o search_paths_b.dtb "$SRCDIR/search_paths_b.dts"
|
|
|
|
run_dtc_test -i "$SRCDIR/search_dir_b" -i "$SRCDIR/search_dir" -I dts -O dtb \
|
|
|
|
-o search_paths_b.dtb "$SRCDIR/search_paths_b.dts"
|
2012-03-15 04:04:13 +01:00
|
|
|
run_dtc_test -I dts -O dtb -o search_paths_subdir.dtb \
|
2019-10-09 12:20:17 +02:00
|
|
|
"$SRCDIR/search_dir_b/search_paths_subdir.dts"
|
2016-07-18 09:56:53 +02:00
|
|
|
|
|
|
|
# Check -a option
|
2016-09-22 06:42:42 +02:00
|
|
|
for align in 2 4 8 16 32 64; do
|
|
|
|
# -p -a
|
2019-10-09 12:20:17 +02:00
|
|
|
run_dtc_test -O dtb -p 1000 -a $align -o align0.dtb "$SRCDIR/subnode_iterate.dts"
|
2018-10-03 15:12:11 +02:00
|
|
|
base_run_test check_align align0.dtb $align
|
2016-09-22 06:42:42 +02:00
|
|
|
# -S -a
|
2019-10-09 12:20:17 +02:00
|
|
|
run_dtc_test -O dtb -S 1999 -a $align -o align1.dtb "$SRCDIR/subnode_iterate.dts"
|
2018-10-03 15:12:11 +02:00
|
|
|
base_run_test check_align align1.dtb $align
|
2016-09-22 06:42:42 +02:00
|
|
|
done
|
2016-12-09 04:19:21 +01:00
|
|
|
|
|
|
|
# Tests for overlay/plugin generation
|
|
|
|
dtc_overlay_tests
|
2007-09-18 02:33:40 +02:00
|
|
|
}
|
|
|
|
|
2010-04-30 07:30:00 +02:00
|
|
|
cmp_tests () {
|
|
|
|
basetree="$1"
|
|
|
|
shift
|
|
|
|
wrongtrees="$@"
|
|
|
|
|
|
|
|
run_test dtb_reverse $basetree
|
|
|
|
|
|
|
|
# First dtbs_equal_ordered
|
|
|
|
run_test dtbs_equal_ordered $basetree $basetree
|
|
|
|
run_test dtbs_equal_ordered -n $basetree $basetree.reversed.test.dtb
|
|
|
|
for tree in $wrongtrees; do
|
|
|
|
run_test dtbs_equal_ordered -n $basetree $tree
|
|
|
|
done
|
|
|
|
|
|
|
|
# now unordered
|
|
|
|
run_test dtbs_equal_unordered $basetree $basetree
|
|
|
|
run_test dtbs_equal_unordered $basetree $basetree.reversed.test.dtb
|
|
|
|
run_test dtbs_equal_unordered $basetree.reversed.test.dtb $basetree
|
|
|
|
for tree in $wrongtrees; do
|
|
|
|
run_test dtbs_equal_unordered -n $basetree $tree
|
|
|
|
done
|
2010-11-09 23:51:09 +01:00
|
|
|
|
|
|
|
# now dtc --sort
|
|
|
|
run_dtc_test -I dtb -O dtb -s -o $basetree.sorted.test.dtb $basetree
|
|
|
|
run_test dtbs_equal_unordered $basetree $basetree.sorted.test.dtb
|
|
|
|
run_dtc_test -I dtb -O dtb -s -o $basetree.reversed.sorted.test.dtb $basetree.reversed.test.dtb
|
|
|
|
run_test dtbs_equal_unordered $basetree.reversed.test.dtb $basetree.reversed.sorted.test.dtb
|
|
|
|
run_test dtbs_equal_ordered $basetree.sorted.test.dtb $basetree.reversed.sorted.test.dtb
|
2010-04-30 07:30:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
dtbs_equal_tests () {
|
|
|
|
WRONG_TREE1=""
|
|
|
|
for x in 1 2 3 4 5 6 7 8 9; do
|
2019-10-09 12:20:17 +02:00
|
|
|
run_dtc_test -I dts -O dtb -o test_tree1_wrong$x.test.dtb "$SRCDIR/test_tree1_wrong$x.dts"
|
2010-04-30 07:30:00 +02:00
|
|
|
WRONG_TREE1="$WRONG_TREE1 test_tree1_wrong$x.test.dtb"
|
|
|
|
done
|
|
|
|
cmp_tests test_tree1.dtb $WRONG_TREE1
|
|
|
|
}
|
|
|
|
|
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 19:14:47 +01:00
|
|
|
fdtget_tests () {
|
2012-02-03 06:12:07 +01:00
|
|
|
dts=label01.dts
|
|
|
|
dtb=$dts.fdtget.test.dtb
|
2019-10-09 12:20:17 +02:00
|
|
|
run_dtc_test -O dtb -o $dtb "$SRCDIR/$dts"
|
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 19:14:47 +01:00
|
|
|
|
2012-02-03 06:12:07 +01:00
|
|
|
# run_fdtget_test <expected-result> [<flags>] <file> <node> <property>
|
|
|
|
run_fdtget_test "MyBoardName" $dtb / model
|
2013-01-27 20:13:11 +01:00
|
|
|
run_fdtget_test "MyBoardName MyBoardFamilyName" $dtb / compatible
|
2012-02-03 06:12:07 +01:00
|
|
|
run_fdtget_test "77 121 66 111 \
|
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 19:14:47 +01:00
|
|
|
97 114 100 78 97 109 101 0 77 121 66 111 97 114 100 70 97 109 105 \
|
2013-01-27 20:13:11 +01:00
|
|
|
108 121 78 97 109 101 0" -t bu $dtb / compatible
|
2012-02-03 06:12:07 +01:00
|
|
|
run_fdtget_test "MyBoardName MyBoardFamilyName" -t s $dtb / compatible
|
|
|
|
run_fdtget_test 32768 $dtb /cpus/PowerPC,970@1 d-cache-size
|
|
|
|
run_fdtget_test 8000 -tx $dtb /cpus/PowerPC,970@1 d-cache-size
|
|
|
|
run_fdtget_test "61 62 63 0" -tbx $dtb /randomnode tricky1
|
|
|
|
run_fdtget_test "a b c d de ea ad be ef" -tbx $dtb /randomnode blob
|
2021-12-09 07:14:20 +01:00
|
|
|
run_fdtget_test "MyBoardName\0MyBoardFamilyName\0" -tr $dtb / compatible
|
|
|
|
run_fdtget_test "\x0a\x0b\x0c\x0d\xde\xea\xad\xbe\xef" -tr $dtb /randomnode blob
|
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 19:14:47 +01:00
|
|
|
|
|
|
|
# Here the property size is not a multiple of 4 bytes, so it should fail
|
2012-02-03 06:12:07 +01:00
|
|
|
run_wrap_error_test $DTGET -tlx $dtb /randomnode mixed
|
|
|
|
run_fdtget_test "6162 6300 1234 0 a 0 b 0 c" -thx $dtb /randomnode mixed
|
|
|
|
run_fdtget_test "61 62 63 0 12 34 0 0 0 a 0 0 0 b 0 0 0 c" \
|
|
|
|
-thhx $dtb /randomnode mixed
|
|
|
|
run_wrap_error_test $DTGET -ts $dtb /randomnode doctor-who
|
2012-03-03 02:12:07 +01:00
|
|
|
|
|
|
|
# Test multiple arguments
|
|
|
|
run_fdtget_test "MyBoardName\nmemory" -ts $dtb / model /memory device_type
|
2012-03-07 01:41:47 +01:00
|
|
|
|
|
|
|
# Test defaults
|
|
|
|
run_wrap_error_test $DTGET -tx $dtb /randomnode doctor-who
|
|
|
|
run_fdtget_test "<the dead silence>" -tx \
|
|
|
|
-d "<the dead silence>" $dtb /randomnode doctor-who
|
|
|
|
run_fdtget_test "<blink>" -tx -d "<blink>" $dtb /memory doctor-who
|
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 19:14:47 +01:00
|
|
|
}
|
|
|
|
|
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>
2012-01-21 19:14:48 +01:00
|
|
|
fdtput_tests () {
|
2012-02-03 06:12:07 +01:00
|
|
|
dts=label01.dts
|
|
|
|
dtb=$dts.fdtput.test.dtb
|
2019-10-09 12:20:17 +02:00
|
|
|
text="$SRCDIR/lorem.txt"
|
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>
2012-01-21 19:14:48 +01:00
|
|
|
|
2012-02-03 06:12:09 +01:00
|
|
|
# Allow just enough space for $text
|
2019-10-09 12:20:17 +02:00
|
|
|
run_dtc_test -O dtb -p $($STATSZ $text) -o $dtb "$SRCDIR/$dts"
|
2012-02-03 06:12:07 +01:00
|
|
|
|
|
|
|
# run_fdtput_test <expected-result> <file> <node> <property> <flags> <value>
|
|
|
|
run_fdtput_test "a_model" $dtb / model -ts "a_model"
|
|
|
|
run_fdtput_test "board1 board2" $dtb / compatible -ts board1 board2
|
|
|
|
run_fdtput_test "board1 board2" $dtb / compatible -ts "board1 board2"
|
|
|
|
run_fdtput_test "32768" $dtb /cpus/PowerPC,970@1 d-cache-size "" "32768"
|
|
|
|
run_fdtput_test "8001" $dtb /cpus/PowerPC,970@1 d-cache-size -tx 0x8001
|
|
|
|
run_fdtput_test "2 3 12" $dtb /randomnode tricky1 -tbi "02 003 12"
|
|
|
|
run_fdtput_test "a b c ea ad be ef" $dtb /randomnode blob \
|
|
|
|
-tbx "a b c ea ad be ef"
|
|
|
|
run_fdtput_test "a0b0c0d deeaae ef000000" $dtb /randomnode blob \
|
|
|
|
-tx "a0b0c0d deeaae ef000000"
|
2012-02-03 06:12:09 +01:00
|
|
|
run_fdtput_test "$(cat $text)" $dtb /randomnode blob -ts "$(cat $text)"
|
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>
2012-01-21 19:14:48 +01:00
|
|
|
|
2013-05-29 04:47:38 +02:00
|
|
|
# Test expansion of the blob when insufficient room for property
|
|
|
|
run_fdtput_test "$(cat $text $text)" $dtb /randomnode blob -ts "$(cat $text $text)"
|
|
|
|
|
2012-07-12 17:52:49 +02:00
|
|
|
# Start again with a fresh dtb
|
2019-10-09 12:20:17 +02:00
|
|
|
run_dtc_test -O dtb -p $($STATSZ $text) -o $dtb "$SRCDIR/$dts"
|
2012-07-12 17:52:49 +02:00
|
|
|
|
|
|
|
# Node creation
|
|
|
|
run_wrap_error_test $DTPUT $dtb -c /baldrick sod
|
|
|
|
run_wrap_test $DTPUT $dtb -c /chosen/son /chosen/daughter
|
|
|
|
run_fdtput_test "eva" $dtb /chosen/daughter name "" -ts "eva"
|
|
|
|
run_fdtput_test "adam" $dtb /chosen/son name "" -ts "adam"
|
|
|
|
|
|
|
|
# Not allowed to create an existing node
|
|
|
|
run_wrap_error_test $DTPUT $dtb -c /chosen
|
|
|
|
run_wrap_error_test $DTPUT $dtb -c /chosen/son
|
|
|
|
|
2012-07-12 17:52:51 +02:00
|
|
|
# Automatic node creation
|
|
|
|
run_wrap_test $DTPUT $dtb -cp /blackadder/the-second/turnip \
|
|
|
|
/blackadder/the-second/potato
|
|
|
|
run_fdtput_test 1000 $dtb /blackadder/the-second/turnip cost "" 1000
|
|
|
|
run_fdtput_test "fine wine" $dtb /blackadder/the-second/potato drink \
|
|
|
|
"-ts" "fine wine"
|
|
|
|
run_wrap_test $DTPUT $dtb -p /you/are/drunk/sir/winston slurp -ts twice
|
|
|
|
|
2019-05-20 10:12:09 +02:00
|
|
|
# Test expansion of the blob when insufficient room for a new node
|
2013-05-29 04:47:38 +02:00
|
|
|
run_wrap_test $DTPUT $dtb -cp "$(cat $text $text)/longish"
|
|
|
|
|
2012-07-12 17:52:51 +02:00
|
|
|
# Allowed to create an existing node with -p
|
|
|
|
run_wrap_test $DTPUT $dtb -cp /chosen
|
|
|
|
run_wrap_test $DTPUT $dtb -cp /chosen/son
|
|
|
|
|
2015-01-23 02:25:20 +01:00
|
|
|
# Start again with a fresh dtb
|
2019-10-09 12:20:17 +02:00
|
|
|
run_dtc_test -O dtb -p $($STATSZ $text) -o $dtb "$SRCDIR/$dts"
|
2015-01-23 02:25:20 +01:00
|
|
|
|
|
|
|
# Node delete
|
|
|
|
run_wrap_test $DTPUT $dtb -c /chosen/node1 /chosen/node2 /chosen/node3
|
|
|
|
run_fdtget_test "node3\nnode2\nnode1" $dtb -l /chosen
|
|
|
|
run_wrap_test $DTPUT $dtb -r /chosen/node1 /chosen/node2
|
|
|
|
run_fdtget_test "node3" $dtb -l /chosen
|
|
|
|
|
|
|
|
# Delete the non-existent node
|
|
|
|
run_wrap_error_test $DTPUT $dtb -r /non-existent/node
|
|
|
|
|
|
|
|
# Property delete
|
|
|
|
run_fdtput_test "eva" $dtb /chosen/ name "" -ts "eva"
|
|
|
|
run_fdtput_test "016" $dtb /chosen/ age "" -ts "016"
|
|
|
|
run_fdtget_test "age\nname\nbootargs\nlinux,platform" $dtb -p /chosen
|
|
|
|
run_wrap_test $DTPUT $dtb -d /chosen/ name age
|
|
|
|
run_fdtget_test "bootargs\nlinux,platform" $dtb -p /chosen
|
|
|
|
|
|
|
|
# Delete the non-existent property
|
|
|
|
run_wrap_error_test $DTPUT $dtb -d /chosen non-existent-prop
|
|
|
|
|
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>
2012-01-21 19:14:48 +01:00
|
|
|
# TODO: Add tests for verbose mode?
|
|
|
|
}
|
|
|
|
|
2011-09-22 19:11:02 +02:00
|
|
|
utilfdt_tests () {
|
|
|
|
run_test utilfdt_test
|
|
|
|
}
|
|
|
|
|
2014-06-18 13:24:32 +02:00
|
|
|
fdtdump_tests () {
|
2019-10-09 12:20:17 +02:00
|
|
|
run_fdtdump_test "$SRCDIR/fdtdump.dts"
|
2014-06-18 13:24:32 +02:00
|
|
|
}
|
|
|
|
|
2017-06-14 16:51:12 +02:00
|
|
|
fdtoverlay_tests() {
|
2019-10-09 12:20:17 +02:00
|
|
|
base="$SRCDIR/overlay_base.dts"
|
2017-06-14 16:51:12 +02:00
|
|
|
basedtb=overlay_base.fdoverlay.test.dtb
|
2019-10-09 12:20:17 +02:00
|
|
|
overlay="$SRCDIR/overlay_overlay_manual_fixups.dts"
|
2017-06-14 16:51:12 +02:00
|
|
|
overlaydtb=overlay_overlay_manual_fixups.fdoverlay.test.dtb
|
|
|
|
targetdtb=target.fdoverlay.test.dtb
|
|
|
|
|
|
|
|
run_dtc_test -@ -I dts -O dtb -o $basedtb $base
|
|
|
|
run_dtc_test -@ -I dts -O dtb -o $overlaydtb $overlay
|
|
|
|
|
|
|
|
# test that the new property is installed
|
|
|
|
run_fdtoverlay_test foobar "/test-node" "test-str-property" "-ts" ${basedtb} ${targetdtb} ${overlaydtb}
|
2017-07-31 19:10:08 +02:00
|
|
|
|
2019-10-09 12:20:17 +02:00
|
|
|
stacked_base="$SRCDIR/stacked_overlay_base.dts"
|
2017-07-31 19:10:08 +02:00
|
|
|
stacked_basedtb=stacked_overlay_base.fdtoverlay.test.dtb
|
2019-10-09 12:20:17 +02:00
|
|
|
stacked_bar="$SRCDIR/stacked_overlay_bar.dts"
|
2017-07-31 19:10:08 +02:00
|
|
|
stacked_bardtb=stacked_overlay_bar.fdtoverlay.test.dtb
|
2019-10-09 12:20:17 +02:00
|
|
|
stacked_baz="$SRCDIR/stacked_overlay_baz.dts"
|
2017-07-31 19:10:08 +02:00
|
|
|
stacked_bazdtb=stacked_overlay_baz.fdtoverlay.test.dtb
|
|
|
|
stacked_targetdtb=stacked_overlay_target.fdtoverlay.test.dtb
|
|
|
|
|
|
|
|
run_dtc_test -@ -I dts -O dtb -o $stacked_basedtb $stacked_base
|
|
|
|
run_dtc_test -@ -I dts -O dtb -o $stacked_bardtb $stacked_bar
|
|
|
|
run_dtc_test -@ -I dts -O dtb -o $stacked_bazdtb $stacked_baz
|
|
|
|
|
|
|
|
# test that baz correctly inserted the property
|
|
|
|
run_fdtoverlay_test baz "/foonode/barnode/baznode" "baz-property" "-ts" ${stacked_basedtb} ${stacked_targetdtb} ${stacked_bardtb} ${stacked_bazdtb}
|
2018-10-03 09:55:02 +02:00
|
|
|
|
2019-11-11 09:04:44 +01:00
|
|
|
# test that bar and baz are correctly appended to __symbols__
|
|
|
|
run_fdtoverlay_test "/foonode/barnode" "/__symbols__" "bar" "-ts" ${stacked_basedtb} ${stacked_targetdtb} ${stacked_bardtb}
|
|
|
|
run_fdtoverlay_test "/foonode/barnode/baznode" "/__symbols__" "baz" "-ts" ${stacked_basedtb} ${stacked_targetdtb} ${stacked_bardtb} ${stacked_bazdtb}
|
|
|
|
|
2019-10-09 12:20:17 +02:00
|
|
|
overlay_long_path="$SRCDIR/overlay_overlay_long_path.dts"
|
2018-10-03 09:55:02 +02:00
|
|
|
overlay_long_pathdtb=overlay_overlay_long_path.fdoverlay.test.dtb
|
|
|
|
target_long_pathdtb=overlay_overlay_long_path_target.fdoverlay.test.dtb
|
|
|
|
run_dtc_test -@ -I dts -O dtb -o $overlay_long_pathdtb $overlay_long_path
|
|
|
|
|
|
|
|
# test that fdtoverlay manages to apply overlays with long target path
|
|
|
|
run_fdtoverlay_test lpath "/test-node/sub-test-node/sub-test-node-with-very-long-target-path/test-0" "prop" "-ts" ${basedtb} ${target_long_pathdtb} ${overlay_long_pathdtb}
|
2019-07-04 06:39:02 +02:00
|
|
|
|
|
|
|
# test adding a label to the root of a fragment
|
2019-10-09 12:20:17 +02:00
|
|
|
stacked_base_nolabel="$SRCDIR/stacked_overlay_base_nolabel.dts"
|
2019-07-04 06:39:02 +02:00
|
|
|
stacked_base_nolabeldtb=stacked_overlay_base_nolabel.test.dtb
|
2019-10-09 12:20:17 +02:00
|
|
|
stacked_addlabel="$SRCDIR/stacked_overlay_addlabel.dts"
|
2019-07-04 06:39:02 +02:00
|
|
|
stacked_addlabeldtb=stacked_overlay_addlabel.test.dtb
|
|
|
|
stacked_addlabel_targetdtb=stacked_overlay_target_nolabel.fdtoverlay.test.dtb
|
|
|
|
|
|
|
|
run_dtc_test -@ -I dts -O dtb -o $stacked_base_nolabeldtb $stacked_base_nolabel
|
|
|
|
run_dtc_test -@ -I dts -O dtb -o $stacked_addlabeldtb $stacked_addlabel
|
|
|
|
|
|
|
|
run_fdtoverlay_test baz "/foonode/barnode/baznode" "baz-property" "-ts" ${stacked_base_nolabeldtb} ${stacked_addlabel_targetdtb} ${stacked_addlabeldtb} ${stacked_bardtb} ${stacked_bazdtb}
|
2017-06-14 16:51:12 +02:00
|
|
|
}
|
|
|
|
|
2017-03-17 23:14:34 +01:00
|
|
|
pylibfdt_tests () {
|
2019-10-09 12:20:17 +02:00
|
|
|
run_dtc_test -I dts -O dtb -o test_props.dtb "$SRCDIR/test_props.dts"
|
2017-03-17 23:14:34 +01:00
|
|
|
TMP=/tmp/tests.stderr.$$
|
2019-10-09 12:20:17 +02:00
|
|
|
$PYTHON "$SRCDIR/pylibfdt_tests.py" -v 2> $TMP
|
2017-03-17 23:14:34 +01:00
|
|
|
|
|
|
|
# Use the 'ok' message meaning the test passed, 'ERROR' meaning it failed
|
|
|
|
# and the summary line for total tests (e.g. 'Ran 17 tests in 0.002s').
|
|
|
|
# We could add pass + fail to get total tests, but this provides a useful
|
|
|
|
# sanity check.
|
2019-02-18 17:48:55 +01:00
|
|
|
pass_count=$(grep "ok$" $TMP | wc -l)
|
2017-03-17 23:14:34 +01:00
|
|
|
fail_count=$(grep "^ERROR: " $TMP | wc -l)
|
|
|
|
total_tests=$(sed -n 's/^Ran \([0-9]*\) tests.*$/\1/p' $TMP)
|
|
|
|
cat $TMP
|
|
|
|
rm $TMP
|
|
|
|
|
|
|
|
# Extract the test results and add them to our totals
|
|
|
|
tot_fail=$((tot_fail + $fail_count))
|
|
|
|
tot_pass=$((tot_pass + $pass_count))
|
|
|
|
tot_tests=$((tot_tests + $total_tests))
|
|
|
|
}
|
|
|
|
|
2013-12-30 12:42:41 +01:00
|
|
|
while getopts "vt:me" ARG ; do
|
2006-11-27 06:21:28 +01:00
|
|
|
case $ARG in
|
|
|
|
"v")
|
|
|
|
unset QUIET_TEST
|
|
|
|
;;
|
|
|
|
"t")
|
|
|
|
TESTSETS=$OPTARG
|
|
|
|
;;
|
2007-11-21 01:56:14 +01:00
|
|
|
"m")
|
|
|
|
VALGRIND="valgrind --tool=memcheck -q --error-exitcode=$VGCODE"
|
|
|
|
;;
|
2013-12-30 12:42:41 +01:00
|
|
|
"e")
|
|
|
|
STOP_ON_FAIL=1
|
|
|
|
;;
|
2006-11-27 06:21:28 +01:00
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ -z "$TESTSETS" ]; then
|
2017-06-14 16:51:12 +02:00
|
|
|
TESTSETS="libfdt utilfdt dtc dtbs_equal fdtget fdtput fdtdump fdtoverlay"
|
2017-03-17 23:14:34 +01:00
|
|
|
|
|
|
|
# Test pylibfdt if the libfdt Python module is available.
|
2020-03-04 05:45:47 +01:00
|
|
|
if ! $no_python; then
|
2017-03-17 23:14:34 +01:00
|
|
|
TESTSETS="$TESTSETS pylibfdt"
|
|
|
|
fi
|
2006-11-27 06:21:28 +01:00
|
|
|
fi
|
|
|
|
|
2007-10-16 05:53:20 +02:00
|
|
|
# Make sure we don't have stale blobs lying around
|
2007-11-07 00:34:06 +01:00
|
|
|
rm -f *.test.dtb *.test.dts
|
2007-10-16 05:53:20 +02:00
|
|
|
|
2006-11-27 06:21:28 +01:00
|
|
|
for set in $TESTSETS; do
|
|
|
|
case $set in
|
2007-09-17 06:39:24 +02:00
|
|
|
"libfdt")
|
|
|
|
libfdt_tests
|
2006-11-27 06:21:28 +01:00
|
|
|
;;
|
2011-09-22 19:11:02 +02:00
|
|
|
"utilfdt")
|
|
|
|
utilfdt_tests
|
|
|
|
;;
|
2007-09-18 02:33:40 +02:00
|
|
|
"dtc")
|
|
|
|
dtc_tests
|
|
|
|
;;
|
2010-04-30 07:30:00 +02:00
|
|
|
"dtbs_equal")
|
|
|
|
dtbs_equal_tests
|
|
|
|
;;
|
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 19:14:47 +01:00
|
|
|
"fdtget")
|
|
|
|
fdtget_tests
|
|
|
|
;;
|
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>
2012-01-21 19:14:48 +01:00
|
|
|
"fdtput")
|
|
|
|
fdtput_tests
|
|
|
|
;;
|
2014-06-18 13:24:32 +02:00
|
|
|
"fdtdump")
|
|
|
|
fdtdump_tests
|
|
|
|
;;
|
2017-03-17 23:14:34 +01:00
|
|
|
"pylibfdt")
|
|
|
|
pylibfdt_tests
|
|
|
|
;;
|
2017-06-14 16:51:12 +02:00
|
|
|
"fdtoverlay")
|
|
|
|
fdtoverlay_tests
|
|
|
|
;;
|
2006-11-27 06:21:28 +01:00
|
|
|
esac
|
|
|
|
done
|
2007-06-26 03:33:10 +02:00
|
|
|
|
2009-11-12 01:56:34 +01:00
|
|
|
echo "********** TEST SUMMARY"
|
|
|
|
echo "* Total testcases: $tot_tests"
|
|
|
|
echo "* PASS: $tot_pass"
|
|
|
|
echo "* FAIL: $tot_fail"
|
|
|
|
echo "* Bad configuration: $tot_config"
|
2007-11-21 01:56:14 +01:00
|
|
|
if [ -n "$VALGRIND" ]; then
|
2009-11-12 01:56:34 +01:00
|
|
|
echo "* valgrind errors: $tot_vg"
|
2007-11-21 01:56:14 +01:00
|
|
|
fi
|
2009-11-12 01:56:34 +01:00
|
|
|
echo "* Strange test result: $tot_strange"
|
|
|
|
echo "**********"
|
2007-06-26 03:33:10 +02:00
|
|
|
|
2017-08-19 19:17:56 +02:00
|
|
|
[ "$tot_tests" -eq "$tot_pass" ] || exit 1
|