• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#! /bin/sh
2
3#  Copyright (c) International Business Machines  Corp., 2002
4#
5#  This program is free software;  you can redistribute it and/or modify
6#  it under the terms of the GNU General Public License as published by
7#  the Free Software Foundation; either version 2 of the License, or
8#  (at your option) any later version.
9#
10#  This program is distributed in the hope that it will be useful,
11#  but WITHOUT ANY WARRANTY;  without even the implied warranty of
12#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
13#  the GNU General Public License for more details.
14#
15#  You should have received a copy of the GNU General Public License
16#  along with this program;  if not, write to the Free Software
17#  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
19# 12/05/02  Port to bash -Robbie Williamson <robbiew@us.ibm.com>
20# 02/05/03  Modified - Manoj Iyer <manjo@mail.utexas.edu> use USCTEST macros
21#           fixed bugs.
22# 07/27/05  Michael Reed  <mreedltp@vnet.ibm.com>
23#            Made changes to account for the replacement of syslogd
24#            with syslog-ng
25#
26##################################################################
27# case4: Test the logging option: LOG_PID                        #
28#                                                                #
29#        Do openlog() with LOG_PID option and see whether pid    #
30#        is logged with message.                                 #
31##################################################################
32
33. syslog-lib.sh || exit 1
34
35syslog_case4()
36{
37	tst_resm TINFO "Testing the log option: LOG_PID..."
38
39	# Create the configuration file specific to this test case.
40	case "$CONFIG_FILE" in
41	/etc/syslog.conf|/etc/rsyslog.conf)
42		echo "$RSYSLOG_CONFIG" > $CONFIG_FILE
43		echo "user.info        /var/log/messages" >> $CONFIG_FILE
44		;;
45
46	/etc/syslog-ng/syslog-ng.conf)
47		echo "source src{ internal(); unix-dgram(\"/dev/log\"); udp(ip(\"0.0.0.0\") port(514)); };" > $CONFIG_FILE
48		echo " " >> $CONFIG_FILE
49		echo "filter f_syslog_user { level(info) and facility(user); };" >> $CONFIG_FILE
50		echo "destination syslog_messages { file(\"/var/log/messages\");};" >> $CONFIG_FILE
51		echo "log { source(src); filter(f_syslog_user); destination(syslog_messages);};"  >> $CONFIG_FILE
52		;;
53	esac
54
55	restart_syslog_daemon
56
57	# Run syslogtst in the background and get the process id.
58	syslogtst 4 2>/dev/null &
59	log_pid=$!
60	if ! wait $log_pid; then
61		cleanup 1
62	fi
63
64	sleep 2
65
66	# check if /var/log/messages script exists
67	if [ ! -e /var/log/messages ]; then
68		tst_resm TBROK "/var/log/messages no such log file"
69		cleanup 1
70	fi
71
72	found=`grep -c "\[$log_pid\]: syslogtst: user info test." /var/log/messages`
73	if [ $found -ne 1 ]; then
74		status_flag=1
75	fi
76}
77
78tst_resm TINFO "case4: Test the logging option: LOG_PID"
79tst_resm TINFO "Do openlog() with LOG_PID option and see whether pid"
80tst_resm TINFO "is logged with message."
81
82setup
83syslog_case4
84cleanup ${status_flag:=0}
85