From 729c1fec5976af17fded2f026725a08ef1924290 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Mon, 6 Sep 2021 09:45:35 -0400 Subject: [PATCH] tests: compile some tools/tests as C++ MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit These tests use things from the common libs, or at least include header files from src/common. These files are going to contain C++-specific things in a following commit, so it's easier if we compile them tools/tests as C++. Change-Id: Ib99f2373beb414c50eaa10b35e0d895bc37e4e64 Signed-off-by: Simon Marchi Signed-off-by: Jérémie Galarneau --- .../Makefile.am | 2 +- ...ation-client.c => notification-client.cpp} | 0 tests/regression/tools/live/Makefile.am | 2 +- .../tools/live/{live_test.c => live_test.cpp} | 8 +++--- .../regression/tools/notification/Makefile.am | 8 +++--- .../notification/consumer_testpoints.cpp | 3 ++- .../{notification.c => notification.cpp} | 2 +- .../tools/trigger/hidden/Makefile.am | 3 +-- .../{hidden_trigger.c => hidden_trigger.cpp} | 25 +++++++++++-------- .../regression/tools/trigger/name/Makefile.am | 4 +-- .../name/{trigger_name.c => trigger_name.cpp} | 0 .../tools/trigger/utils/Makefile.am | 4 +-- ...-triggers.c => register-some-triggers.cpp} | 0 tests/utils/Makefile.am | 4 ++- tests/utils/testapp/gen-ns-events/Makefile.am | 2 +- .../{gen-ns-events.c => gen-ns-events.cpp} | 0 .../testapp/gen-syscall-events/Makefile.am | 4 +-- ...yscall-events.c => gen-syscall-events.cpp} | 0 .../testapp/gen-ust-events-ns/Makefile.am | 5 +++- ...-ust-events-ns.c => gen-ust-events-ns.cpp} | 0 .../utils/testapp/gen-ust-events/Makefile.am | 5 +++- .../{gen-ust-events.c => gen-ust-events.cpp} | 0 .../testapp/gen-ust-nevents-str/Makefile.am | 5 +++- ...-nevents-str.c => gen-ust-nevents-str.cpp} | 0 .../utils/testapp/gen-ust-nevents/Makefile.am | 5 +++- ...{gen-ust-nevents.c => gen-ust-nevents.cpp} | 0 .../utils/testapp/gen-ust-tracef/Makefile.am | 2 +- .../{gen-ust-tracef.c => gen-ust-tracef.cpp} | 0 tests/utils/testapp/signal-helper.h | 7 +++--- tests/utils/{utils.c => utils.cpp} | 0 tests/utils/utils.h | 8 ++++++ tests/utils/xml-utils/Makefile.am | 4 +-- .../{extract_xml.c => extract_xml.cpp} | 0 .../{validate_xml.c => validate_xml.cpp} | 0 34 files changed, 68 insertions(+), 44 deletions(-) rename doc/examples/trigger-condition-event-matches/{notification-client.c => notification-client.cpp} (100%) rename tests/regression/tools/live/{live_test.c => live_test.cpp} (98%) rename tests/regression/tools/notification/{notification.c => notification.cpp} (99%) rename tests/regression/tools/trigger/hidden/{hidden_trigger.c => hidden_trigger.cpp} (91%) rename tests/regression/tools/trigger/name/{trigger_name.c => trigger_name.cpp} (100%) rename tests/regression/tools/trigger/utils/{register-some-triggers.c => register-some-triggers.cpp} (100%) rename tests/utils/testapp/gen-ns-events/{gen-ns-events.c => gen-ns-events.cpp} (100%) rename tests/utils/testapp/gen-syscall-events/{gen-syscall-events.c => gen-syscall-events.cpp} (100%) rename tests/utils/testapp/gen-ust-events-ns/{gen-ust-events-ns.c => gen-ust-events-ns.cpp} (100%) rename tests/utils/testapp/gen-ust-events/{gen-ust-events.c => gen-ust-events.cpp} (100%) rename tests/utils/testapp/gen-ust-nevents-str/{gen-ust-nevents-str.c => gen-ust-nevents-str.cpp} (100%) rename tests/utils/testapp/gen-ust-nevents/{gen-ust-nevents.c => gen-ust-nevents.cpp} (100%) rename tests/utils/testapp/gen-ust-tracef/{gen-ust-tracef.c => gen-ust-tracef.cpp} (100%) rename tests/utils/{utils.c => utils.cpp} (100%) rename tests/utils/xml-utils/{extract_xml.c => extract_xml.cpp} (100%) rename tests/utils/xml-utils/{validate_xml.c => validate_xml.cpp} (100%) diff --git a/doc/examples/trigger-condition-event-matches/Makefile.am b/doc/examples/trigger-condition-event-matches/Makefile.am index bace545b9..cb5512ed0 100644 --- a/doc/examples/trigger-condition-event-matches/Makefile.am +++ b/doc/examples/trigger-condition-event-matches/Makefile.am @@ -15,7 +15,7 @@ libtracepoint_trigger_example_a_SOURCES = tracepoint-trigger-example.c tracepoin instrumented_app_SOURCES = instrumented-app.c instrumented_app_LDADD = libtracepoint-trigger-example.a $(UST_LIBS) $(DL_LIBS) -notification_client_SOURCES = notification-client.c +notification_client_SOURCES = notification-client.cpp notification_client_LDADD = $(LIBLTTNG_CTL) endif diff --git a/doc/examples/trigger-condition-event-matches/notification-client.c b/doc/examples/trigger-condition-event-matches/notification-client.cpp similarity index 100% rename from doc/examples/trigger-condition-event-matches/notification-client.c rename to doc/examples/trigger-condition-event-matches/notification-client.cpp diff --git a/tests/regression/tools/live/Makefile.am b/tests/regression/tools/live/Makefile.am index 1587deb12..c67cde86d 100644 --- a/tests/regression/tools/live/Makefile.am +++ b/tests/regression/tools/live/Makefile.am @@ -19,7 +19,7 @@ if HAVE_LIBLTTNG_UST_CTL EXTRA_DIST += test_ust test_ust_tracefile_count test_lttng_ust endif -live_test_SOURCES = live_test.c +live_test_SOURCES = live_test.cpp live_test_LDADD = $(LIBTAP) $(LIBLTTNG_SESSIOND_COMMON) $(DL_LIBS) all-local: diff --git a/tests/regression/tools/live/live_test.c b/tests/regression/tools/live/live_test.cpp similarity index 98% rename from tests/regression/tools/live/live_test.c rename to tests/regression/tools/live/live_test.cpp index 40d0f6270..afaf23b65 100644 --- a/tests/regression/tools/live/live_test.c +++ b/tests/regression/tools/live/live_test.cpp @@ -76,7 +76,7 @@ ssize_t lttng_live_recv(int fd, void *buf, size_t len) size_t copied = 0, to_copy = len; do { - ret = recv(fd, buf + copied, to_copy, 0); + ret = recv(fd, (char *) buf + copied, to_copy, 0); if (ret > 0) { LTTNG_ASSERT(ret <= to_copy); copied += ret; @@ -285,7 +285,7 @@ int attach_session(uint64_t id) int i; ssize_t ret_len; - session = zmalloc(sizeof(struct live_session)); + session = (live_session *) zmalloc(sizeof(struct live_session)); if (!session) { goto error; } @@ -327,7 +327,7 @@ int attach_session(uint64_t id) diag("Got session stream count == 0"); goto error; } - session->streams = zmalloc(session->stream_count * + session->streams = (viewer_stream *) zmalloc(session->stream_count * sizeof(struct viewer_stream)); if (!session->streams) { goto error; @@ -436,7 +436,7 @@ retry: goto error; } - data = zmalloc(len); + data = (char *) zmalloc(len); if (!data) { PERROR("relay data zmalloc"); goto error; diff --git a/tests/regression/tools/notification/Makefile.am b/tests/regression/tools/notification/Makefile.am index 2f1a9174e..4029a2126 100644 --- a/tests/regression/tools/notification/Makefile.am +++ b/tests/regression/tools/notification/Makefile.am @@ -1,6 +1,6 @@ # SPDX-License-Identifier: GPL-2.0-only -AM_CFLAGS += -I$(top_srcdir)/tests/utils +AM_CPPFLAGS += -I$(top_srcdir)/tests/utils LIBTAP=$(top_builddir)/tests/utils/tap/libtap.la LIB_LTTNG_CTL = $(top_builddir)/src/lib/lttng-ctl/liblttng-ctl.la @@ -14,7 +14,7 @@ EXTRA_DIST = \ base_client.c \ consumer_testpoints.cpp \ sessiond_testpoints.cpp \ - notification.c \ + notification.cpp \ test_notification_kernel_buffer_usage \ test_notification_kernel_capture \ test_notification_kernel_error \ @@ -54,9 +54,9 @@ noinst_LTLIBRARIES = libpause_sessiond.la libpause_consumer.la base_client_SOURCES = base_client.c base_client_LDADD = $(LIB_LTTNG_CTL) -notification_SOURCES = notification.c +notification_SOURCES = notification.cpp # Tests the deprecated lttng_register_trigger() interface -notification_CFLAGS = -Wno-deprecated-declarations $(AM_CFLAGS) +notification_CXXFLAGS = -Wno-deprecated-declarations $(AM_CXXFLAGS) notification_LDADD = $(LIB_LTTNG_CTL) $(LIBTAP) -lm rotation_SOURCES = rotation.c diff --git a/tests/regression/tools/notification/consumer_testpoints.cpp b/tests/regression/tools/notification/consumer_testpoints.cpp index 07c855c9c..05db3421a 100644 --- a/tests/regression/tools/notification/consumer_testpoints.cpp +++ b/tests/regression/tools/notification/consumer_testpoints.cpp @@ -20,7 +20,8 @@ static char *pause_pipe_path; static struct lttng_pipe *pause_pipe; static int *data_consumption_state; -static enum lttng_consumer_type (*lttng_consumer_get_type)(void); +using lttng_consumer_get_type_func = enum lttng_consumer_type (*)(); +static lttng_consumer_get_type_func lttng_consumer_get_type; int lttng_opt_verbose; int lttng_opt_mi; diff --git a/tests/regression/tools/notification/notification.c b/tests/regression/tools/notification/notification.cpp similarity index 99% rename from tests/regression/tools/notification/notification.c rename to tests/regression/tools/notification/notification.cpp index a56b7945d..7a0b5dc91 100644 --- a/tests/regression/tools/notification/notification.c +++ b/tests/regression/tools/notification/notification.cpp @@ -49,7 +49,7 @@ enum field_type { }; struct capture_base_field_tuple { - char* field_name; + const char *field_name; enum field_type field_type; /* Do we expect a userspace capture? */ bool expected_ust; diff --git a/tests/regression/tools/trigger/hidden/Makefile.am b/tests/regression/tools/trigger/hidden/Makefile.am index ef383fde9..205331c92 100644 --- a/tests/regression/tools/trigger/hidden/Makefile.am +++ b/tests/regression/tools/trigger/hidden/Makefile.am @@ -6,8 +6,7 @@ LIBTAP=$(top_builddir)/tests/utils/tap/libtap.la LIBLTTNG_CTL=$(top_builddir)/src/lib/lttng-ctl/liblttng-ctl.la noinst_PROGRAMS = hidden_trigger -hidden_trigger_CFLAGS = $(AM_CFLAGS) -hidden_trigger_SOURCES = hidden_trigger.c +hidden_trigger_SOURCES = hidden_trigger.cpp hidden_trigger_LDADD = $(LIBTAP) $(LIBLTTNG_CTL) noinst_SCRIPTS = test_hidden_trigger diff --git a/tests/regression/tools/trigger/hidden/hidden_trigger.c b/tests/regression/tools/trigger/hidden/hidden_trigger.cpp similarity index 91% rename from tests/regression/tools/trigger/hidden/hidden_trigger.c rename to tests/regression/tools/trigger/hidden/hidden_trigger.cpp index 8edd97ab2..668a60fb3 100644 --- a/tests/regression/tools/trigger/hidden/hidden_trigger.c +++ b/tests/regression/tools/trigger/hidden/hidden_trigger.cpp @@ -62,18 +62,21 @@ int setup_session_with_size_rotation_schedule(const char *session_output_path) struct lttng_session_descriptor *session_desriptor = NULL; enum lttng_error_code ret_code; struct lttng_handle ust_channel_handle = { - .session_name = TEST_SESSION_NAME, - .domain.type = LTTNG_DOMAIN_UST, - .domain.buf_type = LTTNG_BUFFER_PER_UID, - }; - struct lttng_channel channel_cfg = { - .name = TEST_CHANNEL_NAME, - .enabled = 1, - .attr.overwrite = -1, - .attr.subbuf_size = sysconf(_SC_PAGE_SIZE) * 8, - .attr.num_subbuf = 8, - .attr.output = LTTNG_EVENT_MMAP, + TEST_SESSION_NAME, + { + .type = LTTNG_DOMAIN_UST, + .buf_type = LTTNG_BUFFER_PER_UID, + } }; + + lttng_channel channel_cfg {}; + strcpy(channel_cfg.name, TEST_CHANNEL_NAME); + channel_cfg.enabled = 1; + channel_cfg.attr.overwrite = -1; + channel_cfg.attr.subbuf_size = (uint64_t) sysconf(_SC_PAGE_SIZE) * 8; + channel_cfg.attr.num_subbuf = 8; + channel_cfg.attr.output = LTTNG_EVENT_MMAP; + enum lttng_rotation_status rotation_status; struct lttng_rotation_schedule *rotation_schedule = NULL; diff --git a/tests/regression/tools/trigger/name/Makefile.am b/tests/regression/tools/trigger/name/Makefile.am index d4bc5ed06..bd267b886 100644 --- a/tests/regression/tools/trigger/name/Makefile.am +++ b/tests/regression/tools/trigger/name/Makefile.am @@ -7,8 +7,8 @@ LIBLTTNG_CTL=$(top_builddir)/src/lib/lttng-ctl/liblttng-ctl.la noinst_PROGRAMS = trigger_name # This test explicitly tests APIs that were marked as deprecated. -trigger_name_CFLAGS = -Wno-deprecated-declarations $(AM_CFLAGS) -trigger_name_SOURCES = trigger_name.c +trigger_name_CXXFLAGS = -Wno-deprecated-declarations $(AM_CXXFLAGS) +trigger_name_SOURCES = trigger_name.cpp trigger_name_LDADD = $(LIBTAP) $(LIBLTTNG_CTL) noinst_SCRIPTS = test_trigger_name_backwards_compat diff --git a/tests/regression/tools/trigger/name/trigger_name.c b/tests/regression/tools/trigger/name/trigger_name.cpp similarity index 100% rename from tests/regression/tools/trigger/name/trigger_name.c rename to tests/regression/tools/trigger/name/trigger_name.cpp diff --git a/tests/regression/tools/trigger/utils/Makefile.am b/tests/regression/tools/trigger/utils/Makefile.am index 21fb53112..dd3b0278f 100644 --- a/tests/regression/tools/trigger/utils/Makefile.am +++ b/tests/regression/tools/trigger/utils/Makefile.am @@ -1,6 +1,6 @@ # SPDX-License-Identifier: GPL-2.0-only -AM_CFLAGS += -I$(srcdir) -I$(top_srcdir)/tests/utils +AM_CPPFLAGS += -I$(srcdir) -I$(top_srcdir)/tests/utils LIBLTTNG_CTL=$(top_builddir)/src/lib/lttng-ctl/liblttng-ctl.la noinst_PROGRAMS = \ @@ -11,7 +11,7 @@ notification_client_SOURCES = notification-client.c notification_client_LDADD = $(LIBLTTNG_CTL) \ $(top_builddir)/tests/utils/libtestutils.la -register_some_triggers_SOURCES = register-some-triggers.c +register_some_triggers_SOURCES = register-some-triggers.cpp register_some_triggers_LDADD = $(LIBLTTNG_CTL) \ $(top_builddir)/src/common/filter/libfilter.la \ $(top_builddir)/src/common/bytecode/libbytecode.la diff --git a/tests/regression/tools/trigger/utils/register-some-triggers.c b/tests/regression/tools/trigger/utils/register-some-triggers.cpp similarity index 100% rename from tests/regression/tools/trigger/utils/register-some-triggers.c rename to tests/regression/tools/trigger/utils/register-some-triggers.cpp diff --git a/tests/utils/Makefile.am b/tests/utils/Makefile.am index 1c7c95326..96dbe2852 100644 --- a/tests/utils/Makefile.am +++ b/tests/utils/Makefile.am @@ -7,7 +7,9 @@ EXTRA_DIST = utils.sh test_utils.py babelstats.pl warn_processes.sh \ dist_noinst_SCRIPTS = utils.sh test_utils.py babelstats.pl tap-driver.sh noinst_LTLIBRARIES = libtestutils.la -libtestutils_la_SOURCES = utils.c utils.h +libtestutils_la_SOURCES = \ + utils.cpp \ + utils.h all-local: @if [ x"$(srcdir)" != x"$(builddir)" ]; then \ diff --git a/tests/utils/testapp/gen-ns-events/Makefile.am b/tests/utils/testapp/gen-ns-events/Makefile.am index adc76ee52..5c1cddefe 100644 --- a/tests/utils/testapp/gen-ns-events/Makefile.am +++ b/tests/utils/testapp/gen-ns-events/Makefile.am @@ -4,7 +4,7 @@ AM_CPPFLAGS += -I$(top_srcdir)/tests/utils -I$(srcdir) \ -I$(top_srcdir)/tests/utils/testapp noinst_PROGRAMS = gen-ns-events -gen_ns_events_SOURCES = gen-ns-events.c +gen_ns_events_SOURCES = gen-ns-events.cpp gen_ns_events_LDADD = \ $(top_builddir)/tests/utils/libtestutils.la \ $(DL_LIBS) $(POPT_LIBS) diff --git a/tests/utils/testapp/gen-ns-events/gen-ns-events.c b/tests/utils/testapp/gen-ns-events/gen-ns-events.cpp similarity index 100% rename from tests/utils/testapp/gen-ns-events/gen-ns-events.c rename to tests/utils/testapp/gen-ns-events/gen-ns-events.cpp diff --git a/tests/utils/testapp/gen-syscall-events/Makefile.am b/tests/utils/testapp/gen-syscall-events/Makefile.am index 3f3a77fa7..59ac2f3a9 100644 --- a/tests/utils/testapp/gen-syscall-events/Makefile.am +++ b/tests/utils/testapp/gen-syscall-events/Makefile.am @@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-only -AM_CFLAGS += -I$(top_srcdir)/tests/utils/ +AM_CPPFLAGS += -I$(top_srcdir)/tests/utils noinst_PROGRAMS = gen-syscall-events -gen_syscall_events_SOURCES = gen-syscall-events.c +gen_syscall_events_SOURCES = gen-syscall-events.cpp gen_syscall_events_LDADD = $(top_builddir)/tests/utils/libtestutils.la diff --git a/tests/utils/testapp/gen-syscall-events/gen-syscall-events.c b/tests/utils/testapp/gen-syscall-events/gen-syscall-events.cpp similarity index 100% rename from tests/utils/testapp/gen-syscall-events/gen-syscall-events.c rename to tests/utils/testapp/gen-syscall-events/gen-syscall-events.cpp diff --git a/tests/utils/testapp/gen-ust-events-ns/Makefile.am b/tests/utils/testapp/gen-ust-events-ns/Makefile.am index 35e6d6700..2e3ad0747 100644 --- a/tests/utils/testapp/gen-ust-events-ns/Makefile.am +++ b/tests/utils/testapp/gen-ust-events-ns/Makefile.am @@ -5,7 +5,10 @@ AM_CPPFLAGS += -I$(top_srcdir)/tests/utils -I$(srcdir) \ if HAVE_LIBLTTNG_UST_CTL noinst_PROGRAMS = gen-ust-events-ns -gen_ust_events_ns_SOURCES = gen-ust-events-ns.c tp.c tp.h +gen_ust_events_ns_SOURCES = \ + gen-ust-events-ns.cpp \ + tp.c \ + tp.h gen_ust_events_ns_LDADD = $(UST_LIBS) -llttng-ust-fork \ $(top_builddir)/tests/utils/libtestutils.la \ $(DL_LIBS) $(POPT_LIBS) diff --git a/tests/utils/testapp/gen-ust-events-ns/gen-ust-events-ns.c b/tests/utils/testapp/gen-ust-events-ns/gen-ust-events-ns.cpp similarity index 100% rename from tests/utils/testapp/gen-ust-events-ns/gen-ust-events-ns.c rename to tests/utils/testapp/gen-ust-events-ns/gen-ust-events-ns.cpp diff --git a/tests/utils/testapp/gen-ust-events/Makefile.am b/tests/utils/testapp/gen-ust-events/Makefile.am index f377de58b..c05c665a1 100644 --- a/tests/utils/testapp/gen-ust-events/Makefile.am +++ b/tests/utils/testapp/gen-ust-events/Makefile.am @@ -5,7 +5,10 @@ AM_CPPFLAGS += -I$(top_srcdir)/tests/utils -I$(srcdir) \ if HAVE_LIBLTTNG_UST_CTL noinst_PROGRAMS = gen-ust-events -gen_ust_events_SOURCES = gen-ust-events.c tp.c tp.h +gen_ust_events_SOURCES = \ + gen-ust-events.cpp \ + tp.c \ + tp.h gen_ust_events_LDADD = $(UST_LIBS) \ $(top_builddir)/tests/utils/libtestutils.la \ $(DL_LIBS) diff --git a/tests/utils/testapp/gen-ust-events/gen-ust-events.c b/tests/utils/testapp/gen-ust-events/gen-ust-events.cpp similarity index 100% rename from tests/utils/testapp/gen-ust-events/gen-ust-events.c rename to tests/utils/testapp/gen-ust-events/gen-ust-events.cpp diff --git a/tests/utils/testapp/gen-ust-nevents-str/Makefile.am b/tests/utils/testapp/gen-ust-nevents-str/Makefile.am index 7330f1fb9..955200c2b 100644 --- a/tests/utils/testapp/gen-ust-nevents-str/Makefile.am +++ b/tests/utils/testapp/gen-ust-nevents-str/Makefile.am @@ -5,7 +5,10 @@ AM_CPPFLAGS += -I$(srcdir) -I$(top_srcdir)/tests/utils \ if HAVE_LIBLTTNG_UST_CTL noinst_PROGRAMS = gen-ust-nevents-str -gen_ust_nevents_str_SOURCES = gen-ust-nevents-str.c tp.c tp.h +gen_ust_nevents_str_SOURCES = \ + gen-ust-nevents-str.cpp \ + tp.c \ + tp.h gen_ust_nevents_str_LDADD = $(UST_LIBS) \ $(top_builddir)/tests/utils/libtestutils.la \ $(DL_LIBS) diff --git a/tests/utils/testapp/gen-ust-nevents-str/gen-ust-nevents-str.c b/tests/utils/testapp/gen-ust-nevents-str/gen-ust-nevents-str.cpp similarity index 100% rename from tests/utils/testapp/gen-ust-nevents-str/gen-ust-nevents-str.c rename to tests/utils/testapp/gen-ust-nevents-str/gen-ust-nevents-str.cpp diff --git a/tests/utils/testapp/gen-ust-nevents/Makefile.am b/tests/utils/testapp/gen-ust-nevents/Makefile.am index 0ddbd9d39..cb869715d 100644 --- a/tests/utils/testapp/gen-ust-nevents/Makefile.am +++ b/tests/utils/testapp/gen-ust-nevents/Makefile.am @@ -5,7 +5,10 @@ AM_CPPFLAGS += -I$(srcdir) -I$(top_srcdir)/tests/utils \ if HAVE_LIBLTTNG_UST_CTL noinst_PROGRAMS = gen-ust-nevents -gen_ust_nevents_SOURCES = gen-ust-nevents.c tp.c tp.h +gen_ust_nevents_SOURCES = \ + gen-ust-nevents.cpp \ + tp.c \ + tp.h gen_ust_nevents_LDADD = $(UST_LIBS) \ $(top_builddir)/tests/utils/libtestutils.la \ $(DL_LIBS) diff --git a/tests/utils/testapp/gen-ust-nevents/gen-ust-nevents.c b/tests/utils/testapp/gen-ust-nevents/gen-ust-nevents.cpp similarity index 100% rename from tests/utils/testapp/gen-ust-nevents/gen-ust-nevents.c rename to tests/utils/testapp/gen-ust-nevents/gen-ust-nevents.cpp diff --git a/tests/utils/testapp/gen-ust-tracef/Makefile.am b/tests/utils/testapp/gen-ust-tracef/Makefile.am index b16f6ce54..17678c697 100644 --- a/tests/utils/testapp/gen-ust-tracef/Makefile.am +++ b/tests/utils/testapp/gen-ust-tracef/Makefile.am @@ -5,6 +5,6 @@ AM_CPPFLAGS += -I$(srcdir) \ if HAVE_LIBLTTNG_UST_CTL noinst_PROGRAMS = gen-ust-tracef -gen_ust_tracef_SOURCES = gen-ust-tracef.c +gen_ust_tracef_SOURCES = gen-ust-tracef.cpp gen_ust_tracef_LDADD = $(UST_LIBS) $(DL_LIBS) endif diff --git a/tests/utils/testapp/gen-ust-tracef/gen-ust-tracef.c b/tests/utils/testapp/gen-ust-tracef/gen-ust-tracef.cpp similarity index 100% rename from tests/utils/testapp/gen-ust-tracef/gen-ust-tracef.c rename to tests/utils/testapp/gen-ust-tracef/gen-ust-tracef.cpp diff --git a/tests/utils/testapp/signal-helper.h b/tests/utils/testapp/signal-helper.h index 8d2668f31..ceadcb372 100644 --- a/tests/utils/testapp/signal-helper.h +++ b/tests/utils/testapp/signal-helper.h @@ -24,10 +24,9 @@ static int set_signal_handler(void) { int ret; - struct sigaction sa = { - .sa_flags = 0, - .sa_handler = sighandler, - }; + struct sigaction sa {}; + sa.sa_flags = 0; + sa.sa_handler = sighandler; ret = sigemptyset(&sa.sa_mask); if (ret) { diff --git a/tests/utils/utils.c b/tests/utils/utils.cpp similarity index 100% rename from tests/utils/utils.c rename to tests/utils/utils.cpp diff --git a/tests/utils/utils.h b/tests/utils/utils.h index afacf8d2f..fc06b4ace 100644 --- a/tests/utils/utils.h +++ b/tests/utils/utils.h @@ -8,6 +8,10 @@ #ifndef TEST_UTILS_H #define TEST_UTILS_H +#if defined(__cplusplus) +extern "C" { +#endif + #if !defined(__GLIBC__) || ((_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && !defined(_GNU_SOURCE)) /* @@ -37,4 +41,8 @@ int usleep_safe(useconds_t usec); int create_file(const char *path); int wait_on_file(const char *path); +#if defined(__cplusplus) +} +#endif + #endif /* TEST_UTILS_H */ diff --git a/tests/utils/xml-utils/Makefile.am b/tests/utils/xml-utils/Makefile.am index 7fac12728..7997d94e1 100644 --- a/tests/utils/xml-utils/Makefile.am +++ b/tests/utils/xml-utils/Makefile.am @@ -1,11 +1,11 @@ # SPDX-License-Identifier: GPL-2.0-only noinst_PROGRAMS = validate_xml extract_xml pretty_xml -validate_xml_SOURCES = validate_xml.c +validate_xml_SOURCES = validate_xml.cpp validate_xml_CPPFLAGS = $(libxml2_CFLAGS) $(AM_CPPFLAGS) validate_xml_LDADD = $(libxml2_LIBS) -extract_xml_SOURCES = extract_xml.c +extract_xml_SOURCES = extract_xml.cpp extract_xml_CPPFLAGS = $(libxml2_CFLAGS) $(AM_CPPFLAGS) extract_xml_LDADD = $(libxml2_LIBS) diff --git a/tests/utils/xml-utils/extract_xml.c b/tests/utils/xml-utils/extract_xml.cpp similarity index 100% rename from tests/utils/xml-utils/extract_xml.c rename to tests/utils/xml-utils/extract_xml.cpp diff --git a/tests/utils/xml-utils/validate_xml.c b/tests/utils/xml-utils/validate_xml.cpp similarity index 100% rename from tests/utils/xml-utils/validate_xml.c rename to tests/utils/xml-utils/validate_xml.cpp -- 2.34.1