fi
if [ -z $(pidof lt-$SESSIOND_BIN) ]; then
- $DIR/../src/bin/lttng-sessiond/$SESSIOND_BIN --daemonize --quiet --consumerd32-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd" --consumerd64-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd"
+ $DIR/../src/bin/lttng-sessiond/$SESSIOND_BIN --background --quiet --consumerd32-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd" --consumerd64-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd"
if [ $? -eq 1 ]; then
echo "Fail to start lttng-sessiond"
exit 1
fi
- # Wait for sessiond to bootstrap
- sleep 2
fi
-opt="-o $TRACE_PATH"
+opt="--background -o $TRACE_PATH"
if [ -z $(pidof lt-$RELAYD_BIN) ]; then
- $DIR/../src/bin/lttng-relayd/$RELAYD_BIN $opt >/dev/null 2>&1 &
+ $DIR/../src/bin/lttng-relayd/$RELAYD_BIN $opt >/dev/null 2>&1
if [ $? -eq 1 ]; then
echo "Fail to start lttng-relayd (opt: $opt)"
return 1
}
if [ -z $(pidof lt-$SESSIOND_BIN) ]; then
- $DIR/../src/bin/lttng-sessiond/$SESSIOND_BIN --daemonize --quiet --consumerd32-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd" --consumerd64-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd"
+ $DIR/../src/bin/lttng-sessiond/$SESSIOND_BIN --background --quiet --consumerd32-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd" --consumerd64-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd"
if [ $? -eq 1 ]; then
echo "Fail to start lttng-sessiond"
exit 1
fi
- # Wait for sessiond to bootstrap
- sleep 2
fi
-opt="-o $TRACE_PATH"
+opt="-o $TRACE_PATH --background"
if [ -z $(pidof lt-$RELAYD_BIN) ]; then
- $DIR/../src/bin/lttng-relayd/$RELAYD_BIN $opt >/dev/null 2>&1 &
+ $DIR/../src/bin/lttng-relayd/$RELAYD_BIN $opt >/dev/null 2>&1
if [ $? -eq 1 ]; then
echo "Fail to start lttng-relayd (opt: $opt)"
return 1
}
if [ -z $(pidof lt-$SESSIOND_BIN) ]; then
- $DIR/../src/bin/lttng-sessiond/$SESSIOND_BIN --daemonize --quiet --consumerd32-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd" --consumerd64-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd"
+ $DIR/../src/bin/lttng-sessiond/$SESSIOND_BIN --background --quiet --consumerd32-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd" --consumerd64-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd"
if [ $? -eq 1 ]; then
echo "Fail to start lttng-sessiond"
exit 1
fi
- # Wait for sessiond to bootstrap
- sleep 2
fi
-opt="-o $TRACE_PATH"
+opt="-o $TRACE_PATH --background"
if [ -z $(pidof lt-$RELAYD_BIN) ]; then
- $DIR/../src/bin/lttng-relayd/$RELAYD_BIN $opt >/dev/null 2>&1 &
+ $DIR/../src/bin/lttng-relayd/$RELAYD_BIN $opt >/dev/null 2>&1
if [ $? -eq 1 ]; then
echo "Fail to start lttng-relayd (opt: $opt)"
return 1
TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
NR_ITER=2000000
NR_USEC_WAIT=100
+APPS_PID=
TRACE_PATH=$(mktemp -d)
}
# Start trace application and return once one event has been hit.
-function start_trace_app()
+function start_test_app()
{
local tmp_file="/tmp/lttng_test_ust.42.file"
# Start application with a temporary file.
$TESTAPP_BIN $NR_ITER $NR_USEC_WAIT $tmp_file &
- ok $? "Start application to trace"
+ ret=$?
+ APPS_PID="${APPS_PID} ${!}"
+ ok $ret "Start application to trace"
# Wait for the application file to appear indicating that at least one
# tracepoint has been fired.
rm -f $tmp_file
}
-function stop_trace_app()
+function stop_test_apps()
{
- diag "Killing $TESTAPP_NAME"
- PID_APP=`pidof $TESTAPP_NAME`
- kill $PID_APP >/dev/null 2>&1
- diag "Waiting on $TESTAPP_NAME"
- wait
+ diag "Stopping $TESTAPP_NAME"
+ for p in ${APPS_PID}; do
+ kill ${p}
+ wait ${p} 2>&1
+ done
}
# Test a snapshot using a default name for the output destination.
enable_ust_lttng_event $SESSION_NAME $EVENT_NAME $CHANNEL_NAME
start_lttng_tracing $SESSION_NAME
- start_trace_app
+ start_test_app
snapshot_add_output $SESSION_NAME "net://localhost"
lttng_snapshot_record $SESSION_NAME
echo $TRACE_PATH/$HOSTNAME/snapshot-1
validate_trace $EVENT_NAME $TRACE_PATH/$HOSTNAME/snapshot-1*
if [ $? -ne 0 ]; then
- stop_trace_app
+ stop_test_apps
return $?
fi
# Validate test with the next ID since a del output was done prior.
validate_trace $EVENT_NAME $TRACE_PATH/$HOSTNAME/snapshot-2*
if [ $? -ne 0 ]; then
- stop_trace_app
+ stop_test_apps
return $?
fi
stop_lttng_tracing $SESSION_NAME
destroy_lttng_session $SESSION_NAME
- stop_trace_app
+ stop_test_apps
return 0
}
enable_ust_lttng_event $SESSION_NAME $EVENT_NAME $CHANNEL_NAME
start_lttng_tracing $SESSION_NAME
- start_trace_app
+ start_test_app
snapshot_add_output $SESSION_NAME "net://localhost"
lttng_snapshot_record $SESSION_NAME
validate_trace $EVENT_NAME $TRACE_PATH/$HOSTNAME/snapshot-1*
out=$?
- stop_trace_app
+ stop_test_apps
return $out
}
enable_ust_lttng_event $SESSION_NAME $EVENT_NAME $CHANNEL_NAME
start_lttng_tracing $SESSION_NAME
- start_trace_app
+ start_test_app
snapshot_add_output $SESSION_NAME "-C tcp://localhost:5342 -D tcp://localhost:5343"
lttng_snapshot_record $SESSION_NAME
validate_trace $EVENT_NAME $TRACE_PATH/$HOSTNAME/snapshot-1*
out=$?
- stop_trace_app
+ stop_test_apps
return $out
}
enable_ust_lttng_event $SESSION_NAME $EVENT_NAME $CHANNEL_NAME
start_lttng_tracing $SESSION_NAME
- start_trace_app
+ start_test_app
snapshot_add_output $SESSION_NAME "net://localhost" $name
lttng_snapshot_record $SESSION_NAME
out=1
fi
- stop_trace_app
+ stop_test_apps
return $out
}
TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
NR_ITER=2000000
NR_USEC_WAIT=100
+APPS_PID=
NUM_TESTS=76
# Start application with a temporary file.
$TESTAPP_BIN $NR_ITER $NR_USEC_WAIT $tmp_file &
- ok $? "Start application to trace"
+ ret=$?
+ APPS_PID="${APPS_PID} ${!}"
+ ok $ret "Start application to trace"
# Wait for the application file to appear indicating that at least one
# tracepoint has been fired.
rm -f $tmp_file
}
-function stop_test_app()
+function stop_test_apps()
{
- diag "Killing $TESTAPP_NAME"
- PID_APP=`pidof $TESTAPP_NAME`
- kill $PID_APP >/dev/null 2>&1
- diag "Waiting on $TESTAPP_NAME"
- wait
+ diag "Stopping $TESTAPP_NAME"
+ for p in ${APPS_PID}; do
+ kill ${p}
+ wait ${p} 2>&1
+ done
}
function snapshot_add_output ()
rm -rf $TRACE_PATH
fi
- stop_test_app
+ stop_test_apps
}
function test_ust_local_snapshot_max_size ()
rm -rf $TRACE_PATH
fi
- stop_test_app
+ stop_test_apps
}
function test_ust_local_snapshot_large_metadata ()
rm -rf $TRACE_PATH
fi
- stop_test_app
+ stop_test_apps
}
function test_ust_per_uid_local_snapshot_post_mortem ()
# Returns once the application has at least fired ONE tracepoint.
start_test_app
- stop_test_app
+ stop_test_apps
lttng_snapshot_record $SESSION_NAME
stop_lttng_tracing $SESSION_NAME
stop_lttng_tracing $SESSION_NAME
destroy_lttng_session $SESSION_NAME
- stop_test_app
+ stop_test_apps
}
plan_tests $NUM_TESTS
sleep 1
stop_lttng_tracing $SESSION_NAME
destroy_lttng_session $SESSION_NAME
-
- # We can not predict _yet_ when the trace is available so we have to do a
- # arbitratry sleep to validate the trace.
- diag "Wait 3 seconds for the trace to be written on disk"
- for i in `seq 1 3`; do
- sleep 1
- done
}
# Deactivated since this feature is not yet available where we can enable
start_lttng_tracing $SESSION_NAME
# Wait for the applications started in background
- wait ${!}
+ wait
stop_lttng_tracing $SESSION_NAME
destroy_lttng_session $SESSION_NAME
# Run 5 times with a 1 second delay
run_app_background 0 1
- sleep 1
+ # Wait for the applications started in background
+ wait
stop_lttng_tracing $SESSION_NAME
destroy_lttng_session $SESSION_NAME
enable_jul_lttng_event $SESSION_NAME $EVENT_NAME2
start_lttng_tracing $SESSION_NAME
+ # Run 5 times with a 1 second delay
+ run_app_background 0 1
+
# Wait for the applications started in background
- wait ${!}
+ wait
stop_lttng_tracing $SESSION_NAME
destroy_lttng_session $SESSION_NAME
start_lttng_tracing $SESSION_NAME
# Wait for the applications started in background
- wait ${!}
+ wait
stop_lttng_tracing $SESSION_NAME
destroy_lttng_session $SESSION_NAME
# Run 5 times with a 1 second delay
run_app_background 0 1
-
- sleep 1
+ # Wait for the applications started in background
+ wait
stop_lttng_tracing $SESSION_NAME
destroy_lttng_session $SESSION_NAME
enable_log4j_lttng_event $SESSION_NAME $EVENT_NAME2
start_lttng_tracing $SESSION_NAME
+ # Run 5 times with a 1 second delay
+ run_app_background 0 1
# Wait for the applications started in background
- wait ${!}
+ wait
stop_lttng_tracing $SESSION_NAME
destroy_lttng_session $SESSION_NAME
CURDIR=$(dirname $0)/
TESTDIR=$CURDIR/../../..
-NR_ITER=1000
+NR_ITER=-1 # infinite loop
NR_USEC_WAIT=1000000
TESTAPP_PATH="$TESTDIR/utils/testapp"
TESTAPP_NAME="gen-ust-events"
EVENT_NAME="tp:tptest"
TEST_WAIT_SEC=5
NUM_TESTS=9
+APPS_PID=
source $TESTDIR/utils/utils.sh
start_lttng_sessiond
-# Start test for 1000 seconds
+# Start tests. Each is an infinite tracing loop.
+diag "Starting $NUM_PROCESS test applications"
for i in `seq 1 $NUM_PROCESS`
do
$TESTAPP_BIN $NR_ITER $NR_USEC_WAIT >/dev/null 2>&1 &
+ APPS_PID="${APPS_PID} ${!}"
done
+diag "Waiting for applications to be registered to sessiond"
+
reg_app_count=0
while [ $reg_app_count -ne $NUM_PROCESS ]; do
listing=$($TESTDIR/../src/bin/lttng/$LTTNG_BIN list -u)
reg_app_count=$(echo -n $listing | sed "s#$TESTAPP_BIN#$TESTAPP_BIN\n#g" | grep "$TESTAPP_BIN" | wc -l)
done
-pass "Trace validation"
+pass "All applications are registered to sessiond"
TRACE_PATH=$(mktemp -d)
enable_ust_lttng_event $SESSION_NAME $EVENT_NAME
start_lttng_tracing $SESSION_NAME
-diag "Sleeping $TEST_WAIT_SEC seconds for tracing to start everywhere"
-diag "Warning: this arbitrary time can make the test fail on slower system"
-
-sleep $TEST_WAIT_SEC
+# We don't validate whether the applications have traced here, rather
+# just that they registered to sessiond (above).
stop_lttng_tracing $SESSION_NAME
destroy_lttng_session $SESSION_NAME
rm -rf $TRACE_PATH
diag "Stopping all spawned applications"
-killall -q $TESTAPP_NAME >/dev/null 2>&1
-wait
+for p in ${APPS_PID}; do
+ kill ${p}
+ wait ${p} 2>/dev/null
+done
pass "Stopped all spawned applications"
stop_lttng_sessiond
if [ -z $(pidof lt-$SESSIOND_BIN) ]; then
# We have to start it like this so the ulimit -c is used by this
# process. Also, we collect any error message printed out.
- $TESTDIR/../src/bin/lttng-sessiond/$SESSIOND_BIN --quiet --consumerd32-path="$TESTDIR/../src/bin/lttng-consumerd/lttng-consumerd" --consumerd64-path="$TESTDIR/../src/bin/lttng-consumerd/lttng-consumerd" >$LOG_FILE 2>&1 &
+ $TESTDIR/../src/bin/lttng-sessiond/$SESSIOND_BIN --quiet --background --consumerd32-path="$TESTDIR/../src/bin/lttng-consumerd/lttng-consumerd" --consumerd64-path="$TESTDIR/../src/bin/lttng-consumerd/lttng-consumerd" >$LOG_FILE 2>&1
status=$?
- # Wait for sessiond to bootstrap
- sleep 2
ok $status "Start session daemon"
fi
}
if [ -z $(pidof lt-$SESSIOND_BIN) ]; then
# We have to start it like this so the ulimit -c is used by this
# process. Also, we collect any error message printed out.
- $TESTDIR/../src/bin/lttng-sessiond/$SESSIOND_BIN --quiet --consumerd32-path="$TESTDIR/../src/bin/lttng-consumerd/lttng-consumerd" --consumerd64-path="$TESTDIR/../src/bin/lttng-consumerd/lttng-consumerd" >$LOG_FILE_SESSIOND 2>&1 &
+ $TESTDIR/../src/bin/lttng-sessiond/$SESSIOND_BIN --quiet --background --consumerd32-path="$TESTDIR/../src/bin/lttng-consumerd/lttng-consumerd" --consumerd64-path="$TESTDIR/../src/bin/lttng-consumerd/lttng-consumerd" >$LOG_FILE_SESSIOND 2>&1
status=$?
- # Wait for sessiond to bootstrap
- sleep 2
ok $status "Start session daemon"
fi
}
if [ -z $(pidof lt-$SESSIOND_BIN) ]; then
# We have to start it like this so the ulimit -c is used by this
# process. Also, we collect any error message printed out.
- #$TESTDIR/../src/bin/lttng-sessiond/$SESSIOND_BIN --quiet --consumerd32-path="$TESTDIR/../src/bin/lttng-consumerd/lttng-consumerd" --consumerd64-path="$TESTDIR/../src/bin/lttng-consumerd/lttng-consumerd" >$LOG_FILE_SESSIOND 2>&1 &
- $TESTDIR/../src/bin/lttng-sessiond/$SESSIOND_BIN --verbose-consumer -vvv --consumerd32-path="$TESTDIR/../src/bin/lttng-consumerd/lttng-consumerd" --consumerd64-path="$TESTDIR/../src/bin/lttng-consumerd/lttng-consumerd" >$LOG_FILE_SESSIOND 2>&1 &
- #$TESTDIR/../src/bin/lttng-sessiond/$SESSIOND_BIN --consumerd32-path="$TESTDIR/../src/bin/lttng-consumerd/lttng-consumerd" --consumerd64-path="$TESTDIR/../src/bin/lttng-consumerd/lttng-consumerd" >$LOG_FILE_SESSIOND 2>&1 &
+ #$TESTDIR/../src/bin/lttng-sessiond/$SESSIOND_BIN --quiet --background --consumerd32-path="$TESTDIR/../src/bin/lttng-consumerd/lttng-consumerd" --consumerd64-path="$TESTDIR/../src/bin/lttng-consumerd/lttng-consumerd" >$LOG_FILE_SESSIOND 2>&1
+ $TESTDIR/../src/bin/lttng-sessiond/$SESSIOND_BIN --verbose-consumer -vvv --background --consumerd32-path="$TESTDIR/../src/bin/lttng-consumerd/lttng-consumerd" --consumerd64-path="$TESTDIR/../src/bin/lttng-consumerd/lttng-consumerd" >$LOG_FILE_SESSIOND 2>&1
+ #$TESTDIR/../src/bin/lttng-sessiond/$SESSIOND_BIN --background --consumerd32-path="$TESTDIR/../src/bin/lttng-consumerd/lttng-consumerd" --consumerd64-path="$TESTDIR/../src/bin/lttng-consumerd/lttng-consumerd" >$LOG_FILE_SESSIOND 2>&1
status=$?
- # Wait for sessiond to bootstrap
- sleep 2
ok $status "Start session daemon"
fi
}
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
+#include <stdbool.h>
#define TRACEPOINT_DEFINE
#include "tp.h"
int main(int argc, char **argv)
{
- int i, netint;
+ unsigned int i, netint;
long values[] = { 1, 2, 3 };
char text[10] = "test";
double dbl = 2.0;
float flt = 2222.0;
- unsigned int nr_iter = 100;
+ int nr_iter = 100;
useconds_t nr_usec = 0;
char *tmp_file_path = NULL;
+ bool file_created = false;
if (argc >= 2) {
+ /*
+ * If nr_iter is negative, do an infinite tracing loop.
+ */
nr_iter = atoi(argv[1]);
}
tmp_file_path = argv[3];
}
- for (i = 0; i < nr_iter; i++) {
+ for (i = 0; nr_iter < 0 || i < nr_iter; i++) {
netint = htonl(i);
tracepoint(tp, tptest, i, netint, values, text, strlen(text), dbl,
flt);
* First loop we create the file if asked to indicate that at least one
* tracepoint has been hit.
*/
- if (i == 0 && tmp_file_path) {
+ if (!file_created && tmp_file_path) {
create_file(tmp_file_path);
+ file_created = true;
}
usleep(nr_usec);
}
else
$DIR/../src/bin/lttng-sessiond/$SESSIOND_BIN --background --consumerd32-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd" --consumerd64-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd"
fi
- #$DIR/../src/bin/lttng-sessiond/$SESSIOND_BIN --consumerd32-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd" --consumerd64-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd" --verbose-consumer >>/tmp/sessiond.log 2>&1 &
+ #$DIR/../src/bin/lttng-sessiond/$SESSIOND_BIN --background --consumerd32-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd" --consumerd64-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd" --verbose-consumer >>/tmp/sessiond.log 2>&1
status=$?
ok $status "Start session daemon"
fi