public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH] commands/logrotate_tests.sh: Fix two issues
@ 2018-11-22 11:39 Xiao Yang
  2018-11-28  7:00 ` Petr Vorel
  0 siblings, 1 reply; 2+ messages in thread
From: Xiao Yang @ 2018-11-22 11:39 UTC (permalink / raw)
  To: ltp

1) Pass correct arguments when calling tst_res command in logrotate_tests.sh
2) If syslog group doesn't exist on system, su option with it triggers a
   an 'unknow group' error in config file and then skips the config file.
   e.g.  Running logrotate_sh gets either of the following errors, because
   logrotate command with above error returns non-zero exit status since
   commit e547b94 in logrotate:
   ---------------------------------------------------------
   logrotate01    1  TFAIL  :  ltpapicmd.c:154: Test #1: logrotate command failed. Reason:
   ...
   logrotate01    1  TFAIL  :  ltpapicmd.c:154: Test #1: logrotate command exited with 1 return code. Output:
   ---------------------------------------------------------
   We just use syslog group if it actually exists.

Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
---
 testcases/commands/logrotate/logrotate_tests.sh | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/testcases/commands/logrotate/logrotate_tests.sh b/testcases/commands/logrotate/logrotate_tests.sh
index ce12c7f..c9ffc41 100755
--- a/testcases/commands/logrotate/logrotate_tests.sh
+++ b/testcases/commands/logrotate/logrotate_tests.sh
@@ -154,6 +154,10 @@ test01()
 	tst_resm TINFO "Test #1: 1. rotate /var/log/tst_logfile file."
 	tst_resm TINFO "Test #1: 2. compresses it."
 
+	# Check if syslog group exists
+	local set_group="root"
+	grep -q syslog /etc/group && set_group="syslog"
+
 	# create config file.
 	cat >$LTPTMP/tst_logrotate.conf <<-EOF
 	#****** Begin Config file *******
@@ -164,7 +168,7 @@ test01()
 	compress
 
 	/var/log/tst_logfile {
-		su root syslog
+		su root ${set_group}
 		rotate 5
 		weekly
 	}
@@ -208,7 +212,7 @@ test01()
 			$LTPTMP/tst_logrotate.out   > $LTPTMP/tst_logrotate.err 2>&1 || RC=$?
 		if [ $RC -ne 0 ]
 		then
-			tst_res TFAIL > $LTPTMP/tst_logrotate.err 2>&1 \
+			tst_res TFAIL $LTPTMP/tst_logrotate.err \
 				"Test #1: logrotate command failed. Reason:"
 		else
 			# Check if compressed log file is created.
-- 
1.8.3.1




^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [LTP] [PATCH] commands/logrotate_tests.sh: Fix two issues
  2018-11-22 11:39 [LTP] [PATCH] commands/logrotate_tests.sh: Fix two issues Xiao Yang
@ 2018-11-28  7:00 ` Petr Vorel
  0 siblings, 0 replies; 2+ messages in thread
From: Petr Vorel @ 2018-11-28  7:00 UTC (permalink / raw)
  To: ltp

Hi Xiao,

> 1) Pass correct arguments when calling tst_res command in logrotate_tests.sh
> 2) If syslog group doesn't exist on system, su option with it triggers a
>    an 'unknow group' error in config file and then skips the config file.
>    e.g.  Running logrotate_sh gets either of the following errors, because
>    logrotate command with above error returns non-zero exit status since
>    commit e547b94 in logrotate:
>    ---------------------------------------------------------
>    logrotate01    1  TFAIL  :  ltpapicmd.c:154: Test #1: logrotate command failed. Reason:
>    ...
>    logrotate01    1  TFAIL  :  ltpapicmd.c:154: Test #1: logrotate command exited with 1 return code. Output:
>    ---------------------------------------------------------
>    We just use syslog group if it actually exists.

> Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
> ---
>  testcases/commands/logrotate/logrotate_tests.sh | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)

thanks for your commit, pushed with some changes (I split commit into 2,
adjusted commit message, simplify variable name and reverse check logic to not
repeat group name).

Kind regards,
Petr

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-11-28  7:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-11-22 11:39 [LTP] [PATCH] commands/logrotate_tests.sh: Fix two issues Xiao Yang
2018-11-28  7:00 ` Petr Vorel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox