Tests: remove TRACE_PATH at the end of the rotation test only
authorJonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Thu, 22 Mar 2018 20:13:35 +0000 (16:13 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 3 Apr 2018 20:13:06 +0000 (16:13 -0400)
Clean the inside of TRACE_PATH directory between each test but do not
delete the actual directory.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
tests/regression/tools/rotation/rotate_utils.sh
tests/regression/tools/rotation/test_kernel
tests/regression/tools/rotation/test_ust

index 37ada94864338cccf4556b1c49eb644ddef65ef0..9c19e29b69dc2460d4c534b4203b48d322a719e0 100644 (file)
@@ -1,3 +1,14 @@
+# Clean everything under directory but keep directory
+function clean_path ()
+{
+       local path=$1
+       # Use -u from bash top prevent empty expansion of variable yielding a
+       # list of current directory from find.
+       set -u
+       find $path -mindepth 1 -maxdepth 1 -exec rm -rf '{}' \;
+       set +u
+}
+
 function set_chunk_pattern ()
 {
        # Need to call this function after $today has been set.
@@ -65,12 +76,6 @@ function validate_test_chunks ()
        test -z "$(\ls -A $local_path)"
        empty=$?
        ok $empty "Trace folder is now empty"
-       if [ $empty -eq 0 ]; then
-       # Only delete if successful
-               rm -rf $local_path/
-       else
-               find $local_path
-       fi
 }
 
 function rotate_timer_test ()
@@ -122,8 +127,6 @@ function rotate_timer_test ()
                while [ $i -le $expected_chunks ]; do
                        validate_trace_empty $local_path/${chunk_pattern}-$i
                        i=$(($i+1))
-       done
-fi
-
-       rm -rf $local_path
+               done
+       fi
 }
index 93b3da1c0f0d5670dd9edc4a802cf91adae8cfc8..3ef3b7dfd298e85dd8d42f2e0c9d66d77481f76b 100755 (executable)
@@ -80,7 +80,7 @@ function test_kernel_streaming ()
        diag "Test kernel streaming with session rotation"
        lttng_create_session_uri
        rotate_kernel_test "${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*"
-       rm -rf ${TRACE_PATH}/${HOSTNAME}
+       clean_path $TRACE_PATH
 }
 
 function test_kernel_local ()
@@ -111,7 +111,7 @@ function test_kernel_streaming_timer ()
        start_lttng_tracing_ok $SESSION_NAME
 
        rotate_timer_test "${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*" 0
-       rm -rf ${TRACE_PATH}/${HOSTNAME}
+       clean_path $TRACE_PATH
 }
 
 plan_tests $NUM_TESTS
@@ -142,3 +142,5 @@ skip $isroot "Root access is needed. Skipping all kernel streaming tests." $NUM_
        stop_lttng_sessiond
        stop_lttng_relayd
 }
+
+rm -rf $TRACE_PATH
index 1807168ce304b4e7963e6b80810d99b2cc9a2503..5bd41382f657514a42769b3db0d5fdfc09d1843b 100755 (executable)
@@ -95,7 +95,7 @@ function test_ust_streaming_uid ()
        enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME
 
        rotate_ust_test "${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*" "ust/uid/*/*/" 0
-       rm -rf ${TRACE_PATH}/${HOSTNAME}
+       clean_path $TRACE_PATH
 }
 
 function test_ust_local_uid ()
@@ -105,7 +105,7 @@ function test_ust_local_uid ()
        enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME
 
        rotate_ust_test "${TRACE_PATH}" "ust/uid/*/*/" 0
-       rm -rf ${TRACE_PATH}
+       clean_path $TRACE_PATH
 }
 
 function test_ust_streaming_pid ()
@@ -116,7 +116,7 @@ function test_ust_streaming_pid ()
        enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME "channel0"
 
        rotate_ust_test "${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*" "ust/pid/*/" 1
-       rm -rf ${TRACE_PATH}/${HOSTNAME}
+       clean_path $TRACE_PATH
 }
 
 function test_ust_local_pid ()
@@ -127,7 +127,7 @@ function test_ust_local_pid ()
        enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME "channel0"
 
        rotate_ust_test "${TRACE_PATH}" "ust/pid/*/" 1
-       rm -rf ${TRACE_PATH}
+       clean_path $TRACE_PATH
 }
 
 function test_ust_local_timer_uid ()
@@ -141,7 +141,7 @@ function test_ust_local_timer_uid ()
        $TESTAPP_BIN 0 0 /dev/null 2>&1
 
        rotate_timer_test "${TRACE_PATH}" 0
-       rm -rf ${TRACE_PATH}
+       clean_path $TRACE_PATH
 }
 
 function test_ust_streaming_timer_uid ()
@@ -155,7 +155,7 @@ function test_ust_streaming_timer_uid ()
        $TESTAPP_BIN 0 0 /dev/null 2>&1
 
        rotate_timer_test "${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*" 0
-       rm -rf ${TRACE_PATH}/${HOSTNAME}
+       clean_path $TRACE_PATH
 }
 
 function test_ust_local_timer_pid ()
@@ -170,7 +170,7 @@ function test_ust_local_timer_pid ()
        $TESTAPP_BIN 0 0 /dev/null 2>&1
 
        rotate_timer_test "${TRACE_PATH}" 1
-       rm -rf ${TRACE_PATH}
+       clean_path $TRACE_PATH
 }
 
 function test_ust_streaming_timer_pid ()
@@ -185,7 +185,7 @@ function test_ust_streaming_timer_pid ()
        $TESTAPP_BIN 0 0 /dev/null 2>&1
 
        rotate_timer_test "${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*" 1
-       rm -rf ${TRACE_PATH}/${HOSTNAME}
+       clean_path $TRACE_PATH
 }
 
 function test_incompatible_sessions ()
@@ -243,3 +243,6 @@ done
 
 stop_lttng_sessiond
 stop_lttng_relayd
+
+# Remove tmp dir
+rm -rf $TRACE_PATH
This page took 0.029716 seconds and 4 git commands to generate.