+function snapshot_add_output ()
+{
+ local sess_name=$1
+ local trace_path=$2
+ local name=$3
+ local max_size=$4
+ local extra_opt=""
+
+ if [ ! -z $name ]; then
+ extra_opt+=" -n $name "
+ fi
+
+ if [ ! -z $max_size ]; then
+ extra_opt+=" -m $max_size "
+ fi
+
+ $TESTDIR/../src/bin/lttng/$LTTNG_BIN snapshot add-output \
+ -s $sess_name $extra_opt $trace_path > /dev/null 2>&1
+
+ ok $? "Added snapshot output $trace_path ($extra_opt)"
+}
+
+function snapshot_del_output ()
+{
+ local sess_name=$1
+ local name=$2
+
+ $TESTDIR/../src/bin/lttng/$LTTNG_BIN snapshot del-output \
+ -s $sess_name $name > /dev/null 2>&1
+
+ ok $? "Deleted snapshot output named $name"
+}
+
+function enable_mmap_overwrite_subbuf_ust_channel ()
+{
+ local sess_name=$1
+ local chan_name=$2
+ local subbuf_size=$3
+
+ $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-channel -s $sess_name \
+ $chan_name -u --output mmap --overwrite \
+ --subbuf-size $subbuf_size > /dev/null 2>&1
+
+ ok $? "Enable channel $channel_name for session $sess_name with subbuf size $subbuf_size"
+}
+
+
+function test_ust_list_output ()
+{
+ output_names=("randomname" "somesnapshot")
+
+ diag "Test UST snapshot output listing"
+ create_lttng_session_no_output $SESSION_NAME
+ enable_lttng_mmap_overwrite_ust_channel $SESSION_NAME $CHANNEL_NAME
+ enable_ust_lttng_event $SESSION_NAME $EVENT_NAME $CHANNEL_NAME
+
+ start_lttng_tracing $SESSION_NAME
+
+ snapshot_add_output $SESSION_NAME "file://$TRACE_PATH" ${output_names[0]}
+
+ $TESTDIR/../src/bin/lttng/$LTTNG_BIN snapshot list-output \
+ -s $SESSION_NAME 2>&1 | grep ${output_names[0]} > /dev/null
+ ok $? "Snapshot named ${output_names[0]} present in list-output listing"
+
+ snapshot_del_output $SESSION_NAME ${output_names[0]}
+
+ snapshot_add_output $SESSION_NAME "file://$TRACE_PATH" ${output_names[1]}
+
+ $TESTDIR/../src/bin/lttng/$LTTNG_BIN snapshot list-output \
+ -s $SESSION_NAME 2>&1 | grep ${output_names[1]} > /dev/null
+
+ ok $? "Snapshot named ${output_names[1]} present in list-output listing"
+
+ stop_lttng_tracing $SESSION_NAME
+ destroy_lttng_session $SESSION_NAME
+}
+