local SESSION_NAME="my_triggered_session"
local TRIGGER_NAME="trigger1"
local TRACE_PATH=$(mktemp -d test-start-action-trace.XXXXXX)
- local SYNC_AFTER_NOTIF_REGISTER_PATH=$(mktemp test-notif-register.XXXXXX)
+ local SYNC_AFTER_NOTIF_REGISTER_PATH=$(mktemp -u test-notif-register.XXXXXX)
diag "Start session action"
# Launch notification listener.
$NOTIFICATION_CLIENT_BIN \
--trigger $TRIGGER_NAME \
- --sync-after-notif-register "$SYNC_AFTER_NOTIF_REGISTER_PATH"
+ --sync-after-notif-register "$SYNC_AFTER_NOTIF_REGISTER_PATH" &
notif_client_pid=$!
while [ ! -f "${SYNC_AFTER_NOTIF_REGISTER_PATH}" ]; do
local SESSION_NAME="my_triggered_session"
local TRIGGER_NAME="trigger1"
local TRACE_PATH=$(mktemp -d test-stop-action-trace.XXXXXX)
- local SYNC_AFTER_NOTIF_REGISTER_PATH=$(mktemp test-notif-register.XXXXXX)
+ local SYNC_AFTER_NOTIF_REGISTER_PATH=$(mktemp -u test-notif-register.XXXXXX)
diag "Stop session action"
create_lttng_session_ok $SESSION_NAME "$TRACE_PATH"
# Launch notification listener.
$NOTIFICATION_CLIENT_BIN \
--trigger $TRIGGER_NAME \
- --sync-after-notif-register "$SYNC_AFTER_NOTIF_REGISTER_PATH"
+ --sync-after-notif-register "$SYNC_AFTER_NOTIF_REGISTER_PATH" &
notif_client_pid=$!
while [ ! -f "${SYNC_AFTER_NOTIF_REGISTER_PATH}" ]; do
static struct option long_options[] =
{
/* These options set a flag. */
- {"trigger", required_argument, 0, 'i'},
+ {"trigger", required_argument, 0, 't'},
{"sync-after-notif-register", required_argument, 0, 'a'},
{0, 0, 0, 0}
};
return false;
}
-static bool is_expected_trigger_name(const char *expected_trigger_name,
+static bool is_trigger_name(const char *expected_trigger_name,
struct lttng_notification *notification)
{
const char *trigger_name = NULL;
}
names_match = strcmp(expected_trigger_name, trigger_name) == 0;
+ if (!names_match) {
+ fprintf(stderr, "Got an unexpected trigger name: name = '%s', expected name = '%s'\n",
+ trigger_name, expected_trigger_name);
+ }
end:
return names_match;
}
ret = lttng_list_triggers(&triggers);
if (ret != LTTNG_OK) {
fprintf(stderr, "Failed to list triggers\n");
+ ret = -1;
goto end;
}
goto end;
}
+ /* Look for the trigger we want to subscribe to. */
for (i = 0; i < count; i++) {
const struct lttng_trigger *trigger =
lttng_triggers_get_at_index(triggers, i);
switch (channel_status) {
case LTTNG_NOTIFICATION_CHANNEL_STATUS_NOTIFICATIONS_DROPPED:
printf("Dropped notification\n");
- break;
+ ret = -1;
+ goto end;
case LTTNG_NOTIFICATION_CHANNEL_STATUS_INTERRUPTED:
- ret = 0;
+ ret = -1;
goto end;
case LTTNG_NOTIFICATION_CHANNEL_STATUS_OK:
break;
case LTTNG_NOTIFICATION_CHANNEL_STATUS_CLOSED:
printf("Notification channel was closed by peer.\n");
+ ret = -1;
break;
default:
fprintf(stderr, "A communication error occurred on the notification channel.\n");
goto end;
}
- ret = is_expected_trigger_name(expected_trigger_name,
- notification);
+ ret = is_trigger_name(expected_trigger_name, notification);
lttng_notification_destroy(notification);
- if (ret) {
+ if (!ret) {
+ ret = -1;
+ goto end;
+ } else {
ret = 0;
goto end;
}