X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=tests%2Fregression%2Ftools%2Frotation%2Frotate_utils.sh;h=13b158abcf96ef64d6feb2a0ebd3f34c2c347605;hp=37ada94864338cccf4556b1c49eb644ddef65ef0;hb=ef96836ca0f16e7afe7b815cc3a3752fb8ea0399;hpb=fc58be13f62e691645dd75d56ce26d2e121b13e0 diff --git a/tests/regression/tools/rotation/rotate_utils.sh b/tests/regression/tools/rotation/rotate_utils.sh index 37ada9486..13b158abc 100644 --- a/tests/regression/tools/rotation/rotate_utils.sh +++ b/tests/regression/tools/rotation/rotate_utils.sh @@ -1,3 +1,31 @@ +#!/bin/bash +# +# Copyright (C) - 2017 Julien Desfossez +# +# This library is free software; you can redistribute it and/or modify it under +# the terms of the GNU Lesser General Public License as published by the Free +# Software Foundation; version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +# details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with this library; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +# 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 +93,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 +144,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 }