Remove files which does not have a dmesg entry
PATCH 1/1 Remove files which does not have a dmesg entry
Hi,
The recently introduced option:
-K DMESG_LOG_DIR
Log Kernel messages generated for each test cases inside this directory,
when used will generate huge no. of files inside the DMESG_DIR. Many of them will be ZERO size as we do not expect KERNEL MESSAGE to be generated against all the LTP TESTS that we will run. It is better to prune them, and let only those files exist which will have real entries. The following patch fixes the same.
---
runltp renamed from runltp.orig +24 -0
@@ -858,6 +858,30 @@ main() cd .. echo "LTP Version: $version_date" + # DMESG_DIR will contain hell lot of files which will not have any entry + # since kernel message(s) will not be generated for every test. The zero size + # files will clog the directory. Lets keep only those fules which have real + # kernel message entries. If DMESG_DIR directroy is empty after test run, it + # will indicate that no kernel message was generated during test run + + if [ $ALT_DMESG_OUT -eq 1 ] ; then + PWD=`pwd` + cd $DMESG_DIR + for dmesg_file in `ls` + do + dmesg_file_size=`wc -c $dmesg_file | cut -d ' ' -f1 | tr -d '\n'` + if [ $dmesg_file_size -eq 0 ]; then + rm -rf $dmesg_file + fi + done + cd $PWD + fi + if [ `ls -l $DMESG_DIR | wc -l` -ge 1 ]; then + echo "Kernel messages were generated for LTP tests $version_date" + else + echo "No Kernel messages were generated for LTP tests $version_date" + fi + if [ "$ALT_HTML_OUT" -eq 1 ] ; then #User wants the HTML output to be created, it then needs to be generated export LTP_VERSION=$version_date export TEST_START_TIME=$test_start_time
---
Regards--
Subrata
------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone? Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
runltp main()
Quoted 6 lines · On Monday, June 28, 2010 07:52:18 Subrata Modak wrote:
runltp renamed from runltp.orig +6
-0+ if [ $ALT_DMESG_OUT -eq 1 ] ; then + PWD=`pwd` + cd $DMESG_DIR + for dmesg_file in `ls` + do + dmesg_file_size=`wc -c $dmesg_file | cut -d ' ' -f1 | tr -d
'\n'`
runltp main() · line 878
Quoted 6 lines
runltp renamed from runltp.orig +6
-0+ if [ $dmesg_file_size -eq 0 ]; then + rm -rf $dmesg_file + fi + done + cd $PWD + fi
ugh. what's wrong with simply executing:
find "$DMESG_DIR" -size 0 -exec rm {} +runltp main() · line 879
Quoted 1 line
runltp renamed from runltp.orig +1
-0+ if [ `ls -l $DMESG_DIR | wc -l` -ge 1 ]; then
if [ -n "$(ls "$DMESG_DIR")" ] ; then
-mike
------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone? Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
Quoted 15 lines · Mike Frysinger
Quoted 6 lines · On Monday, June 28, 2010 07:52:18 Subrata Modak wrote:
+ if [ $ALT_DMESG_OUT -eq 1 ] ; then
+ PWD=pwd
+ cd $DMESG_DIR
+ fordmesg_fileinls
+ do
+ dmesg_file_size=`wc -c $dmesg_file | cut -d ' ' -f1 | tr -d'\n'`
Quoted 6 lines
+ if [ $dmesg_file_size -eq 0 ]; then
+ rm -rf $dmesg_file
+ fi
+ done
+ cd $PWD
+ fi
Quoted 2 lines
ugh. what's wrong with simply executing:
find "$DMESG_DIR" -size 0 -exec rm {} +
Or find "$DMESG_DIR" -size 0 | xargs rm -f ?
Quoted 4 lines
Quoted 1 line
+ if [
ls -l $DMESG_DIR | wc -l-ge 1 ]; thenif [ -n "$(ls "$DMESG_DIR")" ] ; then
-mike
------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone? Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
Quoted 19 lines · On Monday, June 28, 2010 15:47:27 Garrett Cooper wrote:
Quoted 18 lines · Mike Frysinger
runltp main()
Quoted 7 lines · On Monday, June 28, 2010 07:52:18 Subrata Modak wrote:
runltp renamed from runltp.orig +6
-1+ if [ $ALT_DMESG_OUT -eq 1 ] ; then + PWD=`pwd` + cd $DMESG_DIR + for dmesg_file in `ls` + do + dmesg_file_size=`wc -c $dmesg_file | cut -d ' ' -f1 | tr -d'\n'`
Quoted 6 lines
runltp renamed from runltp.orig +6
-0+ if [ $dmesg_file_size -eq 0 ]; then + rm -rf $dmesg_file + fi + done + cd $PWD + fi
Quoted 4 lines
Quoted 2 lines
ugh. what's wrong with simply executing:
find "$DMESG_DIR" -size 0 -exec rm {} +Or find "$DMESG_DIR" -size 0 | xargs rm -f ?
no, because mine handles funky named files while yours does not. both are POSIX and handle command line length issues correctly.
-mike
------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone? Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
Quoted 22 lines · Subrata Modak
Hi,
The recently introduced option:
-K
DMESG_LOG_DIR
Log Kernel messages generated for each test cases inside this directory,when used will generate huge no. of files inside the
DMESG_DIR. Many of them will be ZERO size as we do not expect KERNEL MESSAGE to be generated against all the LTP TESTS that we will run. It is better to prune them, and let only those files exist which will have real entries. The following patch fixes the same.Signed-off-by Subrata Modak <[email protected]>,---
runltp 2010-06-28 10:21:04.000000000 +0530 renamed from runltp.orig 2010-06-28 10:02:42.000000000 +0530 +0
-0@@ -858,6 +858,30 @@ main()cd ..
echo "LTP Version: $version_date"
Quoted 6 lines
+ #
DMESG_DIRwill contain hell lot of files which will not have any entry
+ # since kernel message(s) will not be generated for every test. The zero size
+ # files will clog the directory. Lets keep only those fules which have real
+ # kernel message entries. IfDMESG_DIRdirectroy is empty after test run, it
+ # will indicate that no kernel message was generated during test run +
This comment could be abbreviated to:
# $DMESG_DIR is used to cache messages obtained from dmesg after a test run. # Proactively reap all of the 0-byte files in $DMESG_DIR as they have zero value
# and only clutter up the filesystem.
Quoted 2 lines
+ if [ $ALT_DMESG_OUT -eq 1 ] ; then
+ PWD=pwd
Please use a different variable name. This obfuscates the meaning of the shell set value.
Quoted 1 line
+ cd $DMESG_DIR
What if this fails? Won't this nuke all of the files in the current directory? Are you checking to ensure that this isn't empty beforehand as well? I hate it when scripts nuke files like this (I lost several hours of work last week because of a similar mistake).
Quoted 9 lines
+ for
dmesg_fileinls
+ do
+ dmesg_file_size=wc -c $dmesg_file | cut -d ' ' -f1 | tr -d '\n'
+ if [ $dmesg_file_size -eq 0 ]; then
+ rm -rf $dmesg_file
+ fi
+ done
+ cd $PWD
+ fi
Thanks,
-Garrett
------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone? Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
Quoted 6 lines · On Monday, June 28, 2010 15:53:11 Garrett Cooper wrote:
runltp main() · line 868
Quoted 2 lines · Subrata Modak
runltp renamed from runltp.orig +2
-0+ if [ $ALT_DMESG_OUT -eq 1 ] ; then + PWD=`pwd`Please use a different variable name. This obfuscates the meaning of the shell set value.
use a find as i suggested and changing dir isnt necessary. it replaces the entire body of the if statement.
-mike
------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone? Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list