TRACE_PATH=$(mktemp -d)
-NUM_TESTS=2075
+NUM_TESTS=2076
source $TESTDIR/utils/utils.sh
BAIL_OUT "No UST events binary detected."
fi
+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"
+
+ # Wait for the application file to appear indicating that at least one
+ # tracepoint has been fired.
+ while [ ! -f "$tmp_file" ]; do
+ sleep 0.5
+ done
+ diag "Removing test app temporary file $tmp_file"
+ rm -f $tmp_file
+}
+
+function kill_test_app()
+{
+ diag "Killing $TESTAPP_NAME"
+ PID_APP=`pidof $TESTAPP_NAME`
+ kill $PID_APP >/dev/null 2>&1
+}
+
function snapshot_add_output ()
{
local sess_name=$1
enable_ust_lttng_event $SESSION_NAME $EVENT_NAME $CHANNEL_NAME
start_lttng_tracing $SESSION_NAME
lttng_snapshot_add_output $SESSION_NAME $TRACE_PATH
- $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT &
- ok $? "Start application to trace"
+
+ # Returns once the application has at least fired ONE tracepoint.
+ start_test_app
+
lttng_snapshot_record $SESSION_NAME
stop_lttng_tracing $SESSION_NAME
destroy_lttng_session $SESSION_NAME
else
break
fi
- diag "Killing $TESTAPP_NAME"
- PID_APP=`pidof $TESTAPP_NAME`
- kill $PID_APP >/dev/null 2>&1
+
+ kill_test_app
}
function test_ust_local_snapshot_max_size ()
snapshot_add_output $SESSION_NAME "file://$TRACE_PATH" "" $max_size
- $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT &
- ok $? "Start application to trace"
+ # Returns once the application has at least fired ONE tracepoint.
+ start_test_app
lttng_snapshot_record $SESSION_NAME
rm -rf $TRACE_PATH
fi
- diag "Killing $TESTAPP_NAME"
- PID_APP=`pidof $TESTAPP_NAME`
- kill $PID_APP >/dev/null 2>&1
+ kill_test_app
}
function test_ust_local_snapshot_large_metadata ()
enable_ust_lttng_event $SESSION_NAME $EVENT_NAME $CHANNEL_NAME
start_lttng_tracing $SESSION_NAME
lttng_snapshot_add_output $SESSION_NAME $TRACE_PATH
- $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT &
- ok $? "Start application to trace"
+
+ # Returns once the application has at least fired ONE tracepoint.
+ start_test_app
+
lttng_snapshot_record $SESSION_NAME
stop_lttng_tracing $SESSION_NAME
destroy_lttng_session $SESSION_NAME
else
break
fi
- diag "Killing $TESTAPP_NAME"
- PID_APP=`pidof $TESTAPP_NAME`
- kill $PID_APP >/dev/null 2>&1
+
+ kill_test_app
}
function test_ust_per_uid_local_snapshot_post_mortem ()
enable_ust_lttng_event $SESSION_NAME $EVENT_NAME $CHANNEL_NAME
start_lttng_tracing $SESSION_NAME
lttng_snapshot_add_output $SESSION_NAME $TRACE_PATH
- $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT &
- ok $? "Start application to trace"
- diag "Killing $TESTAPP_NAME"
- PID_APP=`pidof $TESTAPP_NAME`
- kill $PID_APP >/dev/null 2>&1
+
+ # Returns once the application has at least fired ONE tracepoint.
+ start_test_app
+ kill_test_app
+
lttng_snapshot_record $SESSION_NAME
stop_lttng_tracing $SESSION_NAME
destroy_lttng_session $SESSION_NAME
enable_ust_lttng_event $SESSION_NAME $EVENT_NAME $CHANNEL_NAME
start_lttng_tracing $SESSION_NAME
lttng_snapshot_add_output $SESSION_NAME $TRACE_PATH
- $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT &
+
+ # Returns once the application has at least fired ONE tracepoint.
+ start_test_app
+
for i in $(seq 1 $NB_SNAP); do
diag "Snapshot $i/$NB_SNAP"
rm -rf $TRACE_PATH/snapshot/* 2>/dev/null
done
stop_lttng_tracing $SESSION_NAME
destroy_lttng_session $SESSION_NAME
- diag "Killing $TESTAPP_NAME"
- PID_APP=`pidof $TESTAPP_NAME`
- kill $PID_APP >/dev/null 2>&1
+
+ kill_test_app
}
plan_tests $NUM_TESTS
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <assert.h>
#include <arpa/inet.h>
+#include <fcntl.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#define TRACEPOINT_DEFINE
#include "tp.h"
+void create_file(const char *path)
+{
+ int ret;
+
+ assert(path);
+
+ ret = creat(path, S_IRWXU);
+ if (ret < 0) {
+ fprintf(stderr, "Failed to create file %s\n", path);
+ return;
+ }
+
+ (void) close(ret);
+}
+
int main(int argc, char **argv)
{
int i, netint;
float flt = 2222.0;
unsigned int nr_iter = 100;
useconds_t nr_usec = 0;
+ char *tmp_file_path = NULL;
if (argc >= 2) {
nr_iter = atoi(argv[1]);
nr_usec = atoi(argv[2]);
}
+ if (argc == 4) {
+ tmp_file_path = argv[3];
+ }
+
for (i = 0; i < nr_iter; i++) {
netint = htonl(i);
- tracepoint(tp, tptest, i, netint, values, text, strlen(text),
- dbl, flt);
+ 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) {
+ create_file(tmp_file_path);
+ }
usleep(nr_usec);
}