Skip to content

Commit

Permalink
Tests: cleanup: reuse snapshot utils functions
Browse files Browse the repository at this point in the history
Signed-off-by: Francis Deslauriers <[email protected]>
  • Loading branch information
frdeso committed Dec 4, 2018
1 parent b0384fb commit 3aae351
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 80 deletions.
23 changes: 4 additions & 19 deletions tests/regression/tools/snapshots/test_kernel_streaming
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,6 @@ NUM_TESTS=36

source $TESTDIR/utils/utils.sh

function snapshot_add_output ()
{
local sess_name=$1
local trace_path=$2
local name=$3
local extra_opt=""

if [ ! -z $name ]; then
extra_opt="-n $name"
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"
}

# Test a snapshot using a default name for the output destination.
function test_kernel_default_name_with_del()
{
Expand All @@ -51,7 +36,7 @@ function test_kernel_default_name_with_del()
enable_lttng_mmap_overwrite_kernel_channel $SESSION_NAME $CHANNEL_NAME
lttng_enable_kernel_event $SESSION_NAME $EVENT_NAME $CHANNEL_NAME
start_lttng_tracing_ok $SESSION_NAME
snapshot_add_output $SESSION_NAME "net://localhost"
lttng_snapshot_add_output_ok $SESSION_NAME "net://localhost"
lttng_snapshot_record $SESSION_NAME

# Validate test
Expand All @@ -61,7 +46,7 @@ function test_kernel_default_name_with_del()
fi

lttng_snapshot_del_output_ok $SESSION_NAME 1
snapshot_add_output $SESSION_NAME "net://localhost"
lttng_snapshot_add_output_ok $SESSION_NAME "net://localhost"
lttng_snapshot_record $SESSION_NAME

# Validate test with the next ID since a del output was done prior.
Expand All @@ -84,7 +69,7 @@ function test_kernel_default_name()
enable_lttng_mmap_overwrite_kernel_channel $SESSION_NAME $CHANNEL_NAME
lttng_enable_kernel_event $SESSION_NAME $EVENT_NAME $CHANNEL_NAME
start_lttng_tracing_ok $SESSION_NAME
snapshot_add_output $SESSION_NAME "net://localhost"
lttng_snapshot_add_output_ok $SESSION_NAME "net://localhost"
lttng_snapshot_record $SESSION_NAME
stop_lttng_tracing_ok $SESSION_NAME
destroy_lttng_session_ok $SESSION_NAME
Expand All @@ -106,7 +91,7 @@ function test_kernel_custom_name()
enable_lttng_mmap_overwrite_kernel_channel $SESSION_NAME $CHANNEL_NAME
lttng_enable_kernel_event $SESSION_NAME $EVENT_NAME $CHANNEL_NAME
start_lttng_tracing_ok $SESSION_NAME
snapshot_add_output $SESSION_NAME "net://localhost" $name
lttng_snapshot_add_output_ok $SESSION_NAME "net://localhost" $name
lttng_snapshot_record $SESSION_NAME
stop_lttng_tracing_ok $SESSION_NAME
destroy_lttng_session_ok $SESSION_NAME
Expand Down
25 changes: 5 additions & 20 deletions tests/regression/tools/snapshots/test_ust_streaming
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,6 @@ if [ ! -x "$TESTAPP_BIN" ]; then
BAIL_OUT "No UST events binary detected."
fi

function snapshot_add_output ()
{
local sess_name=$1
local trace_path=$2
local name=$3
local extra_opt=""

if [ ! -z $name ]; then
extra_opt="-n $name"
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"
}

# Start trace application and return once one event has been hit.
function start_test_app()
{
Expand Down Expand Up @@ -95,7 +80,7 @@ function test_ust_default_name_with_del()

start_test_app

snapshot_add_output $SESSION_NAME "net://localhost"
lttng_snapshot_add_output_ok $SESSION_NAME "net://localhost"
lttng_snapshot_record $SESSION_NAME

# Validate test
Expand All @@ -107,7 +92,7 @@ function test_ust_default_name_with_del()
fi

lttng_snapshot_del_output_ok $SESSION_NAME 1
snapshot_add_output $SESSION_NAME "net://localhost"
lttng_snapshot_add_output_ok $SESSION_NAME "net://localhost"
lttng_snapshot_record $SESSION_NAME

# Validate test with the next ID since a del output was done prior.
Expand Down Expand Up @@ -136,7 +121,7 @@ function test_ust_default_name()

start_test_app

snapshot_add_output $SESSION_NAME "net://localhost"
lttng_snapshot_add_output_ok $SESSION_NAME "net://localhost"
lttng_snapshot_record $SESSION_NAME
stop_lttng_tracing_ok $SESSION_NAME
destroy_lttng_session_ok $SESSION_NAME
Expand All @@ -159,7 +144,7 @@ function test_ust_default_name_custom_uri()

start_test_app

snapshot_add_output $SESSION_NAME "-C tcp://localhost:5342 -D tcp://localhost:5343"
lttng_snapshot_add_output_ok $SESSION_NAME "-C tcp://localhost:5342 -D tcp://localhost:5343"
lttng_snapshot_record $SESSION_NAME
stop_lttng_tracing_ok $SESSION_NAME
destroy_lttng_session_ok $SESSION_NAME
Expand All @@ -186,7 +171,7 @@ function test_ust_custom_name()

start_test_app

snapshot_add_output $SESSION_NAME "net://localhost" $name
lttng_snapshot_add_output_ok $SESSION_NAME "net://localhost" $name
lttng_snapshot_record $SESSION_NAME
stop_lttng_tracing_ok $SESSION_NAME
destroy_lttng_session_ok $SESSION_NAME
Expand Down
42 changes: 5 additions & 37 deletions tests/regression/tools/snapshots/ust_test
Original file line number Diff line number Diff line change
Expand Up @@ -81,39 +81,6 @@ function stop_test_apps()
APPS_PID=
}

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
Expand Down Expand Up @@ -164,15 +131,15 @@ function test_ust_list_output ()

start_lttng_tracing_ok $SESSION_NAME

snapshot_add_output $SESSION_NAME "file://$TRACE_PATH" ${output_names[0]}
lttng_snapshot_add_output_ok $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]}
lttng_snapshot_del_output_ok $SESSION_NAME ${output_names[0]}

snapshot_add_output $SESSION_NAME "file://$TRACE_PATH" ${output_names[1]}
lttng_snapshot_add_output_ok $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
Expand Down Expand Up @@ -306,6 +273,7 @@ function test_ust_local_snapshot_max_size ()
{
NR_ITER=-1
NR_USEC_WAIT=100
snapshot_name="max_size_snap"
page_size=`getconf PAGE_SIZE`
num_cpus=$(conf_proc_count)

Expand All @@ -323,7 +291,7 @@ function test_ust_local_snapshot_max_size ()
enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME $CHANNEL_NAME
start_lttng_tracing_ok $SESSION_NAME

snapshot_add_output $SESSION_NAME "file://$TRACE_PATH" "" $max_size
lttng_snapshot_add_output_ok $SESSION_NAME "file://$TRACE_PATH" $snapshot_name $max_size

# Returns once the application has at least fired ONE tracepoint.
start_test_app
Expand Down
3 changes: 2 additions & 1 deletion tests/regression/tools/streaming/test_high_throughput_limits
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ function snapshot_add_output
$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"
}

function reset_bw_limit
{
tc qdisc del dev $DEFAULT_IF root >/dev/null 2>&1
Expand Down Expand Up @@ -237,7 +238,7 @@ function test_low_data_socket_bandwidth_snapshot
enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME $CHANNEL_NAME
start_lttng_tracing_ok $SESSION_NAME
run_apps 1 10000
snapshot_add_output $SESSION_NAME $NETWORK_URI
lttng_snapshot_add_output_ok $SESSION_NAME $NETWORK_URI
lttng_snapshot_record $SESSION_NAME

# Validate that the trace is readable
Expand Down
18 changes: 15 additions & 3 deletions tests/utils/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1235,14 +1235,26 @@ function lttng_snapshot_add_output ()
local expected_to_fail=$1
local sess_name=$2
local trace_path=$3
local name=$4
local max_size=$5
local extra_opt=""

$TESTDIR/../src/bin/lttng/$LTTNG_BIN snapshot add-output -s $sess_name file://$trace_path 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
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 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
ret=$?
if [[ $expected_to_fail -eq 1 ]]; then
test "$ret" -ne "0"
ok $? "Added snapshot output file://$trace_path failed as expected"
ok $? "Added snapshot output $trace_path failed as expected"
else
ok $ret "Added snapshot output file://$trace_path"
ok $ret "Added snapshot output $trace_path ($extra_opt)"
fi
}

Expand Down

0 comments on commit 3aae351

Please sign in to comment.