From 9dc506ae3b7d654f25b8bdf905bc4ddfbe6c33dc Mon Sep 17 00:00:00 2001 From: Jonathan Rajotte Date: Thu, 22 Mar 2018 16:13:35 -0400 Subject: [PATCH] Tests: remove TRACE_PATH at the end of the rotation test only MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Clean the inside of TRACE_PATH directory between each test but do not delete the actual directory. Signed-off-by: Jonathan Rajotte Signed-off-by: Jérémie Galarneau --- .../regression/tools/rotation/rotate_utils.sh | 23 +++++++++++-------- tests/regression/tools/rotation/test_kernel | 6 +++-- tests/regression/tools/rotation/test_ust | 19 ++++++++------- 3 files changed, 28 insertions(+), 20 deletions(-) diff --git a/tests/regression/tools/rotation/rotate_utils.sh b/tests/regression/tools/rotation/rotate_utils.sh index 37ada9486..9c19e29b6 100644 --- a/tests/regression/tools/rotation/rotate_utils.sh +++ b/tests/regression/tools/rotation/rotate_utils.sh @@ -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 } diff --git a/tests/regression/tools/rotation/test_kernel b/tests/regression/tools/rotation/test_kernel index 93b3da1c0..3ef3b7dfd 100755 --- a/tests/regression/tools/rotation/test_kernel +++ b/tests/regression/tools/rotation/test_kernel @@ -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 diff --git a/tests/regression/tools/rotation/test_ust b/tests/regression/tools/rotation/test_ust index 1807168ce..5bd41382f 100755 --- a/tests/regression/tools/rotation/test_ust +++ b/tests/regression/tools/rotation/test_ust @@ -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 -- 2.34.1