diff options
author | David Gibson <david@gibson.dropbear.id.au> | 2018-03-17 20:05:24 +1100 |
---|---|---|
committer | David Gibson <david@gibson.dropbear.id.au> | 2018-04-11 16:49:38 +1000 |
commit | cbc9533eb576090e7b320aae7ea64e87dc79190c (patch) | |
tree | cf55d438e66625a71e255800aa646d737b40d948 | |
parent | 054be9d68b7e2574bec6573c2f5125407e23d102 (diff) | |
download | device-tree-compiler-cbc9533eb576090e7b320aae7ea64e87dc79190c.tar.gz |
tests: Better handling of valgrind errors saving blobs
Currently we have 3 valgrind suppression files in the tests, all of which
are to handle memcheck errors that originate from saving entire buffers
containing blobs where the gaps between sub-blocks might not be
initialized.
We can more simply suppress those errors by having the save_blob() helper
use valgrind's client interface to mark the data as initialized before we
write it out.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Simon Glass <sjg@chromium.org>
-rw-r--r-- | tests/mangle-layout.supp | 7 | ||||
-rw-r--r-- | tests/open_pack.supp | 7 | ||||
-rw-r--r-- | tests/sw_tree1.supp | 18 | ||||
-rw-r--r-- | tests/testutils.c | 15 |
4 files changed, 13 insertions, 34 deletions
diff --git a/tests/mangle-layout.supp b/tests/mangle-layout.supp deleted file mode 100644 index 2890420..0000000 --- a/tests/mangle-layout.supp +++ /dev/null @@ -1,7 +0,0 @@ -{ - uninitialized alignment gaps can be dumped to output - Memcheck:Param - write(buf) - obj:/lib/ld-*.so - fun:main -} diff --git a/tests/open_pack.supp b/tests/open_pack.supp deleted file mode 100644 index c954fe7..0000000 --- a/tests/open_pack.supp +++ /dev/null @@ -1,7 +0,0 @@ -{ - opened blob dumps uninitialized data - Memcheck:Param - write(buf) - obj:/lib/ld-*.so - fun:main -} diff --git a/tests/sw_tree1.supp b/tests/sw_tree1.supp deleted file mode 100644 index fcb1950..0000000 --- a/tests/sw_tree1.supp +++ /dev/null @@ -1,18 +0,0 @@ -{ - allocation methods causes uninitialized data in alignment gap - Memcheck:Param - write(buf) - fun:__write_nocancel - fun:utilfdt_write_err - fun:save_blob - fun:main -} -{ - allocation methods causes uninitialized data in alignment gap - Memcheck:Param - write(buf) - fun:write - fun:utilfdt_write_err - fun:save_blob - fun:main -} diff --git a/tests/testutils.c b/tests/testutils.c index 101b00b..d6d6818 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -30,6 +30,8 @@ #include <unistd.h> #include <fcntl.h> +#include <valgrind/memcheck.h> + #include <libfdt.h> #include "tests.h" @@ -179,11 +181,20 @@ void *load_blob_arg(int argc, char *argv[]) void save_blob(const char *filename, void *fdt) { - int ret = utilfdt_write_err(filename, fdt); - + size_t size = fdt_totalsize(fdt); + void *tmp; + int ret; + + /* Make a temp copy of the blob so that valgrind won't check + * about uninitialized bits in the pieces between blocks */ + tmp = xmalloc(size); + fdt_move(fdt, tmp, size); + VALGRIND_MAKE_MEM_DEFINED(tmp, size); + ret = utilfdt_write_err(filename, tmp); if (ret) CONFIG("Couldn't write blob to \"%s\": %s", filename, strerror(ret)); + free(tmp); } void *open_blob_rw(void *blob) |