[lttng-dev] [PATCH lttng-tools 1/2 v2] Tests: use functions from utils.sh

Jérémie Galarneau jeremie.galarneau at efficios.com
Wed Sep 16 18:48:30 EDT 2015


Merged, thanks!

Jérémie

On Fri, Sep 11, 2015 at 10:46 AM, Jonathan Rajotte
<jonathan.rajotte-julien at efficios.com> wrote:
> v2: remove redundant information in success message.
>
> Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien at efficios.com>
> ---
>  tests/regression/ust/test_event_basic | 56 +++++++++--------------------------
>  tests/utils/utils.sh                  | 38 ++++++++++++++++++++++++
>  2 files changed, 52 insertions(+), 42 deletions(-)
>
> diff --git a/tests/regression/ust/test_event_basic b/tests/regression/ust/test_event_basic
> index 31931a9..acc79e5 100755
> --- a/tests/regression/ust/test_event_basic
> +++ b/tests/regression/ust/test_event_basic
> @@ -23,39 +23,11 @@ LTTNG_BIN="lttng"
>  BIN_NAME="gen-ust-events"
>  SESSION_NAME="valid_filter"
>  EVENT_NAME="tp:tptest"
> -NUM_TESTS=25
> -
> -source $TESTDIR/utils/utils.sh
> -
> -function enable_ust_lttng_event_per_chan()
> -{
> -       sess_name="$1"
> -       event_name="$2"
> -       chan_name="$3"
> -
> -       $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" -s $sess_name -c $chan_name -u >/dev/null 2>&1
> -       ok $? "Enable event $event_name for session $sess_name in channel $chan_name"
> -}
>
> -function disable_ust_lttng_event_per_chan()
> -{
> -       sess_name="$1"
> -       event_name="$2"
> -       chan_name="$3"
> -
> -       $TESTDIR/../src/bin/lttng/$LTTNG_BIN disable-event "$event_name" -s $sess_name -c $chan_name -u >/dev/null 2>&1
> -       ok $? "Disable event $event_name for session $sess_name in channel $chan_name"
> -}
>
> -function add_ust_lttng_context()
> -{
> -       sess_name="$1"
> -       chan_name="$2"
> -       type="$3"
> +NUM_TESTS=25
>
> -       $TESTDIR/../src/bin/lttng/$LTTNG_BIN add-context -s $sess_name -c $chan_name -t $type -u >/dev/null 2>&1
> -       ok $? "Add context $type for session $sess_name in channel $chan_name"
> -}
> +source $TESTDIR/utils/utils.sh
>
>  function test_event_basic()
>  {
> @@ -74,21 +46,21 @@ function test_event_basic()
>         enable_ust_lttng_channel_ok $SESSION_NAME $CHAN_NAME
>         enable_ust_lttng_channel_ok $SESSION_NAME2 $CHAN_NAME2
>
> -       enable_ust_lttng_event_per_chan $SESSION_NAME $EVENT_NAME $CHAN_NAME
> -       enable_ust_lttng_event_per_chan $SESSION_NAME $EVENT_NAME2 $CHAN_NAME
> -       enable_ust_lttng_event_per_chan $SESSION_NAME2 $EVENT_NAME3 $CHAN_NAME2
> +       enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME $CHAN_NAME
> +       enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME2 $CHAN_NAME
> +       enable_ust_lttng_event_ok $SESSION_NAME2 $EVENT_NAME3 $CHAN_NAME2
>
> -       add_ust_lttng_context $SESSION_NAME $CHAN_NAME "vpid"
> -       add_ust_lttng_context $SESSION_NAME $CHAN_NAME "vtid"
> -       add_ust_lttng_context $SESSION_NAME $CHAN_NAME "pthread_id"
> -       add_ust_lttng_context $SESSION_NAME $CHAN_NAME "procname"
> -       add_ust_lttng_context $SESSION_NAME2 $CHAN_NAME2 "procname"
> +       add_context_ust_ok $SESSION_NAME $CHAN_NAME "vpid"
> +       add_context_ust_ok $SESSION_NAME $CHAN_NAME "vtid"
> +       add_context_ust_ok $SESSION_NAME $CHAN_NAME "pthread_id"
> +       add_context_ust_ok $SESSION_NAME $CHAN_NAME "procname"
> +       add_context_ust_ok $SESSION_NAME2 $CHAN_NAME2 "procname"
>
> -       disable_ust_lttng_event_per_chan $SESSION_NAME $EVENT_NAME $CHAN_NAME
> -       disable_ust_lttng_event_per_chan $SESSION_NAME2 $EVENT_NAME3 $CHAN_NAME2
> +       disable_ust_lttng_event $SESSION_NAME $EVENT_NAME $CHAN_NAME
> +       disable_ust_lttng_event $SESSION_NAME2 $EVENT_NAME3 $CHAN_NAME2
>
> -       enable_ust_lttng_event_per_chan $SESSION_NAME $EVENT_NAME $CHAN_NAME
> -       enable_ust_lttng_event_per_chan $SESSION_NAME2 $EVENT_NAME3 $CHAN_NAME2
> +       enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME $CHAN_NAME
> +       enable_ust_lttng_event_ok $SESSION_NAME2 $EVENT_NAME3 $CHAN_NAME2
>
>         start_lttng_tracing_ok
>         stop_lttng_tracing_ok
> diff --git a/tests/utils/utils.sh b/tests/utils/utils.sh
> index d466ee6..d45f747 100644
> --- a/tests/utils/utils.sh
> +++ b/tests/utils/utils.sh
> @@ -952,6 +952,44 @@ function lttng_untrack_fail()
>         lttng_untrack 1 "$@"
>  }
>
> +function add_context_lttng()
> +{
> +       local expected_to_fail="$1"
> +       local domain="$2"
> +       local session_name="$3"
> +       local channel_name="$4"
> +       local type="$5"
> +
> +       $TESTDIR/../src/bin/lttng/$LTTNG_BIN add-context -s $session_name -c $channel_name -t $type $domain  1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
> +       ret=$?
> +       if [[ $expected_to_fail -eq "1" ]]; then
> +               test $ret -ne "0"
> +               ok $? "Add context command failed as expected for type: $type"
> +       else
> +               ok $ret "Add context command for type: $type"
> +       fi
> +}
> +
> +function add_context_ust_ok()
> +{
> +       add_context_lttng 0 -u "$@"
> +}
> +
> +function add_context_ust_fail()
> +{
> +       add_context_lttng 1 -u "$@"
> +}
> +
> +function add_context_kernel_ok()
> +{
> +       add_context_lttng 0 -k "$@"
> +}
> +
> +function add_context_kernel_fail()
> +{
> +       add_context_lttng 1 -k "$@"
> +}
> +
>  function trace_matches ()
>  {
>         local event_name=$1
> --
> 2.1.4
>



-- 
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com



More information about the lttng-dev mailing list