tests/regression/tools/mi/Makefile
tests/regression/tools/wildcard/Makefile
tests/regression/tools/crash/Makefile
- tests/regression/tools/metadata-regen/Makefile
+ tests/regression/tools/regen-metadata/Makefile
tests/regression/ust/Makefile
tests/regression/ust/nprocesses/Makefile
tests/regression/ust/high-throughput/Makefile
lttng-enable-event \
lttng-disable-event \
lttng-crash \
- lttng-metadata
+ lttng-metadata \
+ lttng-regenerate
MAN3_NAMES =
MAN8_NAMES = lttng-sessiond lttng-relayd
MAN1_NO_ASCIIDOC_NAMES =
DESCRIPTION
-----------
-The `lttng metadata` command manages a tracing session's metadata
-generation options.
-
-As of this version, only the `regenerate` command's action is available.
-Regenerating a tracing session's metadata can be used to
-resample the offset between the system's monotonic clock and
-the wall-clock time.
-
-This command is meant to be used to resample the wall-clock time
-following a major
-link:https://en.wikipedia.org/wiki/Network_Time_Protocol[NTP]
-correction. As such, a system booting with an incorrect wall time can be
-traced before its wall time is NTP-corrected. Regenerating the tracing
-session's metadata ensures that trace viewers can accurately determine
-the events time relative to Unix Epoch.
+WARNING: This command is **deprecated**; it has been replaced by the *lttng
+regenerate metadata* command (see man:lttng-regenerate(1)).
include::common-cmd-options-head.txt[]
--- /dev/null
+lttng-regenerate(1)
+=================
+
+
+NAME
+----
+lttng-regenerate - Manage an LTTng tracing session's data regeneration
+
+
+SYNOPSIS
+--------
+Regenerate the metadata of a session
+
+[verse]
+*lttng* ['linkgenoptions:(GENERAL OPTIONS)'] *regenerate metadata* [option:--session='SESSION']
+
+DESCRIPTION
+-----------
+The `lttng regenerate` command manages a tracing session's data regeneration
+options.
+
+As of this version, only the `metadata` command's action is available.
+Regenerating a tracing session's metadata can be used to
+resample the offset between the system's monotonic clock and
+the wall-clock time.
+
+This command is meant to be used to resample the wall-clock time
+following a major
+link:https://en.wikipedia.org/wiki/Network_Time_Protocol[NTP]
+correction. As such, a system booting with an incorrect wall time can be
+traced before its wall time is NTP-corrected. Regenerating the tracing
+session's metadata ensures that trace viewers can accurately determine
+the events time relative to Unix Epoch.
+
+
+include::common-cmd-options-head.txt[]
+
+
+option:-s, option:--session='SESSION'::
+ Manage the metadata generation of the tracing session named 'SESSION'
+ instead of the current tracing session.
+
+
+include::common-cmd-help-options.txt[]
+
+
+LIMITATIONS
+-----------
+The `lttng regenerate metadata` command can only be used on kernel and
+user space tracing sessions (using per-user buffering), in non-live
+mode.
+
+See man:lttng-enable-channel(1) for more information about
+buffering schemes and man:lttng-create(1) for more information
+about the different tracing session modes.
+
+
+include::common-cmd-footer.txt[]
+
+
+SEE ALSO
+--------
+man:lttng(1)
*/
extern int lttng_data_pending(const char *session_name);
+/*
+ * Deprecated, replaced by lttng_regenerate_metadata.
+ */
+LTTNG_DEPRECATED()
+extern int lttng_metadata_regenerate(const char *session_name);
+
/*
* Trigger the regeneration of the metadata for a session.
* The new metadata overwrite the previous one locally or remotely (through
* the lttng-relayd). Only kernel, per-uid and non-live sessions are supported.
* Return 0 on success, a negative LTTng error code on error.
*/
-extern int lttng_metadata_regenerate(const char *session_name);
+extern int lttng_regenerate_metadata(const char *session_name);
#ifdef __cplusplus
}
* Return 0 if the metadata can be generated, a LTTNG_ERR code otherwise.
*/
static
-int check_metadata_regenerate_support(struct ltt_session *session)
+int check_regenerate_metadata_support(struct ltt_session *session)
{
int ret;
}
static
-int ust_metadata_regenerate(struct ltt_ust_session *usess)
+int ust_regenerate_metadata(struct ltt_ust_session *usess)
{
int ret = 0;
struct buffer_reg_uid *uid_reg = NULL;
}
/*
- * Command LTTNG_METADATA_REGENERATE from the lttng-ctl library.
+ * Command LTTNG_REGENERATE_METADATA from the lttng-ctl library.
*
* Ask the consumer to truncate the existing metadata file(s) and
* then regenerate the metadata. Live and per-pid sessions are not
*
* Return 0 on success or else a LTTNG_ERR code.
*/
-int cmd_metadata_regenerate(struct ltt_session *session)
+int cmd_regenerate_metadata(struct ltt_session *session)
{
int ret;
assert(session);
- ret = check_metadata_regenerate_support(session);
+ ret = check_regenerate_metadata_support(session);
if (ret) {
goto end;
}
if (session->kernel_session) {
- ret = kernctl_session_metadata_regenerate(
+ ret = kernctl_session_regenerate_metadata(
session->kernel_session->fd);
if (ret < 0) {
ERR("Failed to regenerate the kernel metadata");
}
if (session->ust_session) {
- ret = ust_metadata_regenerate(session->ust_session);
+ ret = ust_regenerate_metadata(session->ust_session);
if (ret < 0) {
ERR("Failed to regenerate the UST metadata");
goto end;
return ret;
}
-
/*
* Send relayd sockets from snapshot output to consumer. Ignore request if the
* snapshot output is *not* set with a remote destination.
int cmd_set_session_shm_path(struct ltt_session *session,
const char *shm_path);
-int cmd_metadata_regenerate(struct ltt_session *session);
+int cmd_regenerate_metadata(struct ltt_session *session);
#endif /* CMD_H */
case LTTNG_SNAPSHOT_RECORD:
case LTTNG_SAVE_SESSION:
case LTTNG_SET_SESSION_SHM_PATH:
- case LTTNG_METADATA_REGENERATE:
+ case LTTNG_REGENERATE_METADATA:
need_domain = 0;
break;
default:
cmd_ctx->lsm->u.set_shm_path.shm_path);
break;
}
- case LTTNG_METADATA_REGENERATE:
+ case LTTNG_REGENERATE_METADATA:
{
- ret = cmd_metadata_regenerate(cmd_ctx->session);
+ ret = cmd_regenerate_metadata(cmd_ctx->session);
break;
}
default:
commands/track-untrack.c \
commands/status.c \
commands/metadata.c \
+ commands/regenerate.c \
commands/help.c \
utils.c utils.h lttng.c
DECL_COMMAND(track);
DECL_COMMAND(untrack);
DECL_COMMAND(metadata);
+DECL_COMMAND(regenerate);
extern int cmd_help(int argc, const char **argv,
const struct cmd_struct commands[]);
ret = -LTTNG_ERR_INVALID;
goto end;
}
- ret = lttng_metadata_regenerate(session_name);
+ ret = lttng_regenerate_metadata(session_name);
if (ret == 0) {
MSG("Metadata successfully regenerated for session %s", session_name);
}
--- /dev/null
+/*
+ * Copyright (C) 2015 - Julien Desfossez <jdesfossez@efficios.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2 only,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#define _LGPL_SOURCE
+#include <assert.h>
+#include <ctype.h>
+#include <popt.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <common/mi-lttng.h>
+
+#include "../command.h"
+
+static char *opt_session_name;
+static char *session_name = NULL;
+
+static int regenerate_metadata(int argc, const char **argv);
+
+enum {
+ OPT_HELP = 1,
+ OPT_LIST_OPTIONS,
+ OPT_LIST_COMMANDS,
+};
+
+static struct mi_writer *writer;
+
+static struct poptOption long_options[] = {
+ /* { longName, shortName, argInfo, argPtr, value, descrip, argDesc, } */
+ { "help", 'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0, },
+ { "session", 's', POPT_ARG_STRING, &opt_session_name, 0, 0, 0},
+ { "list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, 0, 0, },
+ { "list-commands", 0, POPT_ARG_NONE, NULL, OPT_LIST_COMMANDS},
+ { 0, 0, 0, 0, 0, 0, 0, },
+};
+
+static struct cmd_struct actions[] = {
+ { "metadata", regenerate_metadata },
+ { NULL, NULL } /* Array closure */
+};
+
+/*
+ * Count and return the number of arguments in argv.
+ */
+static int count_arguments(const char **argv)
+{
+ int i = 0;
+
+ assert(argv);
+
+ while (argv[i] != NULL) {
+ i++;
+ }
+
+ return i;
+}
+
+static int regenerate_metadata(int argc, const char **argv)
+{
+ int ret;
+
+ if (argc > 1) {
+ ret = -LTTNG_ERR_INVALID;
+ goto end;
+ }
+ ret = lttng_regenerate_metadata(session_name);
+ if (ret == 0) {
+ MSG("Metadata successfully regenerated for session %s", session_name);
+ }
+
+end:
+ return ret;
+}
+
+static int handle_command(const char **argv)
+{
+ struct cmd_struct *cmd;
+ int ret = CMD_SUCCESS, i = 0, argc, command_ret = CMD_SUCCESS;
+
+ if (argv == NULL) {
+ ERR("argv is null");
+ command_ret = CMD_ERROR;
+ goto end;
+ }
+
+ argc = count_arguments(argv);
+
+ cmd = &actions[i];
+ while (cmd->func != NULL) {
+ /* Find command */
+ if (strcmp(argv[0], cmd->name) == 0) {
+ if (lttng_opt_mi) {
+ /* Action element */
+ ret = mi_lttng_writer_open_element(writer,
+ mi_lttng_element_command_regenerate_action);
+ if (ret) {
+ ret = CMD_ERROR;
+ goto end;
+ }
+
+ /* Name of the action */
+ ret = mi_lttng_writer_write_element_string(writer,
+ config_element_name, argv[0]);
+ if (ret) {
+ ret = CMD_ERROR;
+ goto end;
+ }
+ }
+ command_ret = cmd->func(argc, argv);
+ if (lttng_opt_mi) {
+ /* Close output and action element */
+ ret = mi_lttng_writer_close_element(writer);
+ if (ret) {
+ ret = CMD_ERROR;
+ goto end;
+ }
+ }
+ goto end;
+ }
+
+ cmd = &actions[i++];
+ }
+
+ ret = CMD_UNDEFINED;
+
+end:
+ /* Overwrite ret if an error occurred in cmd->func() */
+ ret = command_ret ? command_ret : ret;
+ return ret;
+}
+
+/*
+ * regenerate command handling.
+ */
+int cmd_regenerate(int argc, const char **argv)
+{
+ int opt, ret = CMD_SUCCESS, command_ret = CMD_SUCCESS, success = 1;
+ static poptContext pc;
+
+ if (argc < 1) {
+ SHOW_HELP();
+ ret = CMD_ERROR;
+ goto end;
+ }
+
+ pc = poptGetContext(NULL, argc, argv, long_options, 0);
+ poptReadDefaultConfig(pc, 0);
+
+ if (lttng_opt_mi) {
+ writer = mi_lttng_writer_create(fileno(stdout), lttng_opt_mi);
+ if (!writer) {
+ ret = -LTTNG_ERR_NOMEM;
+ goto end;
+ }
+ /* Open command element */
+ ret = mi_lttng_writer_command_open(writer,
+ mi_lttng_element_command_regenerate);
+ if (ret) {
+ ret = CMD_ERROR;
+ goto end;
+ }
+
+ /* Open output element */
+ ret = mi_lttng_writer_open_element(writer,
+ mi_lttng_element_command_output);
+ if (ret) {
+ ret = CMD_ERROR;
+ goto end;
+ }
+ }
+
+ while ((opt = poptGetNextOpt(pc)) != -1) {
+ switch (opt) {
+ case OPT_HELP:
+ SHOW_HELP();
+ goto end;
+ case OPT_LIST_OPTIONS:
+ list_cmd_options(stdout, long_options);
+ goto end;
+ case OPT_LIST_COMMANDS:
+ list_commands(actions, stdout);
+ goto end;
+ default:
+ SHOW_HELP();
+ ret = CMD_UNDEFINED;
+ goto end;
+ }
+ }
+
+ if (!opt_session_name) {
+ session_name = get_session_name();
+ if (session_name == NULL) {
+ ret = CMD_ERROR;
+ goto end;
+ }
+ } else {
+ session_name = opt_session_name;
+ }
+
+ command_ret = handle_command(poptGetArgs(pc));
+ if (command_ret) {
+ switch (-command_ret) {
+ default:
+ ERR("%s", lttng_strerror(command_ret));
+ success = 0;
+ break;
+ }
+ }
+
+ if (lttng_opt_mi) {
+ /* Close output element */
+ ret = mi_lttng_writer_close_element(writer);
+ if (ret) {
+ ret = CMD_ERROR;
+ goto end;
+ }
+
+ /* Success ? */
+ ret = mi_lttng_writer_write_element_bool(writer,
+ mi_lttng_element_command_success, success);
+ if (ret) {
+ ret = CMD_ERROR;
+ goto end;
+ }
+
+ /* Command element close */
+ ret = mi_lttng_writer_command_close(writer);
+ if (ret) {
+ ret = CMD_ERROR;
+ goto end;
+ }
+ }
+
+end:
+ /* Mi clean-up */
+ if (writer && mi_lttng_writer_destroy(writer)) {
+ /* Preserve original error code */
+ ret = ret ? ret : -LTTNG_ERR_MI_IO_FAIL;
+ }
+
+ if (!opt_session_name) {
+ free(session_name);
+ }
+
+ /* Overwrite ret if an error occurred during handle_command() */
+ ret = command_ret ? command_ret : ret;
+
+ poptFreeContext(pc);
+ return ret;
+}
{ "help", NULL},
{ "version", cmd_version},
{ "view", cmd_view},
+ { "regenerate", cmd_regenerate},
{ NULL, NULL} /* Array closure */
};
return LTTNG_IOCTL_NO_CHECK(fd, LTTNG_KERNEL_SESSION_LIST_TRACKER_PIDS);
}
-int kernctl_session_metadata_regenerate(int fd)
+int kernctl_session_regenerate_metadata(int fd)
{
return LTTNG_IOCTL_CHECK(fd, LTTNG_KERNEL_SESSION_METADATA_REGEN);
}
int kernctl_untrack_pid(int fd, int pid);
int kernctl_list_tracker_pids(int fd);
-int kernctl_session_metadata_regenerate(int fd);
+int kernctl_session_regenerate_metadata(int fd);
/* Buffer operations */
const char * const mi_lttng_element_command_load = "load";
LTTNG_HIDDEN const char * const mi_lttng_element_command_metadata = "metadata";
LTTNG_HIDDEN const char * const mi_lttng_element_command_metadata_action = "metadata_action";
+LTTNG_HIDDEN const char * const mi_lttng_element_command_regenerate = "regenerate";
+LTTNG_HIDDEN const char * const mi_lttng_element_command_regenerate_action = "regenerate_action";
const char * const mi_lttng_element_command_name = "name";
const char * const mi_lttng_element_command_output = "output";
const char * const mi_lttng_element_command_save = "save";
extern const char * const mi_lttng_element_command_load;
extern const char * const mi_lttng_element_command_metadata;
extern const char * const mi_lttng_element_command_metadata_action;
+extern const char * const mi_lttng_element_command_regenerate;
+extern const char * const mi_lttng_element_command_regenerate_action;
extern const char * const mi_lttng_element_command_name;
extern const char * const mi_lttng_element_command_output;
extern const char * const mi_lttng_element_command_save;
LTTNG_UNTRACK_PID = 33,
LTTNG_LIST_TRACKER_PIDS = 34,
LTTNG_SET_SESSION_SHM_PATH = 40,
- LTTNG_METADATA_REGENERATE = 41,
+ LTTNG_REGENERATE_METADATA = 41,
};
enum lttcomm_relayd_command {
} LTTNG_PACKED lost_packets;
struct {
uint64_t session_id;
- } LTTNG_PACKED metadata_regenerate;
+ } LTTNG_PACKED regenerate_metadata;
} u;
} LTTNG_PACKED;
* Regenerate the metadata for a session.
* Return 0 on success, a negative error code on error.
*/
-int lttng_metadata_regenerate(const char *session_name)
+int lttng_regenerate_metadata(const char *session_name)
{
int ret;
struct lttcomm_session_msg lsm;
}
memset(&lsm, 0, sizeof(lsm));
- lsm.cmd_type = LTTNG_METADATA_REGENERATE;
+ lsm.cmd_type = LTTNG_REGENERATE_METADATA;
lttng_ctl_copy_string(lsm.session.name, session_name,
sizeof(lsm.session.name));
return ret;
}
+/*
+ * Deprecated, replaced by lttng_regenerate_metadata.
+ */
+int lttng_metadata_regenerate(const char *session_name)
+{
+ return lttng_regenerate_metadata(session_name);
+}
+
/*
* lib constructor.
*/
validate_trace_date $DATE1 $TRACE_PATH
start_lttng_tracing_ok $SESSION_NAME
date "+%Y-%m-%d %H:%M" -s "$DATE2 $HOUR" >/dev/null
- metadata_regenerate_ok $SESSION_NAME
+ regenerate_metadata_ok $SESSION_NAME
stop_lttng_tracing_ok $SESSION_NAME
validate_trace_date $DATE2 $TRACE_PATH
if [ $? -eq 0 ]; then
validate_trace_date $DATE1 $TRACE_PATH/$HOSTNAME/$SESSION_NAME*
start_lttng_tracing_ok $SESSION_NAME
date "+%Y-%m-%d %H:%M" -s "$DATE2 $HOUR" >/dev/null
- metadata_regenerate_ok $SESSION_NAME
+ regenerate_metadata_ok $SESSION_NAME
stop_lttng_tracing_ok $SESSION_NAME
# Validate test
validate_trace_date $DATE2 $TRACE_PATH/$HOSTNAME/$SESSION_NAME*
start_lttng_tracing_ok $SESSION_NAME
date "+%Y-%m-%d %H:%M" -s "$DATE2 $HOUR" >/dev/null
- metadata_regenerate_ok $SESSION_NAME
+ regenerate_metadata_ok $SESSION_NAME
stop_lttng_tracing_ok $SESSION_NAME
destroy_lttng_session_ok $SESSION_NAME
start_lttng_tracing_ok $SESSION_NAME
date "+%Y-%m-%d %H:%M" -s "$DATE2 $HOUR" >/dev/null
- metadata_regenerate_ok $SESSION_NAME
+ regenerate_metadata_ok $SESSION_NAME
stop_lttng_tracing_ok $SESSION_NAME
destroy_lttng_session_ok $SESSION_NAME
regression/tools/mi/test_mi
regression/tools/wildcard/test_event_wildcard
regression/tools/crash/test_crash
-regression/tools/metadata-regen/test_ust
+regression/tools/regen-metadata/test_ust
regression/ust/before-after/test_before_after
regression/ust/buffers-pid/test_buffers_pid
regression/ust/multi-session/test_multi_session
tools/mi/test_mi \
tools/wildcard/test_event_wildcard \
tools/crash/test_crash \
- tools/metadata-regen/test_ust
+ tools/regen-metadata/test_ust
if HAVE_LIBLTTNG_UST_CTL
SUBDIRS += ust
SUBDIRS = streaming filtering health tracefile-limits snapshots live exclusion save-load mi \
- wildcard crash metadata-regen
+ wildcard crash regen-metadata
+++ /dev/null
-noinst_SCRIPTS = test_ust test_kernel
-EXTRA_DIST = test_ust test_kernel
-
-all-local:
- @if [ x"$(srcdir)" != x"$(builddir)" ]; then \
- for script in $(EXTRA_DIST); do \
- cp -f $(srcdir)/$$script $(builddir); \
- done; \
- fi
-
-clean-local:
- @if [ x"$(srcdir)" != x"$(builddir)" ]; then \
- for script in $(EXTRA_DIST); do \
- rm -f $(builddir)/$$script; \
- done; \
- fi
+++ /dev/null
-#!/bin/bash
-#
-# Copyright (C) - 2015 Julien Desfossez <jdesfossez@efficios.com>
-#
-# This library is free software; you can redistribute it and/or modify it under
-# the terms of the GNU Lesser General Public License as published by the Free
-# Software Foundation; version 2.1 of the License.
-#
-# This library is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
-# details.
-#
-# You should have received a copy of the GNU Lesser General Public License
-# along with this library; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-TEST_DESC="Streaming - Kernel tracing"
-
-CURDIR=$(dirname $0)/
-TESTDIR=$CURDIR/../../..
-EVENT_NAME="lttng_test_filter_event"
-PID_RELAYD=0
-SESSION_NAME=""
-
-TRACE_PATH=$(mktemp -d)
-
-NUM_TESTS=18
-
-source $TESTDIR/utils/utils.sh
-
-# LTTng kernel modules check
-out=`ls /lib/modules/$(uname -r)/extra | grep lttng`
-if [ -z "$out" ]; then
- BAIL_OUT "LTTng modules not detected."
-fi
-
-function lttng_create_session_uri
-{
- # Create session with default path
- $TESTDIR/../src/bin/lttng/$LTTNG_BIN create $SESSION_NAME -U net://localhost >/dev/null 2>&1
-
- ok $? "Create session $SESSION_NAME"
-}
-
-function test_kernel_streaming ()
-{
- diag "Test kernel streaming with metadata regeneration"
- lttng_create_session_uri
- lttng_enable_kernel_event $SESSION_NAME $EVENT_NAME
- start_lttng_tracing_ok $SESSION_NAME
- echo -n "100" > /proc/lttng-test-filter-event
- metadata_regenerate_ok $SESSION_NAME
- stop_lttng_tracing_ok $SESSION_NAME
- # Validate test
- validate_trace $EVENT_NAME $TRACE_PATH/$HOSTNAME/$SESSION_NAME*
- if [ $? -eq 0 ]; then
- # Only delete if successful
- rm -rf $TRACE_PATH
- else
- break
- fi
- destroy_lttng_session_ok $SESSION_NAME
-}
-
-function test_kernel_local ()
-{
- diag "Test kernel local with metadata regeneration"
- create_lttng_session_ok $SESSION_NAME $TRACE_PATH
- lttng_enable_kernel_event $SESSION_NAME $EVENT_NAME
- start_lttng_tracing_ok $SESSION_NAME
- echo -n "100" > /proc/lttng-test-filter-event
- metadata_regenerate_ok $SESSION_NAME
- stop_lttng_tracing_ok $SESSION_NAME
- validate_trace $EVENT_NAME $TRACE_PATH
- if [ $? -eq 0 ]; then
- # Only delete if successful
- rm -rf $TRACE_PATH
- fi
- destroy_lttng_session_ok $SESSION_NAME
-}
-
-plan_tests $NUM_TESTS
-
-print_test_banner "$TEST_DESC"
-
-if [ "$(id -u)" == "0" ]; then
- isroot=1
-else
- isroot=0
-fi
-
-skip $isroot "Root access is needed. Skipping all kernel streaming tests." $NUM_TESTS ||
-{
- start_lttng_relayd "-o $TRACE_PATH"
- start_lttng_sessiond
- modprobe lttng-test
-
- tests=( test_kernel_streaming test_kernel_local )
-
- for fct_test in ${tests[@]};
- do
- SESSION_NAME=$(randstring 16 0)
- ${fct_test}
- done
-
- rmmod lttng-test
- stop_lttng_sessiond
- stop_lttng_relayd
-}
+++ /dev/null
-#!/bin/bash
-#
-# Copyright (C) - 2015 Julien Desfossez <jdesfossez@efficios.com>
-#
-# This library is free software; you can redistribute it and/or modify it under
-# the terms of the GNU Lesser General Public License as published by the Free
-# Software Foundation; version 2.1 of the License.
-#
-# This library is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
-# details.
-#
-# You should have received a copy of the GNU Lesser General Public License
-# along with this library; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-TEST_DESC="Streaming - User space tracing"
-
-CURDIR=$(dirname $0)/
-TESTDIR=$CURDIR/../../..
-NR_ITER=1
-NR_USEC_WAIT=0
-TESTAPP_PATH="$TESTDIR/utils/testapp"
-TESTAPP_NAME="gen-ust-events"
-TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
-SESSION_NAME="stream"
-EVENT_NAME="tp:tptest"
-PID_RELAYD=0
-
-TRACE_PATH=$(mktemp -d)
-
-NUM_TESTS=33
-
-source $TESTDIR/utils/utils.sh
-
-if [ ! -x "$TESTAPP_BIN" ]; then
- BAIL_OUT "No UST events binary detected."
-fi
-
-function lttng_create_session_uri
-{
- # Create session with default path
- $TESTDIR/../src/bin/lttng/$LTTNG_BIN create $SESSION_NAME -U net://localhost >/dev/null 2>&1
- ok $? "Create session with default path"
-}
-
-function lttng_create_session_uri_live
-{
- # Create session with default path
- $TESTDIR/../src/bin/lttng/$LTTNG_BIN create $SESSION_NAME --live -U net://localhost >/dev/null 2>&1
- ok $? "Create live session"
-}
-
-function enable_channel_per_pid()
-{
- sess_name=$1
- channel_name=$2
-
- $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-channel --buffers-pid -u $channel_name -s $sess_name >/dev/null 2>&1
- ok $? "Enable channel $channel_name per PID for session $sess_name"
-}
-
-# MUST set TESTDIR before calling those functions
-
-function test_ust_streaming ()
-{
- local file_sync_after_first=$(mktemp -u)
- local file_sync_before_last=$(mktemp -u)
-
- diag "Test UST streaming with metadata regeneration"
- lttng_create_session_uri
- enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME
-
- $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT ${file_sync_after_first} ${file_sync_before_last} /dev/null 2>&1 &
-
- start_lttng_tracing_ok $SESSION_NAME
-
- touch ${file_sync_before_last}
-
- # Wait for the applications started in background
- wait
- metadata_regenerate_ok $SESSION_NAME
-
- stop_lttng_tracing_ok $SESSION_NAME
- destroy_lttng_session_ok $SESSION_NAME
- # Validate test
- validate_trace $EVENT_NAME $TRACE_PATH/$HOSTNAME/$SESSION_NAME*
- if [ $? -eq 0 ]; then
- # Only delete if successful
- rm -rf $TRACE_PATH
- fi
- rm -f ${file_sync_after_first}
- rm -f ${file_sync_before_last}
-}
-
-function test_ust_local ()
-{
- local file_sync_after_first=$(mktemp -u)
- local file_sync_before_last=$(mktemp -u)
-
- diag "Test UST local with metadata regeneration"
- create_lttng_session_ok $SESSION_NAME $TRACE_PATH
- enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME
-
- $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT ${file_sync_after_first} ${file_sync_before_last} /dev/null 2>&1 &
-
- start_lttng_tracing_ok $SESSION_NAME
-
- touch ${file_sync_before_last}
-
- # Wait for the applications started in background
- wait
- metadata_regenerate_ok $SESSION_NAME
-
- stop_lttng_tracing_ok $SESSION_NAME
- destroy_lttng_session_ok $SESSION_NAME
- # Validate test
- validate_trace $EVENT_NAME $TRACE_PATH
- if [ $? -eq 0 ]; then
- # Only delete if successful
- rm -rf $TRACE_PATH
- fi
- rm -f ${file_sync_after_first}
- rm -f ${file_sync_before_last}
-}
-
-function test_ust_pid ()
-{
- local file_sync_after_first=$(mktemp -u)
- local file_sync_before_last=$(mktemp -u)
-
- diag "Test UST per-pid with metadata regeneration (expect failure)"
- create_lttng_session_ok $SESSION_NAME $TRACE_PATH
- enable_channel_per_pid $SESSION_NAME "channel0"
- enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME "channel0"
-
- $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT ${file_sync_after_first} ${file_sync_before_last} /dev/null 2>&1 &
-
- start_lttng_tracing_ok $SESSION_NAME
-
- touch ${file_sync_before_last}
-
- # Wait for the applications started in background
- wait
- metadata_regenerate_fail $SESSION_NAME
-
- stop_lttng_tracing_ok $SESSION_NAME
- destroy_lttng_session_ok $SESSION_NAME
- # Validate test
- validate_trace $EVENT_NAME $TRACE_PATH
- if [ $? -eq 0 ]; then
- # Only delete if successful
- rm -rf $TRACE_PATH
- fi
- rm -f ${file_sync_after_first}
- rm -f ${file_sync_before_last}
-}
-
-function test_ust_live ()
-{
- local file_sync_after_first=$(mktemp -u)
- local file_sync_before_last=$(mktemp -u)
-
- diag "Test UST live with metadata regeneration (expect failure)"
- lttng_create_session_uri_live $SESSION_NAME $TRACE_PATH
- enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME
-
- $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT ${file_sync_after_first} ${file_sync_before_last} /dev/null 2>&1 &
-
- start_lttng_tracing_ok $SESSION_NAME
-
- touch ${file_sync_before_last}
-
- # Wait for the applications started in background
- wait
- metadata_regenerate_fail $SESSION_NAME
-
- stop_lttng_tracing_ok $SESSION_NAME
- destroy_lttng_session_ok $SESSION_NAME
- # Validate test
- validate_trace $EVENT_NAME $TRACE_PATH
- if [ $? -eq 0 ]; then
- # Only delete if successful
- rm -rf $TRACE_PATH
- fi
- rm -f ${file_sync_after_first}
- rm -f ${file_sync_before_last}
-}
-
-plan_tests $NUM_TESTS
-
-print_test_banner "$TEST_DESC"
-
-start_lttng_relayd "-o $TRACE_PATH"
-start_lttng_sessiond
-
-tests=( test_ust_streaming test_ust_local test_ust_pid test_ust_live )
-
-for fct_test in ${tests[@]};
-do
- SESSION_NAME=$(randstring 16 0)
- ${fct_test}
-done
-
-stop_lttng_sessiond
-stop_lttng_relayd
-
-exit $out
ok $? "Mi test: enabled element : $result expected: true"
#Test metadata regenerate command
- metadata_regenerate_ok $session_name
+ regenerate_metadata_ok $session_name
$XML_VALIDATE $OUTPUT_DEST
- ok $? "Mi test: metadata regenerate"
+ ok $? "Mi test: regenerate metadata"
#Test stop command
stop_lttng_tracing_ok $session_name
--- /dev/null
+noinst_SCRIPTS = test_ust test_kernel
+EXTRA_DIST = test_ust test_kernel
+
+all-local:
+ @if [ x"$(srcdir)" != x"$(builddir)" ]; then \
+ for script in $(EXTRA_DIST); do \
+ cp -f $(srcdir)/$$script $(builddir); \
+ done; \
+ fi
+
+clean-local:
+ @if [ x"$(srcdir)" != x"$(builddir)" ]; then \
+ for script in $(EXTRA_DIST); do \
+ rm -f $(builddir)/$$script; \
+ done; \
+ fi
--- /dev/null
+#!/bin/bash
+#
+# Copyright (C) - 2015 Julien Desfossez <jdesfossez@efficios.com>
+#
+# This library is free software; you can redistribute it and/or modify it under
+# the terms of the GNU Lesser General Public License as published by the Free
+# Software Foundation; version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+# details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this library; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+TEST_DESC="Streaming - Kernel tracing"
+
+CURDIR=$(dirname $0)/
+TESTDIR=$CURDIR/../../..
+EVENT_NAME="lttng_test_filter_event"
+PID_RELAYD=0
+SESSION_NAME=""
+
+TRACE_PATH=$(mktemp -d)
+
+NUM_TESTS=18
+
+source $TESTDIR/utils/utils.sh
+
+# LTTng kernel modules check
+out=`ls /lib/modules/$(uname -r)/extra | grep lttng`
+if [ -z "$out" ]; then
+ BAIL_OUT "LTTng modules not detected."
+fi
+
+function lttng_create_session_uri
+{
+ # Create session with default path
+ $TESTDIR/../src/bin/lttng/$LTTNG_BIN create $SESSION_NAME -U net://localhost >/dev/null 2>&1
+
+ ok $? "Create session $SESSION_NAME"
+}
+
+function test_kernel_streaming ()
+{
+ diag "Test kernel streaming with metadata regeneration"
+ lttng_create_session_uri
+ lttng_enable_kernel_event $SESSION_NAME $EVENT_NAME
+ start_lttng_tracing_ok $SESSION_NAME
+ echo -n "100" > /proc/lttng-test-filter-event
+ regenerate_metadata_ok $SESSION_NAME
+ stop_lttng_tracing_ok $SESSION_NAME
+ # Validate test
+ validate_trace $EVENT_NAME $TRACE_PATH/$HOSTNAME/$SESSION_NAME*
+ if [ $? -eq 0 ]; then
+ # Only delete if successful
+ rm -rf $TRACE_PATH
+ else
+ break
+ fi
+ destroy_lttng_session_ok $SESSION_NAME
+}
+
+function test_kernel_local ()
+{
+ diag "Test kernel local with metadata regeneration"
+ create_lttng_session_ok $SESSION_NAME $TRACE_PATH
+ lttng_enable_kernel_event $SESSION_NAME $EVENT_NAME
+ start_lttng_tracing_ok $SESSION_NAME
+ echo -n "100" > /proc/lttng-test-filter-event
+ regenerate_metadata_ok $SESSION_NAME
+ stop_lttng_tracing_ok $SESSION_NAME
+ validate_trace $EVENT_NAME $TRACE_PATH
+ if [ $? -eq 0 ]; then
+ # Only delete if successful
+ rm -rf $TRACE_PATH
+ fi
+ destroy_lttng_session_ok $SESSION_NAME
+}
+
+plan_tests $NUM_TESTS
+
+print_test_banner "$TEST_DESC"
+
+if [ "$(id -u)" == "0" ]; then
+ isroot=1
+else
+ isroot=0
+fi
+
+skip $isroot "Root access is needed. Skipping all kernel streaming tests." $NUM_TESTS ||
+{
+ start_lttng_relayd "-o $TRACE_PATH"
+ start_lttng_sessiond
+ modprobe lttng-test
+
+ tests=( test_kernel_streaming test_kernel_local )
+
+ for fct_test in ${tests[@]};
+ do
+ SESSION_NAME=$(randstring 16 0)
+ ${fct_test}
+ done
+
+ rmmod lttng-test
+ stop_lttng_sessiond
+ stop_lttng_relayd
+}
--- /dev/null
+#!/bin/bash
+#
+# Copyright (C) - 2015 Julien Desfossez <jdesfossez@efficios.com>
+#
+# This library is free software; you can redistribute it and/or modify it under
+# the terms of the GNU Lesser General Public License as published by the Free
+# Software Foundation; version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+# details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this library; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+TEST_DESC="Streaming - User space tracing"
+
+CURDIR=$(dirname $0)/
+TESTDIR=$CURDIR/../../..
+NR_ITER=1
+NR_USEC_WAIT=0
+TESTAPP_PATH="$TESTDIR/utils/testapp"
+TESTAPP_NAME="gen-ust-events"
+TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
+SESSION_NAME="stream"
+EVENT_NAME="tp:tptest"
+PID_RELAYD=0
+
+TRACE_PATH=$(mktemp -d)
+
+NUM_TESTS=33
+
+source $TESTDIR/utils/utils.sh
+
+if [ ! -x "$TESTAPP_BIN" ]; then
+ BAIL_OUT "No UST events binary detected."
+fi
+
+function lttng_create_session_uri
+{
+ # Create session with default path
+ $TESTDIR/../src/bin/lttng/$LTTNG_BIN create $SESSION_NAME -U net://localhost >/dev/null 2>&1
+ ok $? "Create session with default path"
+}
+
+function lttng_create_session_uri_live
+{
+ # Create session with default path
+ $TESTDIR/../src/bin/lttng/$LTTNG_BIN create $SESSION_NAME --live -U net://localhost >/dev/null 2>&1
+ ok $? "Create live session"
+}
+
+function enable_channel_per_pid()
+{
+ sess_name=$1
+ channel_name=$2
+
+ $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-channel --buffers-pid -u $channel_name -s $sess_name >/dev/null 2>&1
+ ok $? "Enable channel $channel_name per PID for session $sess_name"
+}
+
+# MUST set TESTDIR before calling those functions
+
+function test_ust_streaming ()
+{
+ local file_sync_after_first=$(mktemp -u)
+ local file_sync_before_last=$(mktemp -u)
+
+ diag "Test UST streaming with metadata regeneration"
+ lttng_create_session_uri
+ enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME
+
+ $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT ${file_sync_after_first} ${file_sync_before_last} /dev/null 2>&1 &
+
+ start_lttng_tracing_ok $SESSION_NAME
+
+ touch ${file_sync_before_last}
+
+ # Wait for the applications started in background
+ wait
+ regenerate_metadata_ok $SESSION_NAME
+
+ stop_lttng_tracing_ok $SESSION_NAME
+ destroy_lttng_session_ok $SESSION_NAME
+ # Validate test
+ validate_trace $EVENT_NAME $TRACE_PATH/$HOSTNAME/$SESSION_NAME*
+ if [ $? -eq 0 ]; then
+ # Only delete if successful
+ rm -rf $TRACE_PATH
+ fi
+ rm -f ${file_sync_after_first}
+ rm -f ${file_sync_before_last}
+}
+
+function test_ust_local ()
+{
+ local file_sync_after_first=$(mktemp -u)
+ local file_sync_before_last=$(mktemp -u)
+
+ diag "Test UST local with metadata regeneration"
+ create_lttng_session_ok $SESSION_NAME $TRACE_PATH
+ enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME
+
+ $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT ${file_sync_after_first} ${file_sync_before_last} /dev/null 2>&1 &
+
+ start_lttng_tracing_ok $SESSION_NAME
+
+ touch ${file_sync_before_last}
+
+ # Wait for the applications started in background
+ wait
+ regenerate_metadata_ok $SESSION_NAME
+
+ stop_lttng_tracing_ok $SESSION_NAME
+ destroy_lttng_session_ok $SESSION_NAME
+ # Validate test
+ validate_trace $EVENT_NAME $TRACE_PATH
+ if [ $? -eq 0 ]; then
+ # Only delete if successful
+ rm -rf $TRACE_PATH
+ fi
+ rm -f ${file_sync_after_first}
+ rm -f ${file_sync_before_last}
+}
+
+function test_ust_pid ()
+{
+ local file_sync_after_first=$(mktemp -u)
+ local file_sync_before_last=$(mktemp -u)
+
+ diag "Test UST per-pid with metadata regeneration (expect failure)"
+ create_lttng_session_ok $SESSION_NAME $TRACE_PATH
+ enable_channel_per_pid $SESSION_NAME "channel0"
+ enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME "channel0"
+
+ $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT ${file_sync_after_first} ${file_sync_before_last} /dev/null 2>&1 &
+
+ start_lttng_tracing_ok $SESSION_NAME
+
+ touch ${file_sync_before_last}
+
+ # Wait for the applications started in background
+ wait
+ regenerate_metadata_fail $SESSION_NAME
+
+ stop_lttng_tracing_ok $SESSION_NAME
+ destroy_lttng_session_ok $SESSION_NAME
+ # Validate test
+ validate_trace $EVENT_NAME $TRACE_PATH
+ if [ $? -eq 0 ]; then
+ # Only delete if successful
+ rm -rf $TRACE_PATH
+ fi
+ rm -f ${file_sync_after_first}
+ rm -f ${file_sync_before_last}
+}
+
+function test_ust_live ()
+{
+ local file_sync_after_first=$(mktemp -u)
+ local file_sync_before_last=$(mktemp -u)
+
+ diag "Test UST live with metadata regeneration (expect failure)"
+ lttng_create_session_uri_live $SESSION_NAME $TRACE_PATH
+ enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME
+
+ $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT ${file_sync_after_first} ${file_sync_before_last} /dev/null 2>&1 &
+
+ start_lttng_tracing_ok $SESSION_NAME
+
+ touch ${file_sync_before_last}
+
+ # Wait for the applications started in background
+ wait
+ regenerate_metadata_fail $SESSION_NAME
+
+ stop_lttng_tracing_ok $SESSION_NAME
+ destroy_lttng_session_ok $SESSION_NAME
+ # Validate test
+ validate_trace $EVENT_NAME $TRACE_PATH
+ if [ $? -eq 0 ]; then
+ # Only delete if successful
+ rm -rf $TRACE_PATH
+ fi
+ rm -f ${file_sync_after_first}
+ rm -f ${file_sync_before_last}
+}
+
+plan_tests $NUM_TESTS
+
+print_test_banner "$TEST_DESC"
+
+start_lttng_relayd "-o $TRACE_PATH"
+start_lttng_sessiond
+
+tests=( test_ust_streaming test_ust_local test_ust_pid test_ust_live )
+
+for fct_test in ${tests[@]};
+do
+ SESSION_NAME=$(randstring 16 0)
+ ${fct_test}
+done
+
+stop_lttng_sessiond
+stop_lttng_relayd
+
+exit $out
regression/tools/filtering/test_unsupported_op
regression/tools/filtering/test_valid_filter
regression/tools/wildcard/test_event_wildcard
-regression/tools/metadata-regen/test_kernel
+regression/tools/regen-metadata/test_kernel
regression/ust/test_event_perf
return $ret
}
-function metadata_regenerate ()
+function regenerate_metadata ()
{
local expected_to_fail=$1
local sess_name=$2
- $TESTDIR/../src/bin/lttng/$LTTNG_BIN metadata regenerate -s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
+ $TESTDIR/../src/bin/lttng/$LTTNG_BIN regenerate metadata -s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
ret=$?
if [[ $expected_to_fail -eq "1" ]]; then
test "$ret" -ne "0"
- ok $? "Expected fail on regenerate $sess_name"
+ ok $? "Expected fail on regenerate metadata $sess_name"
else
ok $ret "Metadata regenerate $sess_name"
fi
}
-function metadata_regenerate_ok ()
+function regenerate_metadata_ok ()
{
- metadata_regenerate 0 "$@"
+ regenerate_metadata 0 "$@"
}
-function metadata_regenerate_fail ()
+function regenerate_metadata_fail ()
{
- metadata_regenerate 1 "$@"
+ regenerate_metadata 1 "$@"
}
function destructive_tests_enabled ()