+# Start trace application and return once one event has been hit.
+function start_test_app()
+{
+ local tmp_file=$(mktemp -u)
+
+ # Start application with a temporary file.
+ $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT --sync-after-first-event $tmp_file &
+ 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.
+ while [ ! -f "$tmp_file" ]; do
+ sleep 0.5
+ done
+ diag "Removing test app temporary file $tmp_file"
+ rm -f $tmp_file
+}
+
+function stop_test_apps()
+{
+ diag "Stopping $TESTAPP_NAME"
+ for p in ${APPS_PID}; do
+ kill ${p}
+ wait ${p} 2>/dev/null
+ done
+ APPS_PID=
+}
+