Skip to contentSkip to conversation

commands/logrotate_tests.sh: Fix two issues

PATCH New Xiao Yang 2 participants 2 messages Nov 22, 2018 – Nov 28, 2018

lore
Share & tools
lore

Xiao Yang

author
#0 lore raw

PATCH 1/1 commands/logrotate_tests.sh: Fix two issues

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.

---
 testcases/commands/logrotate/logrotate_tests.sh | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
testcases/commands/logrotate/logrotate_tests.sh +6 -2
index ce12c7f..c9ffc41 100755
@@ -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.
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH 1/1 commands/logrotate_tests.sh: Fix two issues

Hi Xiao,

Quoted 13 lines

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.

Quoted 4 lines
---
 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