The following patch complements previous ones to fix/improve the
behaviour of cron_tests.sh script. Some fixes inspired in CAI Qian's
previous posts.
Changes:
1- Added LANG= in the script executed by cron to avoid issues with
internationalization.
2- Reordered some tests so that one checks if one of the variables
TS_MIN is empty (in case there was some problem to create the file
tst1_cron.out)
3- Eliminated the \t\n from the output strings that caused the problem
reported by Subrata
4- Fixed the order the expected x received values are printed out to the
output log
This version fixes an error in the previous patch that prevented it from
applying correctly and added minor cosmetic changes.
Signed-Off-By: Elder Costa <[EMAIL PROTECTED]>
--- ltp-cvs-081030a/testcases/commands/cron/cron_tests.sh.orig 2008-10-29
07:55:41.000000000 -0200
+++ ltp-cvs-081030a/testcases/commands/cron/cron_tests.sh 2008-10-30
10:51:36.000000000 -0200
@@ -87,7 +87,7 @@
cat > $LTPTMP/tst1_cronprg.sh <<EOF
#! /bin/sh
-DATE=\`date\`
+DATE=\`LANG= date\`
echo "Hello Hell today is \$DATE " > $LTPTMP/tst1_cron.out 2>&1
exit 0
EOF
@@ -161,13 +161,6 @@
do
TS_MIN1=$(awk '{print $8}' $LTPTMP/tst1_cron.out |
awk -F: '{printf("%d", $2);}')
- if [ $TS_MIN1 -eq 59 ]
- then
- TS_MIN1=00
- else
- TS_MIN1=$(( $TS_MIN1+1 ))
- fi
-
# wait for the cronjob to update the tst1_cron.out file.
sleep 1m 2s
@@ -178,19 +171,36 @@
TS_MIN2=$(awk '{print $8}' $LTPTMP/tst1_cron.out |
awk -F: '{printf("%d", $2);}')
- if [ "$TS_MIN2" != "$TS_MIN1" ]
+ if [ "x${TS_MIN1}" = "x" ] || [ "x${TS_MIN2}" = "x" ]
+ then
+ $LTPBIN/tst_resm TFAIL \
+ "Test #1: Problem with $LTPTMP/tst1_cron.out file "
+ $LTPBIN/tst_resm TFAIL \
+ "Test #1: Cause: TS_MIN1= $TS_MIN1; TS_MIN2= $TS_MIN2"
+ FAILCNT=$(( $FAILCNT+1 ))
+ break;
+ fi
+
+ if [ $TS_MIN1 -eq 59 ]
+ then
+ TS_MIN1=0
+ else
+ TS_MIN1=$(( $TS_MIN1+1 ))
+ fi
+
+ if [ $TS_MIN2 -ne $TS_MIN1 ]
then
# if the value of the minute field did not advance by 1
# flag as failure.
FAILCNT=$(( $FAILCNT+1 ))
- echo "\n\t\tExpected $TS_MIN2 \n\t\tReceived $TS_MIN1" \
+ echo " Expected $TS_MIN1; Received $TS_MIN2" \
> $LTPTMP/tst1_cron.log
$LTPBIN/tst_res TFAIL $LTPTMP/tst1_cron.log \
"Test #1: Failed to update every minute. Reason:"
crontab -r >/dev/null 2>&1
break
else
- echo "\n\t\tExpected $TS_MIN2 \n\t\tReceived $TS_MIN1" \
+ echo " Expected $TS_MIN1; Received $TS_MIN2" \
> $LTPTMP/tst1_cron.log
$LTPBIN/tst_res TINFO $LTPTMP/tst1_cron.log \
"Test #1: Values are good: "
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list