Hi Subrata,
I took a look at the merged code and found that we could simplify and remove
the duplicated code there.
I made this patch to remove the duplicated code, please review and say what do
you think about it. I think that with this patch is much easier to read and
understand the code :)
Thanks,
Ricardo Salveti
On Friday 14 September 2007 07:10:45 Subrata Modak wrote:
>I have merged this patch.
>--Subrata--
>
>On Tue, 2007-09-11 at 14:48 +0530, Subrata Modak wrote:
>> Hi,
>> I just observed that neither an Output file nor a Failed File is created
>> by PAN if they are not mentioned as absolute path(s). But the logic for
>> creation of LOG file exists either for an absolute path or under
>> $LTPROOT/result directory. Moreover i think it is prudent to always
>> create a Failed File for the user even if he/she explicitly did not
>> mention it.
>>
>> Following Patch addresses:
>> 1) Creation of Failed file under $LTPROOT/output directory, unless the
>> path is specific
>> 2) Creation of Output file under $LTPROOT/output directory, unless the
>> path is specific
>> 3) Compulsory Creation of Failed file, name depending on circumstances.
>>
>> Comments expected.
>>
>> --Regards--
>> Subrata
--
Ricardo Salveti de Araujo
Author: Ricardo Salveti de Araujo <[EMAIL PROTECTED]>
Date: Fri Sep 14 17:35:12 2007 -0300
Cleaning the code, separating the code that creates the output/results
directory to remove duplicated code.
diff --git a/runltp b/runltp
index 83444a9..136b080 100755
--- a/runltp
+++ b/runltp
@@ -50,6 +50,9 @@
# - added option to create Output File if it is not an absolute path
# - added option to create Failed File compulsory, even if user has not mentioned it
#
+# Sep 14 2007 - Modified - Ricardo Salveti de Araujo
+# - cleaning and removing duplicated code
+#
#################################################################################
@@ -132,7 +135,8 @@ main()
{
local CMDFILES=""
local PRETTY_PRT=""
- local ALT_DIR=0
+ local ALT_DIR_OUT=0
+ local ALT_DIR_RES=0
local RUN_NETEST=0
local QUIET_MODE=""
local VERBOSE_MODE=""
@@ -156,21 +160,13 @@ main()
$LTPROOT/testcases/bin/genload --cpu $NUM_PROCS >/dev/null 2>&1 &
GENLOAD=1 ;;
- C) echo "INFO: creating $LTPROOT/output directory"
- [ ! -d $LTPROOT/output ] && \
- {
- mkdir -p $LTPROOT/output || \
- {
- echo "ERROR: failed to create $LTPROOT/output"
- exit 1
- }
- }
+ C)
case $OPTARG in
/*)
FAILCMDFILE="-C $OPTARG" ;;
*)
FAILCMDFILE="-C $LTPROOT/output/$OPTARG"
- ALT_DIR=1 ;;
+ ALT_DIR_OUT=1 ;;
esac ;;
d) # append $$ to TMP, as it is recursively
@@ -197,21 +193,12 @@ main()
l)
LOGFILE_NAME="$OPTARG"
- echo "INFO: creating $LTPROOT/results directory"
- [ ! -d $LTPROOT/results ] && \
- {
- mkdir -p $LTPROOT/results || \
- {
- echo "ERROR: failed to create $LTPROOT/results"
- exit 1
- }
- }
case $OPTARG in
- /*)
+ /*)
LOGFILE="-l $OPTARG" ;;
*)
LOGFILE="-l $LTPROOT/results/$OPTARG"
- ALT_DIR=1 ;;
+ ALT_DIR_RES=1 ;;
esac ;;
m)
@@ -227,21 +214,12 @@ main()
NETPIPE=1;;
o) OUTPUTFILE_NAME="$OPTARG"
- echo "INFO: creating $LTPROOT/output directory"
- [ ! -d $LTPROOT/output ] && \
- {
- mkdir -p $LTPROOT/output || \
- {
- echo "ERROR: failed to create $LTPROOT/output"
- exit 1
- }
- }
case $OPTARG in
/*)
OUTPUTFILE="-o $OPTARG";;
*)
OUTPUTFILE="-o $LTPROOT/output/$OPTARG"
- ALT_DIR=1 ;;
+ ALT_DIR_OUT=1 ;;
esac ;;
p) PRETTY_PRT=" -p ";;
@@ -279,31 +257,48 @@ main()
if [ ! "$FAILCMDFILE" ]; then ## User has not mentioned about Failed File name
echo Inside Failed File Name not Mentioned
- [ ! -d $LTPROOT/output ] && \ ## Try Creating output Directory if it doesn exist in First Place
- {
- mkdir -p $LTPROOT/output || \
- {
- echo "ERROR: failed to create $LTPROOT/output" ## Chuk out if not possible due to weired reason(s)
- exit 1
- }
- }
+ ALT_DIR_OUT=1
if [ ! "$OUTPUTFILE" ]; then ## User has not mentioned about Output File name either
if [ ! "$LOGFILE" ]; then ## User has not mentioned about Log File name either
FAILED_FILE_NAME=`date +"%Y_%b_%d-%Hh_%Mm_%Ss"`
FAILCMDFILE="-C $LTPROOT/output/LTP_RUN_ON-$FAILED_FILE_NAME.failed"
- ALT_DIR=1
else ## User Fortunately wanted a log file,
FAILED_FILE_NAME=`basename $LOGFILE_NAME` ## Extract log file name and use it to construct Failed file name
FAILCMDFILE="-C $LTPROOT/output/LTP_RUN_ON-$FAILED_FILE_NAME.failed"
- ALT_DIR=1
fi
else ## User Fortunately wanted a Output file
FAILED_FILE_NAME=`basename $OUTPUTFILE_NAME` ## Extract output file name and use it to construct Failed file name
FAILCMDFILE="-C $LTPROOT/output/LTP_RUN_ON-$FAILED_FILE_NAME.failed"
- ALT_DIR=1
fi
fi
+ # If we need, create the output directory
+ [ "$ALT_DIR_OUT" -eq 1 ] && \
+ {
+ echo "INFO: creating $LTPROOT/output directory"
+ [ ! -d $LTPROOT/output ] && \
+ {
+ mkdir -p $LTPROOT/output || \
+ {
+ echo "ERROR: failed to create $LTPROOT/output"
+ exit 1
+ }
+ }
+ }
+ # If we need, create the results directory
+ [ "$ALT_DIR_RES" -eq 1 ] && \
+ {
+ echo "INFO: creating $LTPROOT/results directory"
+ [ ! -d $LTPROOT/results ] && \
+ {
+ mkdir -p $LTPROOT/results || \
+ {
+ echo "ERROR: failed to create $LTPROOT/results"
+ exit 1
+ }
+ }
+ }
+
# Added -m 777 for tests that call tst_tmpdir() and try to
# write to it as user nobody
mkdir -m 777 -p $TMP || \
@@ -490,7 +485,7 @@ main()
[ "$GENLOAD" -eq 1 ] && { killall -9 genload ; }
[ "$NETPIPE" -eq 1 ] && { killall -9 NPtcp ; }
- [ "$ALT_DIR" -eq 1 ] && \
+ [ "$ALT_DIR_OUT" -eq 1 ] || [ "$ALT_DIR_RES" -eq 1 ] && \
{
cat <<-EOF >&1
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list