* [LTP] [PATCH] Remove files which does not have a dmesg entry
@ 2010-06-28 11:52 Subrata Modak
2010-06-28 19:44 ` Mike Frysinger
2010-06-28 19:53 ` Garrett Cooper
0 siblings, 2 replies; 6+ messages in thread
From: Subrata Modak @ 2010-06-28 11:52 UTC (permalink / raw)
To: LTP List Members; +Cc: Mike Frysinger
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 <subrata@linux.vnet.ibm.com>,
---
--- ltp/runltp.orig 2010-06-28 10:02:42.000000000 +0530
+++ ltp/runltp 2010-06-28 10:21:04.000000000 +0530
@@ -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
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [LTP] [PATCH] Remove files which does not have a dmesg entry
2010-06-28 11:52 [LTP] [PATCH] Remove files which does not have a dmesg entry Subrata Modak
@ 2010-06-28 19:44 ` Mike Frysinger
2010-06-28 19:47 ` Garrett Cooper
2010-06-28 19:53 ` Garrett Cooper
1 sibling, 1 reply; 6+ messages in thread
From: Mike Frysinger @ 2010-06-28 19:44 UTC (permalink / raw)
To: Subrata Modak; +Cc: LTP List Members
[-- Attachment #1.1: Type: Text/Plain, Size: 546 bytes --]
On Monday, June 28, 2010 07:52:18 Subrata Modak wrote:
> + 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
ugh. what's wrong with simply executing:
find "$DMESG_DIR" -size 0 -exec rm {} +
> + if [ `ls -l $DMESG_DIR | wc -l` -ge 1 ]; then
if [ -n "$(ls "$DMESG_DIR")" ] ; then
-mike
[-- Attachment #1.2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
[-- Attachment #2: Type: text/plain, Size: 235 bytes --]
------------------------------------------------------------------------------
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
[-- Attachment #3: Type: text/plain, Size: 155 bytes --]
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [LTP] [PATCH] Remove files which does not have a dmesg entry
2010-06-28 19:44 ` Mike Frysinger
@ 2010-06-28 19:47 ` Garrett Cooper
2010-06-28 19:52 ` Mike Frysinger
0 siblings, 1 reply; 6+ messages in thread
From: Garrett Cooper @ 2010-06-28 19:47 UTC (permalink / raw)
To: Mike Frysinger; +Cc: LTP List Members
On Mon, Jun 28, 2010 at 12:44 PM, Mike Frysinger <vapier@gentoo.org> wrote:
> On Monday, June 28, 2010 07:52:18 Subrata Modak wrote:
>> + 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
>
> ugh. what's wrong with simply executing:
> find "$DMESG_DIR" -size 0 -exec rm {} +
Or find "$DMESG_DIR" -size 0 | xargs rm -f ?
>> + 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
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [LTP] [PATCH] Remove files which does not have a dmesg entry
2010-06-28 19:47 ` Garrett Cooper
@ 2010-06-28 19:52 ` Mike Frysinger
0 siblings, 0 replies; 6+ messages in thread
From: Mike Frysinger @ 2010-06-28 19:52 UTC (permalink / raw)
To: Garrett Cooper; +Cc: LTP List Members
[-- Attachment #1.1: Type: Text/Plain, Size: 1007 bytes --]
On Monday, June 28, 2010 15:47:27 Garrett Cooper wrote:
> On Mon, Jun 28, 2010 at 12:44 PM, Mike Frysinger <vapier@gentoo.org> wrote:
> > On Monday, June 28, 2010 07:52:18 Subrata Modak wrote:
> >> + 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
> >
> > 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
[-- Attachment #1.2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
[-- Attachment #2: Type: text/plain, Size: 235 bytes --]
------------------------------------------------------------------------------
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
[-- Attachment #3: Type: text/plain, Size: 155 bytes --]
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [LTP] [PATCH] Remove files which does not have a dmesg entry
2010-06-28 11:52 [LTP] [PATCH] Remove files which does not have a dmesg entry Subrata Modak
2010-06-28 19:44 ` Mike Frysinger
@ 2010-06-28 19:53 ` Garrett Cooper
2010-06-28 19:54 ` Mike Frysinger
1 sibling, 1 reply; 6+ messages in thread
From: Garrett Cooper @ 2010-06-28 19:53 UTC (permalink / raw)
To: Subrata Modak; +Cc: LTP List Members, Mike Frysinger
On Mon, Jun 28, 2010 at 4:52 AM, Subrata Modak
<subrata@linux.vnet.ibm.com> wrote:
> 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 <subrata@linux.vnet.ibm.com>,
> ---
>
> --- ltp/runltp.orig 2010-06-28 10:02:42.000000000 +0530
> +++ ltp/runltp 2010-06-28 10:21:04.000000000 +0530
> @@ -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
> +
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.
> + if [ $ALT_DMESG_OUT -eq 1 ] ; then
> + PWD=`pwd`
Please use a different variable name. This obfuscates the meaning of
the shell set value.
> + 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).
> + 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
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
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [LTP] [PATCH] Remove files which does not have a dmesg entry
2010-06-28 19:53 ` Garrett Cooper
@ 2010-06-28 19:54 ` Mike Frysinger
0 siblings, 0 replies; 6+ messages in thread
From: Mike Frysinger @ 2010-06-28 19:54 UTC (permalink / raw)
To: Garrett Cooper; +Cc: LTP List Members
[-- Attachment #1.1: Type: Text/Plain, Size: 416 bytes --]
On Monday, June 28, 2010 15:53:11 Garrett Cooper wrote:
> On Mon, Jun 28, 2010 at 4:52 AM, Subrata Modak wrote:
> > + 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
[-- Attachment #1.2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
[-- Attachment #2: Type: text/plain, Size: 235 bytes --]
------------------------------------------------------------------------------
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
[-- Attachment #3: Type: text/plain, Size: 155 bytes --]
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2010-06-28 20:10 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-28 11:52 [LTP] [PATCH] Remove files which does not have a dmesg entry Subrata Modak
2010-06-28 19:44 ` Mike Frysinger
2010-06-28 19:47 ` Garrett Cooper
2010-06-28 19:52 ` Mike Frysinger
2010-06-28 19:53 ` Garrett Cooper
2010-06-28 19:54 ` Mike Frysinger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox