From e3bef7256ce348cf232ede3f36721e661cfda2a7 Mon Sep 17 00:00:00 2001 From: Christian Babeux Date: Thu, 21 Mar 2013 15:56:44 -0400 Subject: [PATCH] Tests: Fix first line of output to follow TAP guidelines From the Test::Harness::TAP documentation [1]: The plan tells how many tests will be run, or how many tests have run. It's a check that the test file hasn't stopped prematurely. It must appear once, whether at the beginning or end of the output. The TAP plan *must* be the first line of output of any tests. Currently, most of the tests output their description and then the TAP plan. This can cause issues while parsing the test output for "strict" TAP parser such as the one used in the prove tool. This commit ensure that the first line outputted by any tests is the TAP plan. Signed-off-by: Christian Babeux Signed-off-by: David Goulet --- tests/regression/kernel/test_all_events | 4 ++-- tests/regression/kernel/test_event_basic | 4 ++-- tests/regression/tools/filtering/test_invalid_filter | 4 ++-- tests/regression/tools/filtering/test_unsupported_op | 4 ++-- tests/regression/tools/filtering/test_valid_filter | 4 ++-- tests/regression/tools/health/test_thread_exit | 5 +++-- tests/regression/tools/health/test_thread_stall | 4 ++-- tests/regression/tools/health/test_tp_fail | 4 ++-- tests/regression/tools/streaming/test_high_throughput_limits | 4 ++-- tests/regression/tools/streaming/test_kernel | 4 ++-- tests/regression/tools/streaming/test_ust | 4 ++-- tests/regression/ust/before-after/test_before_after | 4 ++-- tests/regression/ust/buffers-uid/test_buffers_uid | 4 ++-- tests/regression/ust/high-throughput/test_high_throughput | 4 ++-- tests/regression/ust/low-throughput/test_low_throughput | 4 ++-- tests/regression/ust/multi-session/test_multi_session | 4 ++-- tests/regression/ust/nprocesses/test_nprocesses | 4 ++-- tests/regression/ust/overlap/test_overlap | 4 ++-- tests/regression/ust/test_event_basic | 4 ++-- tests/regression/ust/test_event_wildcard | 4 ++-- tests/unit/test_kernel_data.c | 4 ++-- tests/unit/test_session.c | 4 ++-- tests/unit/test_uri.c | 4 ++-- tests/unit/test_ust_data.c | 4 ++-- 24 files changed, 49 insertions(+), 48 deletions(-) diff --git a/tests/regression/kernel/test_all_events b/tests/regression/kernel/test_all_events index 48627481b..afd42ab39 100755 --- a/tests/regression/kernel/test_all_events +++ b/tests/regression/kernel/test_all_events @@ -23,8 +23,6 @@ NUM_TESTS=8 source $TESTDIR/utils/utils.sh -print_test_banner "$TEST_DESC" - function test_all_event() { TRACE_PATH=$(mktemp -d) @@ -47,6 +45,8 @@ function test_all_event() # MUST set TESTDIR before calling those functions plan_tests $NUM_TESTS +print_test_banner "$TEST_DESC" + if [ "$(id -u)" == "0" ]; then isroot=1 else diff --git a/tests/regression/kernel/test_event_basic b/tests/regression/kernel/test_event_basic index 4de94dc67..5c19744d3 100755 --- a/tests/regression/kernel/test_event_basic +++ b/tests/regression/kernel/test_event_basic @@ -23,8 +23,6 @@ NUM_TESTS=12 source $TESTDIR/utils/utils.sh -print_test_banner "$TEST_DESC" - function test_event_basic() { TRACE_PATH=$(mktemp -d) @@ -51,6 +49,8 @@ function test_event_basic() # MUST set TESTDIR before calling those functions plan_tests $NUM_TESTS +print_test_banner "$TEST_DESC" + if [ "$(id -u)" == "0" ]; then isroot=1 else diff --git a/tests/regression/tools/filtering/test_invalid_filter b/tests/regression/tools/filtering/test_invalid_filter index 700fa2369..9e8a3c6f6 100755 --- a/tests/regression/tools/filtering/test_invalid_filter +++ b/tests/regression/tools/filtering/test_invalid_filter @@ -28,8 +28,6 @@ NUM_TESTS=119 source $TESTDIR/utils/utils.sh -print_test_banner "$TEST_DESC" - function enable_ust_lttng_event_filter { sess_name="$1" @@ -85,6 +83,8 @@ function test_bytecode_limit plan_tests $NUM_TESTS +print_test_banner "$TEST_DESC" + IFS=$'\n' INVALID_FILTERS=( # Unsupported ops diff --git a/tests/regression/tools/filtering/test_unsupported_op b/tests/regression/tools/filtering/test_unsupported_op index d0c6c8620..b5b7f27bb 100755 --- a/tests/regression/tools/filtering/test_unsupported_op +++ b/tests/regression/tools/filtering/test_unsupported_op @@ -27,8 +27,6 @@ TRACE_PATH=$(mktemp -d) NUM_TESTS=46 source $TESTDIR/utils/utils.sh -print_test_banner "$TEST_DESC" - function enable_ust_lttng_event_filter_unsupported { sess_name=$1 @@ -86,6 +84,8 @@ function test_unsupported_op plan_tests $NUM_TESTS +print_test_banner "$TEST_DESC" + # Unsupported operators OP_STR=("MUL" "DIV" "MOD" "PLUS" "MINUS" "LSHIFT" "RSHIFT" "BIN_AND" "BIN_OR" "BIN_XOR" "UNARY_BIN_NOT") diff --git a/tests/regression/tools/filtering/test_valid_filter b/tests/regression/tools/filtering/test_valid_filter index 09ac8689e..5587fdec2 100755 --- a/tests/regression/tools/filtering/test_valid_filter +++ b/tests/regression/tools/filtering/test_valid_filter @@ -29,8 +29,6 @@ NUM_TESTS=198 source $TESTDIR/utils/utils.sh -print_test_banner "$TEST_DESC" - if [ ! -x "$CURDIR/$BIN_NAME" ]; then BAIL_OUT "No UST nevents binary detected." fi @@ -313,6 +311,8 @@ function validator_true_statement plan_tests $NUM_TESTS +print_test_banner "$TEST_DESC" + IFS=$'\n' issue_356_filter="intfield > 0 && intfield > 1 && " diff --git a/tests/regression/tools/health/test_thread_exit b/tests/regression/tools/health/test_thread_exit index 885ad1941..aa2bd57c4 100755 --- a/tests/regression/tools/health/test_thread_exit +++ b/tests/regression/tools/health/test_thread_exit @@ -28,8 +28,6 @@ NUM_TESTS=12 source $TESTDIR/utils/utils.sh -print_test_banner "$TEST_DESC" - if [ ! -f "$CURDIR/$SESSIOND_PRELOAD" ]; then BAIL_OUT "libhealthexit.so not available for this test." fi @@ -78,8 +76,11 @@ function test_thread_exit return 1 fi } + plan_tests $NUM_TESTS +print_test_banner "$TEST_DESC" + THREAD=("LTTNG_THREAD_MANAGE_CLIENTS" "LTTNG_THREAD_MANAGE_APPS" "LTTNG_THREAD_REG_APPS") diff --git a/tests/regression/tools/health/test_thread_stall b/tests/regression/tools/health/test_thread_stall index 1651c021e..92951311b 100755 --- a/tests/regression/tools/health/test_thread_stall +++ b/tests/regression/tools/health/test_thread_stall @@ -28,8 +28,6 @@ NUM_TESTS=11 source $TESTDIR/utils/utils.sh -print_test_banner "$TEST_DESC" - if [ ! -f "$CURDIR/$SESSIOND_PRELOAD" ]; then BAIL_OUT "libhealthstall.so not available for this test." fi @@ -99,6 +97,8 @@ function test_thread_stall plan_tests $NUM_TESTS +print_test_banner "$TEST_DESC" + THREAD=("LTTNG_THREAD_MANAGE_CLIENTS" "LTTNG_THREAD_MANAGE_APPS" # This thread is a little bit tricky to stall, diff --git a/tests/regression/tools/health/test_tp_fail b/tests/regression/tools/health/test_tp_fail index fdb8745a2..c7db62488 100755 --- a/tests/regression/tools/health/test_tp_fail +++ b/tests/regression/tools/health/test_tp_fail @@ -28,8 +28,6 @@ NUM_TESTS=9 source $TESTDIR/utils/utils.sh -print_test_banner "$TEST_DESC" - if [ ! -f "$CURDIR/$SESSIOND_PRELOAD" ]; then BAIL_OUT "libhealthtpfail.so not available for this test." fi @@ -73,6 +71,8 @@ function test_tp_fail plan_tests $NUM_TESTS +print_test_banner "$TEST_DESC" + THREAD=("LTTNG_THREAD_MANAGE_CLIENTS" "LTTNG_THREAD_MANAGE_APPS") diff --git a/tests/regression/tools/streaming/test_high_throughput_limits b/tests/regression/tools/streaming/test_high_throughput_limits index 2412374bb..f3885a842 100755 --- a/tests/regression/tools/streaming/test_high_throughput_limits +++ b/tests/regression/tools/streaming/test_high_throughput_limits @@ -35,8 +35,6 @@ NUM_TESTS=112 source $TESTDIR/utils/utils.sh -print_test_banner "$TEST_DESC" - if [ ! -x "$CURDIR/$BIN_NAME" ]; then BAIL_OUT "No UST nevents binary detected." fi @@ -162,6 +160,8 @@ function interrupt_cleanup() plan_tests $NUM_TESTS +print_test_banner "$TEST_DESC" + if [ "$(id -u)" == "0" ]; then isroot=1 else diff --git a/tests/regression/tools/streaming/test_kernel b/tests/regression/tools/streaming/test_kernel index db529c53b..9877bb8d9 100755 --- a/tests/regression/tools/streaming/test_kernel +++ b/tests/regression/tools/streaming/test_kernel @@ -28,8 +28,6 @@ NUM_TESTS=10 source $TESTDIR/utils/utils.sh -print_test_banner "$TEST_DESC" - # LTTng kernel modules check out=`ls /lib/modules/$(uname -r)/extra | grep lttng` if [ -z "$out" ]; then @@ -79,6 +77,8 @@ function test_kernel_after_start () plan_tests $NUM_TESTS +print_test_banner "$TEST_DESC" + if [ "$(id -u)" == "0" ]; then isroot=1 else diff --git a/tests/regression/tools/streaming/test_ust b/tests/regression/tools/streaming/test_ust index 2d49cde31..333b2e9a9 100755 --- a/tests/regression/tools/streaming/test_ust +++ b/tests/regression/tools/streaming/test_ust @@ -29,8 +29,6 @@ NUM_TESTS=18 source $TESTDIR/utils/utils.sh -print_test_banner "$TEST_DESC" - if [ ! -x "$CURDIR/$BIN_NAME" ]; then BAIL_OUT "No UST nevents binary detected." fi @@ -87,6 +85,8 @@ function test_ust_after_start () plan_tests $NUM_TESTS +print_test_banner "$TEST_DESC" + start_lttng_relayd "-o $TRACE_PATH" start_lttng_sessiond diff --git a/tests/regression/ust/before-after/test_before_after b/tests/regression/ust/before-after/test_before_after index 6a5776e23..c3e24f7d8 100755 --- a/tests/regression/ust/before-after/test_before_after +++ b/tests/regression/ust/before-after/test_before_after @@ -25,8 +25,6 @@ NUM_TESTS=16 source $TESTDIR/utils/utils.sh -print_test_banner "$TEST_DESC" - if [ ! -x "$CURDIR/gen-nevents" ]; then BAIL_OUT "No UST nevents binary detected." fi @@ -86,6 +84,8 @@ test_after_apps() { # MUST set TESTDIR before calling those functions plan_tests $NUM_TESTS +print_test_banner "$TEST_DESC" + start_lttng_sessiond diag "Start application BEFORE tracing was started" diff --git a/tests/regression/ust/buffers-uid/test_buffers_uid b/tests/regression/ust/buffers-uid/test_buffers_uid index f56c458d1..97fd95d48 100755 --- a/tests/regression/ust/buffers-uid/test_buffers_uid +++ b/tests/regression/ust/buffers-uid/test_buffers_uid @@ -26,8 +26,6 @@ NUM_TESTS=58 source $TESTDIR/utils/utils.sh -print_test_banner "$TEST_DESC" - if [ ! -x "$CURDIR/gen-nevents" ]; then BAIL_OUT "No UST nevents binary detected." fi @@ -214,6 +212,8 @@ test_multiple_channels() { # MUST set TESTDIR before calling those functions plan_tests $NUM_TESTS +print_test_banner "$TEST_DESC" + TESTS=( "test_before_app" "test_after_app" diff --git a/tests/regression/ust/high-throughput/test_high_throughput b/tests/regression/ust/high-throughput/test_high_throughput index a801400c4..ea450511a 100755 --- a/tests/regression/ust/high-throughput/test_high_throughput +++ b/tests/regression/ust/high-throughput/test_high_throughput @@ -26,8 +26,6 @@ NUM_TESTS=9 source $TESTDIR/utils/utils.sh -print_test_banner "$TEST_DESC" - if [ ! -x "$CURDIR/$BIN_NAME" ]; then BAIL_OUT "No UST nevents binary detected." fi @@ -38,6 +36,8 @@ TRACE_PATH=$(mktemp -d) plan_tests $NUM_TESTS +print_test_banner "$TEST_DESC" + start_lttng_sessiond create_lttng_session $SESSION_NAME $TRACE_PATH diff --git a/tests/regression/ust/low-throughput/test_low_throughput b/tests/regression/ust/low-throughput/test_low_throughput index 197210afe..1ca3c38d0 100755 --- a/tests/regression/ust/low-throughput/test_low_throughput +++ b/tests/regression/ust/low-throughput/test_low_throughput @@ -25,8 +25,6 @@ NUM_TESTS=8 source $TESTDIR/utils/utils.sh -print_test_banner "$TEST_DESC" - if [ ! -x "$CURDIR/$BIN_NAME" ]; then BAIL_OUT "No UST nevents binary detected." fi @@ -37,6 +35,8 @@ TRACE_PATH=$(mktemp -d) plan_tests $NUM_TESTS +print_test_banner "$TEST_DESC" + start_lttng_sessiond create_lttng_session $SESSION_NAME $TRACE_PATH diff --git a/tests/regression/ust/multi-session/test_multi_session b/tests/regression/ust/multi-session/test_multi_session index ffe8355a8..313a7d70f 100755 --- a/tests/regression/ust/multi-session/test_multi_session +++ b/tests/regression/ust/multi-session/test_multi_session @@ -25,8 +25,6 @@ NUM_TESTS=28 source $TESTDIR/utils/utils.sh -print_test_banner "$TEST_DESC" - if [ ! -x "$CURDIR/gen-nevents" ]; then BAIL_OUT "No UST nevents binary detected." fi @@ -76,6 +74,8 @@ test_multi_session() { plan_tests $NUM_TESTS +print_test_banner "$TEST_DESC" + start_lttng_sessiond TRACE_PATH=$(mktemp -d) diff --git a/tests/regression/ust/nprocesses/test_nprocesses b/tests/regression/ust/nprocesses/test_nprocesses index ac8e99a15..418fda5c0 100755 --- a/tests/regression/ust/nprocesses/test_nprocesses +++ b/tests/regression/ust/nprocesses/test_nprocesses @@ -27,8 +27,6 @@ NUM_TESTS=9 source $TESTDIR/utils/utils.sh -print_test_banner "$TEST_DESC" - if [ ! -x "$CURDIR/$TEST_BIN_NAME" ]; then BAIL_OUT "No UST $TEST_BIN_NAME binary detected." fi @@ -37,6 +35,8 @@ fi plan_tests $NUM_TESTS +print_test_banner "$TEST_DESC" + start_lttng_sessiond # Start test for 1000 seconds diff --git a/tests/regression/ust/overlap/test_overlap b/tests/regression/ust/overlap/test_overlap index e82307251..add8ff140 100755 --- a/tests/regression/ust/overlap/test_overlap +++ b/tests/regression/ust/overlap/test_overlap @@ -34,8 +34,6 @@ NUM_TESTS=259 source $TESTDIR/utils/utils.sh -print_test_banner "$TEST_DESC" - if [ ! -x "$CURDIR/demo/demo" ]; then BAIL_OUT "No UST nevents binary detected." fi @@ -615,6 +613,8 @@ test_disable_wildcard_overlap() plan_tests $NUM_TESTS +print_test_banner "$TEST_DESC" + TESTS=( "test_enable_wildcard_filter" "test_enable_wildcard_filter_2" diff --git a/tests/regression/ust/test_event_basic b/tests/regression/ust/test_event_basic index 5a9cfe41b..3ff91b39e 100755 --- a/tests/regression/ust/test_event_basic +++ b/tests/regression/ust/test_event_basic @@ -27,8 +27,6 @@ NUM_TESTS=25 source $TESTDIR/utils/utils.sh -print_test_banner "$TEST_DESC" - function enable_ust_lttng_event_per_chan() { sess_name="$1" @@ -111,6 +109,8 @@ function test_event_basic() # MUST set TESTDIR before calling those functions plan_tests $NUM_TESTS +print_test_banner "$TEST_DESC" + start_lttng_sessiond test_event_basic diff --git a/tests/regression/ust/test_event_wildcard b/tests/regression/ust/test_event_wildcard index 88c02b08a..33ba4c4cc 100755 --- a/tests/regression/ust/test_event_wildcard +++ b/tests/regression/ust/test_event_wildcard @@ -27,8 +27,6 @@ NUM_TESTS=9 source $TESTDIR/utils/utils.sh -print_test_banner "$TEST_DESC" - function test_event_wildcard() { TRACE_PATH=$(mktemp -d) @@ -59,6 +57,8 @@ function test_event_wildcard() # MUST set TESTDIR before calling those functions plan_tests $NUM_TESTS +print_test_banner "$TEST_DESC" + start_lttng_sessiond test_event_wildcard diff --git a/tests/unit/test_kernel_data.c b/tests/unit/test_kernel_data.c index c9dc194d0..f36874564 100644 --- a/tests/unit/test_kernel_data.c +++ b/tests/unit/test_kernel_data.c @@ -177,10 +177,10 @@ static void test_create_kernel_stream(void) int main(int argc, char **argv) { - diag("Kernel data structure unit test"); - plan_tests(NUM_TESTS); + diag("Kernel data structure unit test"); + test_create_one_kernel_session(); test_create_kernel_metadata(); test_create_kernel_channel(); diff --git a/tests/unit/test_session.c b/tests/unit/test_session.c index 196124bd3..61db187f1 100644 --- a/tests/unit/test_session.c +++ b/tests/unit/test_session.c @@ -301,10 +301,10 @@ void test_large_session_number(void) int main(int argc, char **argv) { - diag("Sessions unit tests"); - plan_tests(NUM_TESTS); + diag("Sessions unit tests"); + test_session_list(); test_create_one_session(); diff --git a/tests/unit/test_uri.c b/tests/unit/test_uri.c index 91bd21c5e..ba0baf9b6 100644 --- a/tests/unit/test_uri.c +++ b/tests/unit/test_uri.c @@ -252,10 +252,10 @@ void test_uri_cmp() int main(int argc, char **argv) { - diag("URI unit tests"); - plan_tests(NUM_TESTS); + diag("URI unit tests"); + test_uri_parsing(); test_uri_cmp(); diff --git a/tests/unit/test_ust_data.c b/tests/unit/test_ust_data.c index 50d43bbd3..294b5c589 100644 --- a/tests/unit/test_ust_data.c +++ b/tests/unit/test_ust_data.c @@ -182,10 +182,10 @@ static void test_create_ust_context(void) int main(int argc, char **argv) { - diag("UST data structures unit test"); - plan_tests(NUM_TESTS); + diag("UST data structures unit test"); + test_create_one_ust_session(); test_create_ust_metadata(); test_create_ust_channel(); -- 2.34.1