Fix: add missing synchronization point for before app test case
[lttng-tools.git] / tests / regression / ust / java-jul / test_java_jul
index a91904af4b28f1323a9f5a04aad4e2d97d2c4151..732fc024d9eabccaf002574e2866c4fe51657172 100755 (executable)
@@ -38,7 +38,8 @@ function run_app
        local finest_tp=$1
        local fire_second_tp=$2
 
-       java -cp $JAVA_CP -Djava.library.path="/usr/local/lib:/usr/lib" $TESTAPP_NAME $NR_ITER $NR_MSEC_WAIT $finest_tp $fire_second_tp >/dev/null 2>&1 &
+       #FIXME: app should have synchro.
+       java -cp $JAVA_CP -Djava.library.path="/usr/local/lib:/usr/lib" $TESTAPP_NAME $NR_ITER $NR_MSEC_WAIT $finest_tp $fire_second_tp >/dev/null 2>&1
 }
 
 function wait_apps
@@ -71,6 +72,9 @@ function enable_jul_loglevel_only()
 
 function test_jul_before_start ()
 {
+       local file_sync_after_first=$(mktemp -u)
+       local file_sync_before_last=$(mktemp -u)
+
        diag "Test JUL application BEFORE tracing starts"
        create_lttng_session $SESSION_NAME $TRACE_PATH
        enable_jul_lttng_event $SESSION_NAME $EVENT_NAME
@@ -80,11 +84,17 @@ function test_jul_before_start ()
 
        start_lttng_tracing $SESSION_NAME
 
-       wait_apps
+       touch ${file_sync_before_last}
+
+       # Wait for the applications started in background
+       wait
 
        stop_lttng_tracing $SESSION_NAME
        destroy_lttng_session $SESSION_NAME
 
+       rm -f ${file_sync_after_first}
+       rm -f ${file_sync_before_last}
+
        # Validate test. Expecting all events.
        trace_matches $EVENT_NAME $NR_ITER $TRACE_PATH
        if [ $? -ne 0 ]; then
@@ -296,7 +306,8 @@ function test_jul_destroy_session()
        # Run 5 times with a 1 second delay
        run_app 0 1
 
-       sleep 1
+       # Wait for the applications started in background
+       wait
 
        stop_lttng_tracing $SESSION_NAME
        destroy_lttng_session $SESSION_NAME
@@ -311,7 +322,11 @@ function test_jul_destroy_session()
        enable_jul_lttng_event $SESSION_NAME $EVENT_NAME2
        start_lttng_tracing $SESSION_NAME
 
-       wait_apps
+       # Run 5 times with a 1 second delay
+       run_app_background 0 1
+
+       # Wait for the applications started in background
+       wait
 
        stop_lttng_tracing $SESSION_NAME
        destroy_lttng_session $SESSION_NAME
@@ -323,6 +338,31 @@ function test_jul_destroy_session()
        fi
 }
 
+function test_jul_disable()
+{
+       diag "Test JUL disable event"
+
+       create_lttng_session $SESSION_NAME $TRACE_PATH/$SESSION_NAME
+       # Enable all event with a filter.
+       enable_jul_lttng_event $SESSION_NAME $EVENT_NAME
+       enable_jul_lttng_event $SESSION_NAME $EVENT_NAME2
+       disable_jul_lttng_event $SESSION_NAME $EVENT_NAME
+       start_lttng_tracing $SESSION_NAME
+
+       # Fire second TP but not the finest one.
+       run_app 0 1
+       wait_apps
+
+       stop_lttng_tracing $SESSION_NAME
+       destroy_lttng_session $SESSION_NAME
+
+       # Validate test. Expecting one event of the second TP only.
+       trace_match_only $EVENT_NAME2 1 $TRACE_PATH/$SESSION_NAME
+       if [ $? -ne 0 ]; then
+               return $?
+       fi
+}
+
 plan_tests $NUM_TESTS
 
 print_test_banner "$TEST_DESC"
@@ -338,6 +378,7 @@ skip $withapp "JUL support is needed. Skipping all tests." $NUM_TESTS ||
        start_lttng_sessiond
 
        tests=(
+               test_jul_disable
                test_jul_multi_session_loglevel
                test_jul_destroy_session
                test_jul_loglevel
@@ -355,7 +396,7 @@ skip $withapp "JUL support is needed. Skipping all tests." $NUM_TESTS ||
                if [ $? -ne 0 ]; then
                        break;
                fi
-               rm -rf $TRACE_PATH
+               #rm -rf $TRACE_PATH
        done
 
        stop_lttng_sessiond
This page took 0.03023 seconds and 4 git commands to generate.