cron_tests.sh: fix a bug of syslog daemon is disabled
The case will check the /var/log/messages to see if there is a record of
any crontab activity, so make sure syslog daemon is enabld.
Signed-off-by: Peng Haitao <penght@cn.fujitsu.com>
Acked-by: Cyril Hrubis <chrubis@suse.cz>
Reviewed-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
diff --git a/testcases/commands/cron/cron_tests.sh b/testcases/commands/cron/cron_tests.sh
index b53a53a..3f70a23 100644
--- a/testcases/commands/cron/cron_tests.sh
+++ b/testcases/commands/cron/cron_tests.sh
@@ -57,6 +57,17 @@
LTPBIN=$LTPROOT/testcases/bin
fi
+. cmdlib.sh
+SYSLOG_STARTED=0
+
+if [ -n "$SYSLOG_DAEMON" ]; then
+ status_daemon $SYSLOG_DAEMON
+ if [ $? -ne 0 ]; then
+ restart_daemon $SYSLOG_DAEMON
+ SYSLOG_STARTED=1
+ fi
+fi
+
# Set return code RC variable to 0, it will be set with a non-zero return code
# in case of error. Set TFAILCNT to 0, increment if there occures a failure.
@@ -400,4 +411,8 @@
TFAILCNT=$(( $TFAILCNT+1 ))
fi
+if [ $SYSLOG_STARTED -eq 1 ]; then
+ stop_daemon $SYSLOG_DAEMON
+fi
+
exit $TFAILCNT
diff --git a/testcases/lib/cmdlib.sh b/testcases/lib/cmdlib.sh
index b7eee1a..7819cb7 100644
--- a/testcases/lib/cmdlib.sh
+++ b/testcases/lib/cmdlib.sh
@@ -158,6 +158,16 @@
HAVE_SYSTEMCTL=0
fi
+# Check to see if syslogd, syslog-ng or rsyslogd exists
+SYSLOG_DAEMON=""
+if command -v syslogd >/dev/null 2>&1; then
+ SYSLOG_DAEMON="syslog"
+elif command -v syslog-ng >/dev/null 2>&1; then
+ SYSLOG_DAEMON="syslog-ng"
+elif command -v rsyslogd >/dev/null 2>&1; then
+ SYSLOG_DAEMON="rsyslog"
+fi
+
start_daemon()
{
if [ $HAVE_SYSTEMCTL -eq 1 ]; then