This will be used to demonstrate that tracetool outputs the bare minimum of code when tracing is disabled. Currently, as of this initial commit of reference output, too much code is generated.
Reviewed-by: Marc-André Lureau <[email protected]> Signed-off-by: Daniel P. Berrangé <[email protected]> --- tests/tracetool/meson.build | 1 + tests/tracetool/nop.c | 36 ++++++++++++++++++++++ tests/tracetool/nop.h | 29 ++++++++++++++++++ tests/tracetool/nop.rs | 51 +++++++++++++++++++++++++++++++ tests/tracetool/tracetool-test.py | 2 +- 5 files changed, 118 insertions(+), 1 deletion(-) create mode 100644 tests/tracetool/nop.c create mode 100644 tests/tracetool/nop.h create mode 100644 tests/tracetool/nop.rs diff --git a/tests/tracetool/meson.build b/tests/tracetool/meson.build index 09bbaaa86bf..f4f583e6224 100644 --- a/tests/tracetool/meson.build +++ b/tests/tracetool/meson.build @@ -5,6 +5,7 @@ test_env.set('PYTHONPATH', meson.project_source_root() / 'scripts') test_env.set('PYTHONIOENCODING', 'utf-8') backends = [ + 'nop', 'dtrace', 'ftrace', 'log', diff --git a/tests/tracetool/nop.c b/tests/tracetool/nop.c new file mode 100644 index 00000000000..f83d06252ea --- /dev/null +++ b/tests/tracetool/nop.c @@ -0,0 +1,36 @@ +/* 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" + +uint8_t _TRACE_TEST_BLAH_DSTATE; +uint8_t _TRACE_TEST_WIBBLE_DSTATE; +TraceEvent _TRACE_TEST_BLAH_EVENT = { +#ifdef CONFIG_TRACE_SIMPLE + .id = 0, +#endif + .name = "test_blah", + .sstate = TRACE_TEST_BLAH_ENABLED, + .dstate = &_TRACE_TEST_BLAH_DSTATE +}; +TraceEvent _TRACE_TEST_WIBBLE_EVENT = { +#ifdef CONFIG_TRACE_SIMPLE + .id = 0, +#endif + .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/nop.h b/tests/tracetool/nop.h new file mode 100644 index 00000000000..443f5e0cf6e --- /dev/null +++ b/tests/tracetool/nop.h @@ -0,0 +1,29 @@ +/* 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 uint8_t _TRACE_TEST_BLAH_DSTATE; +extern uint8_t _TRACE_TEST_WIBBLE_DSTATE; +#define TRACE_TEST_BLAH_ENABLED 1 +#define TRACE_TEST_WIBBLE_ENABLED 1 + +#define TRACE_TEST_BLAH_BACKEND_DSTATE() ( \ + false) + +static inline void trace_test_blah(void *context, const char *filename) +{ +} + +#define TRACE_TEST_WIBBLE_BACKEND_DSTATE() ( \ + false) + +static inline void trace_test_wibble(void *context, int value) +{ +} +#endif /* TRACE_TESTSUITE_GENERATED_TRACERS_H */ diff --git a/tests/tracetool/nop.rs b/tests/tracetool/nop.rs new file mode 100644 index 00000000000..5f007cecd04 --- /dev/null +++ b/tests/tracetool/nop.rs @@ -0,0 +1,51 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +// This file is @generated by tracetool, do not edit. + +#[allow(unused_imports)] +use std::ffi::c_char; +#[allow(unused_imports)] +use util::bindings; + +#[allow(dead_code)] +#[inline(always)] +fn trace_event_state_is_enabled(dstate: u8) -> bool { + (unsafe { trace_events_enabled_count }) != 0 && dstate != 0 +} + +extern "C" { + #[allow(dead_code)] + static mut trace_events_enabled_count: u32; +} +extern "C" { + #[allow(dead_code)] + static mut _TRACE_TEST_BLAH_DSTATE: u8; + #[allow(dead_code)] + static mut _TRACE_TEST_WIBBLE_DSTATE: u8; +} + +#[inline(always)] +#[allow(dead_code)] +pub fn trace_test_blah_enabled() -> bool +{ + false +} + +#[inline(always)] +#[allow(dead_code)] +pub fn trace_test_blah(_context: *mut (), _filename: &std::ffi::CStr) +{ +} + +#[inline(always)] +#[allow(dead_code)] +pub fn trace_test_wibble_enabled() -> bool +{ + false +} + +#[inline(always)] +#[allow(dead_code)] +pub fn trace_test_wibble(_context: *mut (), _value: std::ffi::c_int) +{ +} + diff --git a/tests/tracetool/tracetool-test.py b/tests/tracetool/tracetool-test.py index 59e9ab3d6ef..74f315a4629 100755 --- a/tests/tracetool/tracetool-test.py +++ b/tests/tracetool/tracetool-test.py @@ -14,7 +14,7 @@ def get_formats(backend): "c", "h", ] - if backend in {"dtrace", "ftrace", "log", "simple", "syslog"}: + if backend in {"nop", "dtrace", "ftrace", "log", "simple", "syslog"}: formats += ["rs"] if backend == "dtrace": formats += [ -- 2.55.0
