lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZzTiWBLaUDex4ieA@mini-arch>
Date: Wed, 13 Nov 2024 09:31:04 -0800
From: Stanislav Fomichev <stfomichev@...il.com>
To: Alexis Lothoré (eBPF Foundation) <alexis.lothore@...tlin.com>
Cc: Andrii Nakryiko <andrii@...nel.org>,
	Eduard Zingerman <eddyz87@...il.com>,
	Mykola Lysenko <mykolal@...com>,
	Alexei Starovoitov <ast@...nel.org>,
	Daniel Borkmann <daniel@...earbox.net>,
	Martin KaFai Lau <martin.lau@...ux.dev>, Song Liu <song@...nel.org>,
	Yonghong Song <yonghong.song@...ux.dev>,
	John Fastabend <john.fastabend@...il.com>,
	KP Singh <kpsingh@...nel.org>, Stanislav Fomichev <sdf@...ichev.me>,
	Hao Luo <haoluo@...gle.com>, Jiri Olsa <jolsa@...nel.org>,
	Shuah Khan <shuah@...nel.org>, ebpf@...uxfoundation.org,
	Thomas Petazzoni <thomas.petazzoni@...tlin.com>,
	Bastien Curutchet <bastien.curutchet@...tlin.com>,
	Petar Penkov <ppenkov@...gle.com>, bpf@...r.kernel.org,
	linux-kselftest@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH bpf-next 01/10] selftests/bpf: add a macro to compare raw
 memory

On 11/13, Alexis Lothoré (eBPF Foundation) wrote:
> We sometimes need to compare whole structures in an assert. It is
> possible to use the existing macros on each field, but when the whole
> structure has to be checked, it is more convenient to simply compare the
> whole structure memory
> 
> Add a dedicated assert macro, ASSERT_MEMEQ, to allow bare memory
> comparision
> 
> Signed-off-by: Alexis Lothoré (eBPF Foundation) <alexis.lothore@...tlin.com>
> ---
>  tools/testing/selftests/bpf/test_progs.h | 25 +++++++++++++++++++++++++
>  1 file changed, 25 insertions(+)
> 
> diff --git a/tools/testing/selftests/bpf/test_progs.h b/tools/testing/selftests/bpf/test_progs.h
> index 74de33ae37e56c90646cd1e0bb58ed7e3f345ec0..bdde741543836991398daacfe5423e6af8ef9151 100644
> --- a/tools/testing/selftests/bpf/test_progs.h
> +++ b/tools/testing/selftests/bpf/test_progs.h
> @@ -186,6 +186,19 @@ void test__skip(void);
>  void test__fail(void);
>  int test__join_cgroup(const char *path);

[..]
 
> +#define DUMP_BUFFER(name, buf, len)						\
> +	({									\
> +		fprintf(stdout, "%s:\n", name);					\
> +		for (int i = 0; i < len; i++) {					\
> +			if (i && !(i % 16))					\
> +				fprintf(stdout, "\n");				\
> +			if (i && !(i % 8) && (i % 16))				\
> +				fprintf(stdout, "\t");				\
> +			fprintf(stdout, "%02X ", ((uint8_t *)(buf))[i]);	\
> +		}								\
> +		fprintf(stdout, "\n");						\
> +	})

nit: should we rewrite this as a real function?

void hexdump(const char *prefix, void *buf, size_t len)
{
..
}

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ