All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Alex Bennée" <alex.bennee@linaro.org>
To: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Cc: qemu-devel@nongnu.org, "Alexandre Iooss" <erdnaxe@crans.org>,
	"Zhao Liu" <zhao1.liu@intel.com>,
	"Mahmoud Mandour" <ma.mandourr@gmail.com>,
	"Yanan Wang" <wangyanan55@huawei.com>,
	"Eduardo Habkost" <eduardo@habkost.net>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>,
	"Richard Henderson" <richard.henderson@linaro.org>,
	"Marcel Apfelbaum" <marcel.apfelbaum@gmail.com>,
	"Xingtao Yao" <yaoxt.fnst@fujitsu.com>
Subject: Re: [PATCH v7 6/6] tests/tcg/multiarch: add test for plugin memory access
Date: Wed, 04 Sep 2024 16:41:28 +0100	[thread overview]
Message-ID: <87seuftoif.fsf@draig.linaro.org> (raw)
In-Reply-To: <20240724194708.1843704-7-pierrick.bouvier@linaro.org> (Pierrick Bouvier's message of "Wed, 24 Jul 2024 12:47:08 -0700")

Pierrick Bouvier <pierrick.bouvier@linaro.org> writes:

> Add an explicit test to check expected memory values are read/written.
> 8,16,32 load/store are tested for all arch.
> 64,128 load/store are tested for aarch64/x64.
> atomic operations (8,16,32,64) are tested for x64 only.
>
> By default, atomic accesses are non atomic if a single cpu is running,
> so we force creation of a second one by creating a new thread first.
>
> load/store helpers code path can't be triggered easily in user mode (no
> softmmu), so we can't test it here.
>
> Output of test-plugin-mem-access.c is the list of expected patterns in
> plugin output. By reading stdout, we can compare to plugins output and
> have a multiarch test.
>
> Can be run with:
> make -C build/tests/tcg/$ARCH-linux-user run-plugin-test-plugin-mem-access-with-libmem.so
>
> Tested-by: Xingtao Yao <yaoxt.fnst@fujitsu.com>
> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
> ---
>  tests/tcg/multiarch/test-plugin-mem-access.c  | 175 ++++++++++++++++++
>  tests/tcg/multiarch/Makefile.target           |   7 +
>  .../tcg/multiarch/check-plugin-mem-access.sh  |  30 +++
>  3 files changed, 212 insertions(+)
>  create mode 100644 tests/tcg/multiarch/test-plugin-mem-access.c
>  create mode 100755 tests/tcg/multiarch/check-plugin-mem-access.sh
>
> diff --git a/tests/tcg/multiarch/test-plugin-mem-access.c b/tests/tcg/multiarch/test-plugin-mem-access.c
> new file mode 100644
> index 00000000000..09d1fa22e35
<snip>
> diff --git a/tests/tcg/multiarch/Makefile.target b/tests/tcg/multiarch/Makefile.target
> index 5e3391ec9d2..d90cbd3e521 100644
> --- a/tests/tcg/multiarch/Makefile.target
> +++ b/tests/tcg/multiarch/Makefile.target
> @@ -170,5 +170,12 @@ run-plugin-semiconsole-with-%:
>  TESTS += semihosting semiconsole
>  endif
>

Also you need:

test-plugin-mem-access: CFLAGS+=-pthread
test-plugin-mem-access: LDFLAGS+=-pthread

So less tolerant gcc's include pthread (otherwise the alpha-linux-user
fails), with that fix I get:

   TEST    check plugin libmem.so output with test-plugin-mem-access
  ",store_u8,.*,8,store,0xf1" not found in test-plugin-mem-access-with-libmem.so.pout
  make[1]: *** [Makefile:181: run-plugin-test-plugin-mem-access-with-libmem.so] Error 1
  make: *** [/home/alex/lsrc/qemu.git/tests/Makefile.include:56: run-tcg-tests-alpha-linux-user] Error 2

> +# Test plugin memory access instrumentation
> +run-plugin-test-plugin-mem-access-with-libmem.so: \
> +	PLUGIN_ARGS=$(COMMA)print-accesses=true
> +run-plugin-test-plugin-mem-access-with-libmem.so: \
> +	CHECK_PLUGIN_OUTPUT_COMMAND= \
> +	$(SRC_PATH)/tests/tcg/multiarch/check-plugin-mem-access.sh
> +
>  # Update TESTS
>  TESTS += $(MULTIARCH_TESTS)
> diff --git a/tests/tcg/multiarch/check-plugin-mem-access.sh b/tests/tcg/multiarch/check-plugin-mem-access.sh
> new file mode 100755
> index 00000000000..909606943bb
> --- /dev/null
> +++ b/tests/tcg/multiarch/check-plugin-mem-access.sh
> @@ -0,0 +1,30 @@
> +#!/usr/bin/env bash
> +
> +set -euo pipefail
> +
> +die()
> +{
> +    echo "$@" 1>&2
> +    exit 1
> +}
> +
> +check()
> +{
> +    file=$1
> +    pattern=$2
> +    grep "$pattern" "$file" > /dev/null || die "\"$pattern\" not found in $file"
> +}
> +
> +[ $# -eq 1 ] || die "usage: plugin_out_file"
> +
> +plugin_out=$1
> +
> +expected()
> +{
> +    ./test-plugin-mem-access ||
> +        die "running test-plugin-mem-access executable failed"
> +}
> +
> +expected | while read line; do
> +    check "$plugin_out" "$line"
> +done

-- 
Alex Bennée
Virtualisation Tech Lead @ Linaro


  parent reply	other threads:[~2024-09-04 15:42 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-24 19:47 [PATCH v7 0/6] plugins: access values during a memory read/write Pierrick Bouvier
2024-07-24 19:47 ` [PATCH v7 1/6] plugins: save value during memory accesses Pierrick Bouvier
2024-07-24 19:47 ` [PATCH v7 2/6] plugins: extend API to get latest memory value accessed Pierrick Bouvier
2024-07-24 19:47 ` [PATCH v7 3/6] tests/tcg: add mechanism to run specific tests with plugins Pierrick Bouvier
2024-07-24 19:47 ` [PATCH v7 4/6] tests/tcg: allow to check output of plugins Pierrick Bouvier
2024-07-24 19:47 ` [PATCH v7 5/6] tests/plugin/mem: add option to print memory accesses Pierrick Bouvier
2024-07-24 19:47 ` [PATCH v7 6/6] tests/tcg/multiarch: add test for plugin memory access Pierrick Bouvier
2024-08-29  9:03   ` Alex Bennée
2024-08-30 15:25     ` [RFC PATCH] tests/tcg: add a system test to check memory instrumentation Alex Bennée
2024-08-30 19:17       ` Pierrick Bouvier
2024-08-30 19:08     ` [PATCH v7 6/6] tests/tcg/multiarch: add test for plugin memory access Pierrick Bouvier
2024-09-04 13:19       ` Alex Bennée
2024-09-04 15:41   ` Alex Bennée [this message]
2024-09-04 16:28     ` Alex Bennée
2024-09-05 15:21 ` [PATCH v7 0/6] plugins: access values during a memory read/write Alex Bennée
2024-09-07  1:49   ` Pierrick Bouvier
2024-09-09 10:00     ` Alex Bennée
2024-09-09 19:04       ` Pierrick Bouvier
2024-09-09 20:21         ` Alex Bennée
2024-09-09 21:42           ` Pierrick Bouvier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87seuftoif.fsf@draig.linaro.org \
    --to=alex.bennee@linaro.org \
    --cc=eduardo@habkost.net \
    --cc=erdnaxe@crans.org \
    --cc=ma.mandourr@gmail.com \
    --cc=marcel.apfelbaum@gmail.com \
    --cc=pbonzini@redhat.com \
    --cc=philmd@linaro.org \
    --cc=pierrick.bouvier@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=wangyanan55@huawei.com \
    --cc=yaoxt.fnst@fujitsu.com \
    --cc=zhao1.liu@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.