On 2015/5/21 15:51, Cui Bixuan wrote:


-------- Original Message --------
Subject: [LTP] [PATCH] commands/logrotate:run the case once again will failed
Date: Tue, 5 May 2015 12:12:13 +0000
From: Cui Bixuan <cuibix...@huawei.com>
To: <ltp-list@lists.sourceforge.net>
CC: <lijin...@huawei.com>, <zhanyongm...@huawei.com>, <zhuyanp...@huawei.com>, Cui 
Bixuan <cuibix...@huawei.com>

For the first time,case do 'logrotate -fv tst_logrotate.conf' that will
create the 'half-rotated' file(messages-20150416.gz). When run case again,
the case will fail:
'error: destination /var/log/messages-20150416.gz already exists,skipping
rotation'

'Logrotate' does't expect to find an already existing "half-rotated" file
(http://centos.1050465.n5.nabble.com/CentOS-Logrotate-errors-td5725868.html).
Clean the "half-rotated" file,and the case will pass all the time.

Signed-off-by: Cui Bixuan <cuibix...@huawei.com>
---
  testcases/commands/logrotate/logrotate_tests.sh |    1 +
  1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/testcases/commands/logrotate/logrotate_tests.sh 
b/testcases/commands/logrotate/logrotate_tests.sh
index 2a793cc..5b14ca0 100755
--- a/testcases/commands/logrotate/logrotate_tests.sh
+++ b/testcases/commands/logrotate/logrotate_tests.sh
@@ -191,6 +191,7 @@ test01()
        do
                rm -f $files > /dev/null 2>&1
        done
+       rm -f /var/log/*`date '+%Y%m%d'`* > /dev/null 2>&1

If the current time is 23:59:59, a problem would occur. It is good to use the following command.
rm [0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]
Of course, it is better if you can find a way to use regular expressions to match it.

        chmod 644 $LTPTMP/tst_logrotate.conf
        logrotate -fv $LTPTMP/tst_logrotate.conf > $LTPTMP/tst_logrotate.out 
2>&1 \

------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud 
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to