Fix: snapshot path have domain subdir duplicate "ust/ust" or "kernel/kernel"
[lttng-tools.git] / tests / regression / tools / streaming / test_ust
... / ...
CommitLineData
1#!/bin/bash
2#
3# Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
4#
5# SPDX-License-Identifier: LGPL-2.1-only
6
7TEST_DESC="Streaming - User space tracing"
8
9CURDIR=$(dirname $0)/
10TESTDIR=$CURDIR/../../..
11NR_ITER=5
12NR_USEC_WAIT=1000000
13TESTAPP_PATH="$TESTDIR/utils/testapp"
14TESTAPP_NAME="gen-ust-events"
15TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
16SESSION_NAME="stream"
17EVENT_NAME="tp:tptest"
18
19TRACE_PATH=$(mktemp -d)
20
21NUM_TESTS=18
22
23source $TESTDIR/utils/utils.sh
24
25if [ ! -x "$TESTAPP_BIN" ]; then
26 BAIL_OUT "No UST events binary detected."
27fi
28
29# MUST set TESTDIR before calling those functions
30
31function test_ust_before_start ()
32{
33 local file_sync_before_last=$(mktemp -u)
34
35 diag "Test UST streaming BEFORE tracing starts"
36 create_lttng_session_uri $SESSION_NAME net://localhost
37 enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME
38
39 # Run 5 times with a 1 second delay
40 $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT --sync-before-last-event ${file_sync_before_last} > /dev/null 2>&1 &
41
42 start_lttng_tracing_ok $SESSION_NAME
43
44 touch ${file_sync_before_last}
45
46 # Wait for the applications started in background
47 wait
48
49 stop_lttng_tracing_ok $SESSION_NAME
50 destroy_lttng_session_ok $SESSION_NAME
51 rm -f ${file_sync_before_last}
52}
53
54function test_ust_after_start ()
55{
56 local file_sync_after_first=$(mktemp -u)
57
58 diag "Test UST streaming AFTER tracing starts"
59 create_lttng_session_uri $SESSION_NAME net://localhost
60 enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME
61 start_lttng_tracing_ok $SESSION_NAME
62
63 # Run 5 times with a 1 second delay
64 $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT \
65 --sync-after-first-event ${file_sync_after_first} >/dev/null 2>&1
66
67 while [ ! -f "${file_sync_after_first}" ]; do
68 sleep 0.5
69 done
70
71 stop_lttng_tracing_ok $SESSION_NAME
72 destroy_lttng_session_ok $SESSION_NAME
73
74 # Wait for the applications started in background
75 wait
76 rm -f ${file_sync_after_first}
77}
78
79plan_tests $NUM_TESTS
80
81print_test_banner "$TEST_DESC"
82
83start_lttng_relayd "-o $TRACE_PATH"
84start_lttng_sessiond
85
86tests=( test_ust_before_start test_ust_after_start )
87
88for fct_test in ${tests[@]};
89do
90 SESSION_NAME=$(randstring 16 0)
91 ${fct_test}
92
93 # Validate test
94 validate_trace_path_ust_uid_network "$TRACE_PATH" "$SESSION_NAME"
95 validate_trace $EVENT_NAME $TRACE_PATH/$HOSTNAME/$SESSION_NAME*
96 if [ $? -eq 0 ]; then
97 # Only delete if successful
98 rm -rf $TRACE_PATH
99 else
100 break
101 fi
102done
103
104stop_lttng_sessiond
105stop_lttng_relayd
106
107exit $out
This page took 0.04635 seconds and 5 git commands to generate.