From: Paolo Bonzini <pbonzini@redhat.com>
To: "Daniel P. Berrangé" <berrange@redhat.com>, qemu-devel@nongnu.org
Cc: "Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Thomas Huth" <thuth@redhat.com>, "Mads Ynddal" <mads@ynddal.dk>,
"Stefan Hajnoczi" <stefanha@redhat.com>,
"Alex Bennée" <alex.bennee@linaro.org>
Subject: Re: [PATCH v2 5/6] tracetool: add test suite for tracetool with reference output
Date: Wed, 6 Aug 2025 16:58:26 +0200 [thread overview]
Message-ID: <24abd83e-aa9e-4f02-b391-178249e9bdf5@redhat.com> (raw)
In-Reply-To: <20250806102440.702545-6-berrange@redhat.com>
On 8/6/25 12:24, Daniel P. Berrangé wrote:
> +#line 48 "../../../../../../../../dev/stdout"
These line directives depend on the name of the QEMU build directory...
> + args += [events,
> + "/dev/stdout"]
... because you're using an absolute path here.
Maybe you can use a temporary directory, in which you copy the source
file as well?
Paolo
> + actual = check_output(args)
> +
> + if os.getenv("QEMU_TEST_REGENERATE", False):
> + print(f"# regenerate {filename}")
> + with open(filename, "wb") as fh:
> + fh.write(actual)
> +
> + with open(filename, "rb") as fh:
> + expect = fh.read()
> +
> + assert(expect == actual)
> +
> +def test_tracetool(tracetool, events, backend):
> + fail = False
> + scenarios = len(get_formats(backend))
> +
> + print(f"1..{scenarios}")
> +
> + num = 1
> + for fmt in get_formats(backend):
> + status = "not ok"
> + hint = ""
> + try:
> + test_tracetool_one(tracetool, events, backend, fmt)
> + status = "ok"
> + except Exception as e:
> + print(f"# {e}")
> + fail = True
> + hint = " (set QEMU_TEST_REGENERATE=1 to recreate reference " + \
> + "output if tracetool generator was intentionally changed)"
> + finally:
> + print(f"{status} {num} - {backend}.{fmt}{hint}")
> +
> + return fail
> +
> +
> +if __name__ == '__main__':
> + if len(sys.argv) != 4:
> + argv0 = sys.argv[0]
> + print("syntax: {argv0} TRACE-TOOL TRACE-EVENTS BACKEND", file=sys.stderr)
> + sys.exit(1)
> +
> + fail = test_tracetool(sys.argv[1], sys.argv[2], sys.argv[3])
> + if fail:
> + sys.exit(1)
> + sys.exit(0)
> diff --git a/tests/tracetool/ust.c b/tests/tracetool/ust.c
> new file mode 100644
> index 0000000000..9f862fa14d
> --- /dev/null
> +++ b/tests/tracetool/ust.c
> @@ -0,0 +1,32 @@
> +/* This file is autogenerated by tracetool, do not edit. */
> +/* SPDX-License-Identifier: GPL-2.0-or-later */
> +
> +#include "qemu/osdep.h"
> +#include "qemu/module.h"
> +#include "trace-testsuite.h"
> +
> +uint16_t _TRACE_TEST_BLAH_DSTATE;
> +uint16_t _TRACE_TEST_WIBBLE_DSTATE;
> +TraceEvent _TRACE_TEST_BLAH_EVENT = {
> + .id = 0,
> + .name = "test_blah",
> + .sstate = TRACE_TEST_BLAH_ENABLED,
> + .dstate = &_TRACE_TEST_BLAH_DSTATE
> +};
> +TraceEvent _TRACE_TEST_WIBBLE_EVENT = {
> + .id = 0,
> + .name = "test_wibble",
> + .sstate = TRACE_TEST_WIBBLE_ENABLED,
> + .dstate = &_TRACE_TEST_WIBBLE_DSTATE
> +};
> +TraceEvent *testsuite_trace_events[] = {
> + &_TRACE_TEST_BLAH_EVENT,
> + &_TRACE_TEST_WIBBLE_EVENT,
> + NULL,
> +};
> +
> +static void trace_testsuite_register_events(void)
> +{
> + trace_event_register_group(testsuite_trace_events);
> +}
> +trace_init(trace_testsuite_register_events)
> diff --git a/tests/tracetool/ust.h b/tests/tracetool/ust.h
> new file mode 100644
> index 0000000000..1184ddd870
> --- /dev/null
> +++ b/tests/tracetool/ust.h
> @@ -0,0 +1,55 @@
> +/* This file is autogenerated by tracetool, do not edit. */
> +/* SPDX-License-Identifier: GPL-2.0-or-later */
> +
> +#ifndef TRACE_TESTSUITE_GENERATED_TRACERS_H
> +#define TRACE_TESTSUITE_GENERATED_TRACERS_H
> +
> +#include "trace/control.h"
> +
> +extern TraceEvent _TRACE_TEST_BLAH_EVENT;
> +extern TraceEvent _TRACE_TEST_WIBBLE_EVENT;
> +extern uint16_t _TRACE_TEST_BLAH_DSTATE;
> +extern uint16_t _TRACE_TEST_WIBBLE_DSTATE;
> +#define TRACE_TEST_BLAH_ENABLED 1
> +#define TRACE_TEST_WIBBLE_ENABLED 1
> +#include <lttng/tracepoint.h>
> +#include "trace-ust-testsuite.h"
> +
> +/* tracepoint_enabled() was introduced in LTTng UST 2.7 */
> +#ifndef tracepoint_enabled
> +#define tracepoint_enabled(a, b) true
> +#endif
> +
> +
> +#define TRACE_TEST_BLAH_BACKEND_DSTATE() ( \
> + tracepoint_enabled(qemu, test_blah) || \
> + false)
> +
> +static inline void _nocheck__trace_test_blah(void *context, const char *filename)
> +{
> + tracepoint(qemu, test_blah, context, filename);
> +}
> +
> +static inline void trace_test_blah(void *context, const char *filename)
> +{
> + if (true) {
> + _nocheck__trace_test_blah(context, filename);
> + }
> +}
> +
> +#define TRACE_TEST_WIBBLE_BACKEND_DSTATE() ( \
> + tracepoint_enabled(qemu, test_wibble) || \
> + false)
> +
> +static inline void _nocheck__trace_test_wibble(void *context, int value)
> +{
> + tracepoint(qemu, test_wibble, context, value);
> +}
> +
> +static inline void trace_test_wibble(void *context, int value)
> +{
> + if (true) {
> + _nocheck__trace_test_wibble(context, value);
> + }
> +}
> +#endif /* TRACE_TESTSUITE_GENERATED_TRACERS_H */
> diff --git a/tests/tracetool/ust.ust-events-c b/tests/tracetool/ust.ust-events-c
> new file mode 100644
> index 0000000000..db23224056
> --- /dev/null
> +++ b/tests/tracetool/ust.ust-events-c
> @@ -0,0 +1,14 @@
> +/* This file is autogenerated by tracetool, do not edit. */
> +/* SPDX-License-Identifier: GPL-2.0-or-later */
> +
> +#include "qemu/osdep.h"
> +
> +#define TRACEPOINT_DEFINE
> +#define TRACEPOINT_CREATE_PROBES
> +
> +/* If gcc version 4.7 or older is used, LTTng ust gives a warning when compiling with
> + -Wredundant-decls.
> + */
> +#pragma GCC diagnostic ignored "-Wredundant-decls"
> +
> +#include "trace-ust-all.h"
> diff --git a/tests/tracetool/ust.ust-events-h b/tests/tracetool/ust.ust-events-h
> new file mode 100644
> index 0000000000..4621a995fc
> --- /dev/null
> +++ b/tests/tracetool/ust.ust-events-h
> @@ -0,0 +1,56 @@
> +/* This file is autogenerated by tracetool, do not edit. */
> +/* SPDX-License-Identifier: GPL-2.0-or-later */
> +
> +#undef TRACEPOINT_PROVIDER
> +#define TRACEPOINT_PROVIDER qemu
> +
> +#undef TRACEPOINT_INCLUDE
> +#define TRACEPOINT_INCLUDE "./trace-ust.h"
> +
> +#if !defined (TRACE_TESTSUITE_GENERATED_UST_H) || \
> + defined(TRACEPOINT_HEADER_MULTI_READ)
> +#define TRACE_TESTSUITE_GENERATED_UST_H
> +
> +#include <lttng/tracepoint.h>
> +
> +/*
> + * LTTng ust 2.0 does not allow you to use TP_ARGS(void) for tracepoints
> + * requiring no arguments. We define these macros introduced in more recent * versions of LTTng ust as a workaround
> + */
> +#ifndef _TP_EXPROTO1
> +#define _TP_EXPROTO1(a) void
> +#endif
> +#ifndef _TP_EXDATA_PROTO1
> +#define _TP_EXDATA_PROTO1(a) void *__tp_data
> +#endif
> +#ifndef _TP_EXDATA_VAR1
> +#define _TP_EXDATA_VAR1(a) __tp_data
> +#endif
> +#ifndef _TP_EXVAR1
> +#define _TP_EXVAR1(a)
> +#endif
> +
> +TRACEPOINT_EVENT(
> + qemu,
> + test_blah,
> + TP_ARGS(void *, context, const char *, filename),
> + TP_FIELDS(
> + ctf_integer_hex(void *, context, context)
> + ctf_string(filename, filename)
> + )
> +)
> +
> +TRACEPOINT_EVENT(
> + qemu,
> + test_wibble,
> + TP_ARGS(void *, context, int, value),
> + TP_FIELDS(
> + ctf_integer_hex(void *, context, context)
> + ctf_integer(int, value, value)
> + )
> +)
> +
> +#endif /* TRACE_TESTSUITE_GENERATED_UST_H */
> +
> +/* This part must be outside ifdef protection */
> +#include <lttng/tracepoint-event.h>
next prev parent reply other threads:[~2025-08-06 15:12 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-06 10:24 [PATCH v2 0/6] tracetool: add test suite to improve reviewability Daniel P. Berrangé
2025-08-06 10:24 ` [PATCH v2 1/6] checkpatch: cull trailing '*/' in SPDX check Daniel P. Berrangé
2025-08-06 10:24 ` [PATCH v2 2/6] tracetool: eliminate trailing whitespace in C format Daniel P. Berrangé
2025-08-06 10:24 ` [PATCH v2 3/6] tracetool: avoid space after "*" in arg types Daniel P. Berrangé
2025-08-06 10:24 ` [PATCH v2 4/6] tracetool: include SPDX-License-Identifier in generated files Daniel P. Berrangé
2025-08-06 10:24 ` [PATCH v2 5/6] tracetool: add test suite for tracetool with reference output Daniel P. Berrangé
2025-08-06 11:20 ` Markus Armbruster
2025-08-06 11:39 ` Daniel P. Berrangé
2025-08-06 14:58 ` Paolo Bonzini [this message]
2025-08-06 16:47 ` Daniel P. Berrangé
2025-08-06 10:24 ` [PATCH v2 6/6] tracetool: drop the probe "__nocheck__" wrapping Daniel P. Berrangé
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=24abd83e-aa9e-4f02-b391-178249e9bdf5@redhat.com \
--to=pbonzini@redhat.com \
--cc=alex.bennee@linaro.org \
--cc=berrange@redhat.com \
--cc=mads@ynddal.dk \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
--cc=thuth@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).