Re: [PATCH 2/4] tests: Enhance truncated_memrsv to test fdt_open_into()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



On Fri, Jun 11, 2021 at 12:58:21PM +0100, Andre Przywara wrote:
> We already check that libfdt's r/o functions can deal properly with
> malformed blobs, where the memreserve block is not correct.
> 
> Add a test for fdt_open_into(), which also queries the memreserve block,
> and uses the return value as an offset into a buffer.
> 
> Signed-off-by: Andre Przywara <andre.przywara@xxxxxxx>

Reviewed-by: David Gibson <david@xxxxxxxxxxxxxxxxxxxxx>

> ---
>  tests/truncated_memrsv.c | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/tests/truncated_memrsv.c b/tests/truncated_memrsv.c
> index d78036c..9defef3 100644
> --- a/tests/truncated_memrsv.c
> +++ b/tests/truncated_memrsv.c
> @@ -18,7 +18,8 @@
>  int main(int argc, char *argv[])
>  {
>  	void *fdt = &truncated_memrsv;
> -	int err;
> +	char *buf;
> +	int err, bufsize;
>  	uint64_t addr, size;
>  
>  	test_init(argc, argv);
> @@ -46,5 +47,12 @@ int main(int argc, char *argv[])
>  		FAIL("fdt_get_mem_rsv(1) returned %d instead of -FDT_ERR_BADOFFSET",
>  		     err);
>  
> +	bufsize = fdt_totalsize(fdt);
> +	buf = xmalloc(bufsize);
> +	err = fdt_open_into(fdt, buf, bufsize);
> +	if (err != -FDT_ERR_TRUNCATED)
> +		FAIL("fdt_open_into() returned %d instead of -FDT_ERR_TRUNCATED",
> +		     err);
> +
>  	PASS();
>  }

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Device Tree]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux