The attached patch fixes some errors when running with Ubuntu due to some bash specific syntax. It also has some minor cosmetic and indentation changes.

Signed-Off-By: Elder Costa <[EMAIL PROTECTED]>


CAVEATS:
1- The comparisons failed because the script was generating empty files and the comparisons in line 181 failed. However the test proceeded as if the comparisons were successful. There is still room for improvement. 2- I had to change Ubuntu default configuration (enable cron log file and rename it from cron.log to cron) for the test to succeed.


Bellow the results before and after the changed.

------------------

cron01 0 INFO : Test #1: crontab <filename> installs the crontab file cron01 0 INFO : Test #1: cron schedules the job listed in crontab file.
cron01      0  INFO  :  Test #1: Installing cron job ...
cron01      0  INFO  :  Test #1: Cronjob installed successfully
cron01      0  INFO  :  Test #1: cron activity logged in /var/log/messages
[: 199: 59: unexpected operator
[: 199: 1: unexpected operator
cron01      0  INFO  :  Test #1: Values are good:

                 Expected
 Received 1
[: 199: 59: unexpected operator
[: 199: 1: unexpected operator
cron01      0  INFO  :  Test #1: Values are good:

                 Expected
 Received 1
[: 199: 59: unexpected operator
[: 199: 1: unexpected operator
cron01      0  INFO  :  Test #1: Values are good:

                 Expected
 Received 1
[: 199: 59: unexpected operator
[: 199: 1: unexpected operator
cron01      0  INFO  :  Test #1: Values are good:

                 Expected
 Received 1
[: 199: 59: unexpected operator
[: 199: 1: unexpected operator
cron01      0  INFO  :  Test #1: Values are good:

                 Expected
 Received 1
cron01 1 PASS : Test #1: installed cronjob, and cron executed the cronjob.
cron02      0  INFO  :  Test #2: crontab -r removes the crontab file.
cron02      0  INFO  :  Test #2: installing crontab file.
cron02      0  INFO  :  Test #2: uninstalling crontab file.
cron02      2  PASS  :  Test #2: crontab removed the cronjob
cron03      0  INFO  :  Test #3: crontab -l lists the cronjobs installed
cron03      0  INFO  :  Test #3: installing crontab file ...
cron03      0  INFO  :  Test #3: Cron job installed.
* * * * * /tmp/ltp-281008-085412/tst2_cronprg.sh
cron03      0  INFO  :  Test #3: crontab -l listed cronjob tst2_cronprg.sh
cron03      0  INFO  :  Test #3: uninstalling crontab file.
no crontab for root
cron03      0  INFO  :  crontab uninstalled all jobs for user
cron03      3  PASS  :  crontab did not list any cronjobs


--------------------

cron01 0 INFO : Test #1: crontab <filename> installs the crontab file cron01 0 INFO : Test #1: cron schedules the job listed in crontab file.
cron01      0  INFO  :  Test #1: Installing cron job ...
cron01      0  INFO  :  Test #1: Cronjob installed successfully
cron01      0  INFO  :  Test #1: /var/log/cron: Trying altenate log...
cron01      0  INFO  :  Test #1: cron activity logged in /var/log/messages
cron01      0  INFO  :  Test #1: Values are good:

                 Expected 25
 Received 25
cron01      0  INFO  :  Test #1: Values are good:

                 Expected 26
 Received 26
cron01      0  INFO  :  Test #1: Values are good:

                 Expected 27
 Received 27
cron01      0  INFO  :  Test #1: Values are good:

                 Expected 28
 Received 28
cron01      0  INFO  :  Test #1: Values are good:

                 Expected 29
 Received 29
cron01      0  INFO  :  Test #1: /var/log/cron: alternate...
cron01 1 PASS : Test #1: installed cronjob, and cron executed the cronjob.
cron02      0  INFO  :  Test #2: crontab -r removes the crontab file.
cron02      0  INFO  :  Test #2: installing crontab file.
cron02      0  INFO  :  Test #1: /var/log/cron: alternate...
cron02      0  INFO  :  Test #2: uninstalling crontab file.
cron02      0  INFO  :  Test #1: /var/log/cron: alternate...
cron02      2  PASS  :  Test #2: crontab removed the cronjob
cron03      0  INFO  :  Test #3: crontab -l lists the cronjobs installed
cron03      0  INFO  :  Test #3: installing crontab file ...
cron03      0  INFO  :  Test #3: Cron job installed.
cron03      0  INFO  :  Test #3: crontab -l listed cronjob tst2_cronprg.sh
cron03      0  INFO  :  Test #3: uninstalling crontab file.


--- cron_tests.sh.ORIG	2003-12-09 16:39:40.000000000 -0200
+++ cron_tests.sh	2008-10-28 08:47:02.000000000 -0200
@@ -88,7 +88,7 @@
 #! /bin/sh
 
 DATE=\`date\`
-echo "Hello Hell today is \$DATE " &>$LTPTMP/tst1_cron.out
+echo "Hello Hell today is \$DATE " > $LTPTMP/tst1_cron.out 2>&1
 exit 0
 EOF
 
@@ -99,7 +99,7 @@
 # activity.
 
 $LTPBIN/tst_resm TINFO "Test #1: Installing cron job ... " 
-crontab $LTPTMP/tst1_cronjob.cron &>$LTPTMP/cron_tst2n1.out
+crontab $LTPTMP/tst1_cronjob.cron >$LTPTMP/cron_tst2n1.out 2>&1
 RC=$?
 
 if [ $RC -ne 0 ]
@@ -114,7 +114,7 @@
 sleep 10s
 
 tail -n 10 /var/log/messages | grep crontab | grep REPLACE \
-	&>$LTPTMP/cron_tst2n1.out
+	> $LTPTMP/cron_tst2n1.out 2>&1
 RC=$?
 #####
 # Some implementations log cron info to /var/log/cron instead...
@@ -122,7 +122,7 @@
 if [ "$RC" -ne 0 -a -f /var/log/cron ]; then
 	$LTPBIN/tst_resm TINFO "Test #1: /var/log/cron: Trying altenate log..."
 	tail -n 10 /var/log/cron | grep crontab | grep REPLACE \
-	    &>$LTPTMP/cron_tst2n1.out
+	    > $LTPTMP/cron_tst2n1.out 2>&1
 	RC=$?
 fi
 if [ $RC -ne 0 ]
@@ -182,26 +182,26 @@
 	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 Received $TS_MIN1" \
+		FAILCNT=$(( $FAILCNT+1 ))
+		echo "\n\t\tExpected $TS_MIN2 \n\t\tReceived $TS_MIN1" \
 			> $LTPTMP/tst1_cron.log
 		$LTPBIN/tst_res TFAIL $LTPTMP/tst1_cron.log \
 			"Test #1: Failed to update every minute. Reason:"
-		crontab -r &>/dev/null
+		crontab -r >/dev/null 2>&1
 		break
 	else
-		echo "\n\t\t Expected $TS_MIN2 \n Received $TS_MIN1" \
+		echo "\n\t\tExpected $TS_MIN2 \n\t\tReceived $TS_MIN1" \
 			> $LTPTMP/tst1_cron.log
 		$LTPBIN/tst_res TINFO $LTPTMP/tst1_cron.log \
 			"Test #1: Values are good: "
 	fi
-		 LOOP_CNTR=$(( $LOOP_CNTR-1 ))
+	LOOP_CNTR=$(( $LOOP_CNTR-1 ))
 done
 
 if [ $FAILCNT -eq 0 ]
 then
 	# check if var/log/messages file was updated.
-	grep "CMD ($LTPTMP/tst1_cronprg.sh)" /var/log/messages &>$LTPTMP/cron_tst2n1.out
+	grep "CMD ($LTPTMP/tst1_cronprg.sh)" /var/log/messages >$LTPTMP/cron_tst2n1.out 2>&1
 	RC=$?
 #####
 # Some implementations log cron info to /var/log/cron instead...
@@ -209,7 +209,7 @@
 	if [ "$RC" -ne 0 -a -f /var/log/cron ]; then
 		$LTPBIN/tst_resm TINFO "Test #1: /var/log/cron: alternate..."
 		grep "CMD ($LTPTMP/tst1_cronprg.sh)" /var/log/cron \
-		    &>$LTPTMP/cron_tst2n1.out
+		    >$LTPTMP/cron_tst2n1.out 2>&1
 		RC=$?
 	fi
 	if [ $RC -eq 0 ]
@@ -228,7 +228,7 @@
 fi
 
 #remove the cron job that was installed.
-crontab -r &>/dev/null
+crontab -r >/dev/null 2>&1
 
 
 # Test #2
@@ -250,11 +250,11 @@
 exit 0
 EOF
 
-chmod +x  $LTPTMP/tst2_cronprg.sh &>/dev/null
+chmod +x  $LTPTMP/tst2_cronprg.sh >/dev/null 2>&1
 
 $LTPBIN/tst_resm TINFO "Test #2: installing crontab file."
 
-crontab $LTPTMP/tst2_cronjob.cron &>$LTPTMP/cron_tst2n1.out
+crontab $LTPTMP/tst2_cronjob.cron >$LTPTMP/cron_tst2n1.out 2>&1
 
 if [ $? -ne 0 ]
 then
@@ -266,7 +266,7 @@
 sleep 10s
 
 tail -n 10 /var/log/messages | grep crontab | grep REPLACE \
-    &>$LTPTMP/cron_tst2n1.out
+    >$LTPTMP/cron_tst2n1.out 2>&1
 RC=$?
 #####
 # Some implementations log cron info to /var/log/cron instead...
@@ -274,7 +274,7 @@
 if [ "$RC" -ne 0 -a -f /var/log/cron ]; then
 	$LTPBIN/tst_resm TINFO "Test #1: /var/log/cron: alternate..."
 	tail -n 10 /var/log/cron | grep crontab | grep REPLACE \
-	    &>$LTPTMP/cron_tst2n1.out
+	    >$LTPTMP/cron_tst2n1.out 2>&1
 	RC=$?
 fi
 if [ $RC -ne 0 ]
@@ -286,7 +286,7 @@
 
 $LTPBIN/tst_resm TINFO "Test #2: uninstalling crontab file."
 
-crontab -r  &>$LTPTMP/cron_tst2n1.out
+crontab -r  >$LTPTMP/cron_tst2n1.out 2>&1
 RC=$?
 
 if [ $RC -ne 0 ]
@@ -295,7 +295,7 @@
         "Test #2: crontab Broke while installing cronjob. Reason:"
     TFAILCNT=$(( $TFAILCNT+1 ))
 else
-	tail -n 10 /var/log/messages | grep DELETE &>$LTPTMP/cron_tst2n1.out
+	tail -n 10 /var/log/messages | grep DELETE >$LTPTMP/cron_tst2n1.out 2>&1
 	RC=$?
 #####
 # Some implementations log cron info to /var/log/cron instead...
@@ -303,7 +303,7 @@
 	if [ "$RC" -ne 0 -a -f /var/log/cron ]; then
 		$LTPBIN/tst_resm TINFO "Test #1: /var/log/cron: alternate..."
 		tail -n 10 /var/log/cron | grep DELETE \
-		    &>$LTPTMP/cron_tst2n1.out
+		    >$LTPTMP/cron_tst2n1.out 2>&1
 		RC=$?
 	fi
 	if [ $RC -ne 0 ]
@@ -336,10 +336,10 @@
 exit 0
 EOF
 
-chmod +x  $LTPTMP/tst2_cronprg.sh &>/dev/null
+chmod +x  $LTPTMP/tst2_cronprg.sh >/dev/null 2>&1
 
 $LTPBIN/tst_resm TINFO "Test #3: installing crontab file ..."
-crontab $LTPTMP/tst2_cronjob.cron &>$LTPTMP/cron_tst2n1.out
+crontab $LTPTMP/tst2_cronjob.cron >$LTPTMP/cron_tst2n1.out 2>&1
 if [ $? -ne 0 ]
 then
     $LTPBIN/tst_brkm TBROK NULL \
@@ -349,7 +349,7 @@
     $LTPBIN/tst_resm TINFO "Test #3: Cron job installed."
 fi
 
-crontab -l | grep "$LTPTMP/tst2_cronprg.sh" &>$LTPTMP/cron_tst2n1.out
+crontab -l | grep "$LTPTMP/tst2_cronprg.sh" >$LTPTMP/cron_tst2n1.out 2>&1
 RC=$?
 if [ $RC -ne 0 ]
 then	
@@ -362,7 +362,7 @@
 fi
 
 $LTPBIN/tst_resm TINFO "Test #3: uninstalling crontab file."
-crontab -r &>/dev/null
+crontab -r >/dev/null 2>&1
 
 if [ $? -ne 0 ]
 then	
@@ -370,10 +370,10 @@
 		 TFAILCNT=$(( $TFAILCNT+1 ))
 fi
 
-crontab -l &>$LTPTMP/cron_tst2.out
+crontab -l >$LTPTMP/cron_tst2.out 2>&1
 if [ $? -ne 0 ]
 then	
-	grep "no crontab for" $LTPTMP/cron_tst2.out &>$LTPTMP/cron_tst2n1.out
+	grep "no crontab for" $LTPTMP/cron_tst2.out >$LTPTMP/cron_tst2n1.out 2>&1
 	RC=$?
 	if [ $RC -ne 0 ]
 	then
-------------------------------------------------------------------------
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

Reply via email to