Tests: remove TRACE_PATH at the end of the rotation test only
[lttng-tools.git] / tests / regression / tools / rotation / rotate_utils.sh
index 1a78c174bdb8ef9d24111484c4d4ecf0fdf2481e..9c19e29b69dc2460d4c534b4203b48d322a719e0 100644 (file)
@@ -1,9 +1,20 @@
+# 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.
 
-       # YYYYMMDD-HHMMSS-YYYYMMDD-HHMMSS
-       export chunk_pattern="${today}-[0-9][0-9][0-9][0-9][0-9][0-9]-${today}-[0-9][0-9][0-9][0-9][0-9][0-9]"
+       # YYYYMMDDTHHMMSS[+-]HHMM-YYYYMMDDTHHMMSS[+-]HHMM
+       export chunk_pattern="${today}T[0-9][0-9][0-9][0-9][0-9][0-9][+-][0-9][0-9][0-9][0-9]-${today}T[0-9][0-9][0-9][0-9][0-9][0-9][+-][0-9][0-9][0-9][0-9]"
 }
 
 function validate_test_chunks ()
@@ -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
 }
This page took 0.023781 seconds and 4 git commands to generate.