Logsys testing system.

git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1431 fd59a12c-fef9-0310-b244-a6a79926bd2f
This commit is contained in:
Steven Dake 2007-09-09 06:43:20 +00:00
parent 3cbecd98c1
commit 5ef02ff3ba
6 changed files with 277 additions and 3 deletions

View File

@ -1,5 +1,5 @@
# Copyright (c) 2002-2004 MontaVista Software, Inc.
# Copyright (c) 2006 Red Hat, Inc.
# Copyright (c) 2006-2007 Red Hat, Inc.
# Copyright (c) 2006 Sun Microsystems, Inc.
#
# All rights reserved.
@ -50,13 +50,15 @@ TEST_SRC = testclm.c testamf1.c \
testckpt.c ckptstress.c ckptbench.c \
ckptbenchth.c testevt.c testevs.c evsbench.c \
subscription.c publish.c evtbench.c \
sa_error.c unlink.c testclm2.c testlck.c testmsg.c
sa_error.c unlink.c testclm2.c testlck.c testmsg.c \
logsys_s1.c logsys_s2.c logsys_s.c logsys_t1.c logsys_t2.c
all: testclm testamf1 \
testckpt ckptstress ckptbench \
ckptbenchth ckpt-rd ckpt-wr testevt testevs \
evsbench subscription publish evtbench unlink testclm2 testlck \
testmsg testcpg testcpg2 cpgbench openais-cfgtool
testmsg testcpg testcpg2 cpgbench openais-cfgtool \
logsys_s logsys_t1 logsys_t2
testtimer: testtimer.o $(LIBRARIES)
$(CC) $(LDFLAGS) -o testtimer testtimer.o ../exec/timer.o
@ -154,6 +156,15 @@ cpgbench: cpgbench.o $(LIBRARIES)
openais-cfgtool: openais-cfgtool.o $(LIBRARIES)
$(CC) $(LDFLAGS) -o openais-cfgtool openais-cfgtool.o $(LIBS)
logsys_s: logsys_s.o logsys_s1.o logsys_s2.o ../exec/liblogsys.a
$(CC) $(LDFLAGS) -o logsys_s logsys_s.o logsys_s1.o logsys_s2.o ../exec/liblogsys.a
logsys_t1: logsys_t1.o ../exec/liblogsys.a
$(CC) $(LDFLAGS) -o logsys_t1 logsys_t1.o ../exec/liblogsys.a
logsys_t2: logsys_t2.o ../exec/liblogsys.a
$(CC) $(LDFLAGS) -o logsys_t2 logsys_t2.o ../exec/liblogsys.a
clean:
rm -f *.o testclm testamf testamf1 testamf2 testamf3 testamf4 \
testamf5 testamf6 testamfth testckpt ckptstress testtimer \

50
test/logsys_s.c Normal file
View File

@ -0,0 +1,50 @@
/*
* Copyright (c) 2007 Red Hat, Inc.
*
* All rights reserved.
*
* Author: Steven Dake (sdake@mvista.com)
*
* This software licensed under BSD license, the text of which follows:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* - Neither the name of the MontaVista Software, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdio.h>
#include <syslog.h>
#include "../exec/logsys.h"
LOGSYS_DECLARE_SYSTEM ("logsystestsubsystems",
LOG_MODE_OUTPUT_STDERR | LOG_MODE_OUTPUT_SYSLOG_THREADED,
NULL,
LOG_DAEMON);
extern void logsys_s1_print (void);
extern void logsys_s2_print (void);
int main (void) {
logsys_s1_print();
logsys_s2_print();
return (0);
}

43
test/logsys_s1.c Normal file
View File

@ -0,0 +1,43 @@
/*
* Copyright (c) 2007 Red Hat, Inc.
*
* All rights reserved.
*
* Author: Steven Dake (sdake@mvista.com)
*
* This software licensed under BSD license, the text of which follows:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* - Neither the name of the MontaVista Software, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdio.h>
#include <syslog.h>
#include "../exec/logsys.h"
LOGSYS_DECLARE_SUBSYS ("SYS1", LOG_ALERT)
void logsys_s1_print (void) {
log_printf (LOG_ALERT, "This is an alert log message\n");
log_printf (LOG_WARNING, "This is a warning log message\n");
}

44
test/logsys_s2.c Normal file
View File

@ -0,0 +1,44 @@
/*
* Copyright (c) 2007 Red Hat, Inc.
*
* All rights reserved.
*
* Author: Steven Dake (sdake@mvista.com)
*
* This software licensed under BSD license, the text of which follows:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* - Neither the name of the MontaVista Software, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdio.h>
#include <syslog.h>
#include "../exec/logsys.h"
LOGSYS_DECLARE_SUBSYS ("SYS2", LOG_DEBUG)
void logsys_s2_print (void) {
log_printf (LOG_ALERT, "This is an alert log message\n");
log_printf (LOG_WARNING, "This is a warning log message\n");
log_printf (LOG_DEBUG, "This is a debug log message\n");
}

50
test/logsys_t1.c Normal file
View File

@ -0,0 +1,50 @@
/*
* Copyright (c) 2007 Red Hat, Inc.
*
* All rights reserved.
*
* Author: Steven Dake (sdake@mvista.com)
*
* This software licensed under BSD license, the text of which follows:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* - Neither the name of the MontaVista Software, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdio.h>
#include <syslog.h>
#include "../exec/logsys.h"
LOGSYS_DECLARE_SYSTEM ("logsystestNOsubsystems",
LOG_MODE_OUTPUT_STDERR | LOG_MODE_OUTPUT_SYSLOG_THREADED | LOG_MODE_DISPLAY_DEBUG,
NULL,
LOG_DAEMON);
LOGSYS_DECLARE_NOSUBSYS(LOG_LEVEL_DEBUG);
int main (void) {
log_printf (LOG_ALERT, "This is an alert log message\n");
log_printf (LOG_WARNING, "This is a warning log message\n");
log_printf (LOG_DEBUG, "This is a debug log message\n");
return (0);
}

76
test/logsys_t2.c Normal file
View File

@ -0,0 +1,76 @@
/*
* Copyright (c) 2007 Red Hat, Inc.
*
* All rights reserved.
*
* Author: Lon Hohberger (lhh@redhat.com)
*
* This software licensed under BSD license, the text of which follows:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* - Neither the name of the MontaVista Software, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdio.h>
#include <stdint.h>
#include "../exec/logsys.h"
LOGSYS_DECLARE_SYSTEM ("logtest_t2",
LOG_MODE_OUTPUT_STDERR | LOG_MODE_OUTPUT_SYSLOG_THREADED | LOG_MODE_DISPLAY_DEBUG | LOG_MODE_BUFFER_BEFORE_CONFIG,
NULL,
LOG_DAEMON);
LOGSYS_DECLARE_NOSUBSYS(LOG_LEVEL_INFO);
int
main(int argc, char **argv)
{
/*
* fork could occur here and the file to output to could be set
*/
logsys_config_mode_set (LOG_MODE_OUTPUT_STDERR | LOG_MODE_OUTPUT_SYSLOG_THREADED | LOG_MODE_DISPLAY_DEBUG | LOG_MODE_FLUSH_AFTER_CONFIG);
log_printf(LOG_NOTICE, "Hello, world!\n");
log_printf(LOG_DEBUG, "If you see this, the logger's busted\n");
logsys_config_priority_set (LOG_ALERT);
log_printf(LOG_DEBUG, "If you see this, the logger's busted\n");
log_printf(LOG_CRIT, "If you see this, the logger's busted\n");
log_printf(LOG_ALERT, "Alert 1\n");
logsys_config_priority_set (LOG_NOTICE);
log_printf(LOG_CRIT, "Crit 1\n");
log_printf(LOG_INFO, "If you see this, the logger's busted\n");
logsys_config_priority_set (LOG_DEBUG);
log_printf(LOG_DEBUG, "Debug 1\n");
logsys_config_mode_set (LOG_MODE_DISPLAY_DEBUG | LOG_MODE_OUTPUT_STDERR);
log_printf(LOG_DEBUG, "Debug 2\n");
return 0;
}