|
From: Bob T. <bt...@us...> - 2003-11-29 07:15:21
|
Update of /cvsroot/benson/benson3/src/tests
In directory sc8-pr-cvs1:/tmp/cvs-serv28898
Modified Files:
Makefile.in btraptest.at btraptest.c stacktest.c
Log Message:
Updating the test suite software
Index: Makefile.in
===================================================================
RCS file: /cvsroot/benson/benson3/src/tests/Makefile.in,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -r1.11 -r1.12
*** Makefile.in 8 Nov 2003 20:43:20 -0000 1.11
--- Makefile.in 29 Nov 2003 07:15:13 -0000 1.12
***************
*** 1,2 ****
--- 1,3 ----
+ prefix=@prefix@
sysconfdir=@sysconfdir@
srcdir=@srcdir@
***************
*** 7,35 ****
CFLAGS=-I$(top_srcdir) -I$(top_srcdir)/src -I$(top_srcdir)/include @CFLAGS@ @PERL_CFLAGS@
CPPFLAGS=@CPPFLAGS@ @DEFS@
! LIBS=@LIBS@
AR=@arpath@
RANLIB=@RANLIB@
INSTALL=@INSTALL@
! LDFLAGS=-L. @LDFLAGS@
PERL_LDFLAGS=@PERL_LDFLAGS@
! TESTSUITE=./testsuite
! AUTOTEST=./autom4te --language=autotest
! TEST_TARGETS=stacktest
.c.o:
$(CC) $(CFLAGS) $(CPPFLAGS) -c $<
! all: $(TEST_TARGETS)
! stacktest: stacktest.o
! $(CC) $(CFLAGS) $(CPPFLAGS) -static -o stacktest stacktest.o -L$(top_srcdir)/src -lbenson
! #-Wl,--rpath -Wl,$(top_srcdir)/src
! check: atconfig $(TESTSUITE)
$(SHELL) $(TESTSUITE)
clean:
test -z stacktest || rm -f stacktest
rm -f *.o *.a core
--- 8,48 ----
CFLAGS=-I$(top_srcdir) -I$(top_srcdir)/src -I$(top_srcdir)/include @CFLAGS@ @PERL_CFLAGS@
CPPFLAGS=@CPPFLAGS@ @DEFS@
! LIBS=-lbenson -lnetclient
AR=@arpath@
RANLIB=@RANLIB@
INSTALL=@INSTALL@
! LD_SEARCH_FLAG=@LD_SEARCH_FLAG@
! LDFLAGS=-L$(top_srcdir)/src -L$(top_srcdir)/src/network -Wl,$(LD_SEARCH_FLAG) -Wl,$(prefix)/lib
PERL_LDFLAGS=@PERL_LDFLAGS@
! TESTSUITE=testsuite
! AUTOTEST=autom4te --language=autotest
! TESTS_OBJECTS=stacktest.o btraptest.o
! TARGETS=stacktest btraptest
!
!
! all: $(TESTS_OBJECTS) $(TARGETS) testsuite
.c.o:
$(CC) $(CFLAGS) $(CPPFLAGS) -c $<
! testsuite: testsuite.at
! $(AUTOTEST) testsuite.at > testsuite
!
! $(TEST_OBJECTS): ../../config.h
!
! stacktest: ../libbenson.so stacktest.o
! $(CC) -o stacktest stacktest.o $(LDFLAGS) $(LIBS)
! btraptest: ../libbenson.so btraptest.o
! $(CC) -o btraptest btraptest.o $(LDFLAGS) $(LIBS)
! check: atconfig $(prefix)/lib/libbenson.so $(prefix)/lib/libnetclient.so testsuite
$(SHELL) $(TESTSUITE)
clean:
+ test -z btraptest || rm -f btraptest
test -z stacktest || rm -f stacktest
+ test -z testsuite || rm -f testsuite
rm -f *.o *.a core
Index: btraptest.at
===================================================================
RCS file: /cvsroot/benson/benson3/src/tests/btraptest.at,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** btraptest.at 28 Nov 2003 05:24:01 -0000 1.1
--- btraptest.at 29 Nov 2003 07:15:13 -0000 1.2
***************
*** 3,17 ****
AT_BANNER([Benson Trap Unit Testing])
! AT_SETUP([stack creation])
! AT_CHECK([stacktest -c], [0], [2/2], [ignore])
AT_CLEANUP
! AT_SETUP([stack destruction])
! AT_CHECK([stacktest -d], [0], [5/5], [ignore])
AT_CLEANUP
! AT_SETUP([stack overflow])
! AT_CHECK([stacktest -o], [0], [6/6], [ignore])
! AT_CLEANUP
! AT_SETUP([stack underflow])
! AT_CHECK([stacktest -u], [0], [9/9], [ignore])
AT_CLEANUP
--- 3,14 ----
AT_BANNER([Benson Trap Unit Testing])
! AT_SETUP([Test sending benson trap])
! AT_CHECK([btraptest -i], [0], [1/1], [ignore])
AT_CLEANUP
! AT_SETUP([Test benson trap failure])
! AT_CHECK([btraptest -f], [0], [1/1], [ignore])
AT_CLEANUP
! AT_SETUP([Test sending benson traps of various severity])
! AT_CHECK([btraptest -s], [0], [5/5], [ignore])
AT_CLEANUP
Index: btraptest.c
===================================================================
RCS file: /cvsroot/benson/benson3/src/tests/btraptest.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** btraptest.c 26 Feb 2003 18:25:07 -0000 1.4
--- btraptest.c 29 Nov 2003 07:15:13 -0000 1.5
***************
*** 1,86 ****
#include <benson/benson.h>
! int main(void) {
short rc = 0;
int pid = 0;
- int sts3 = 0;
char message[128];
! mtrace();
pid = getpid();
-
- printf("1) Initial Send Trap Test (test success)\n");
- snprintf(message, 126, "%s %i", "STS Test 1\0", pid);
- printf(" Executing bn_send_trap(\"localhost\", 9021, \"localhost\",\"warning\",\"btraptest\",\"%s\")\n", message);
- rc = 0;
- rc = bn_send_trap("localhost", 9021, "localhost", "warning", "testing", message);
-
- printf(" rc = %i\n", rc);
- if(rc == 0) {
- printf("STS 1: PASS\n\n");
- } else {
- printf("STS 1: FAIL\n\n");
- printf("This needs to be fixed first, make sure benson is running.\n");
- // exit(EXIT_FAILURE);
- }
-
- printf("2) Initial Send Trap Test (test failure)\n");
snprintf(message, 128, "%s %i", "STS Test 2", pid);
! printf(" Executing bn_send_trap(\"localhost\", 9020, \"localhost\",\"warning\",\"btraptest\",\"%s\")\n", message);
! rc = 0;
! rc = bn_send_trap("localhost", 9020, "localhost", "warning", "testing", message);
!
! printf(" rc = %i\n", rc);
! if(rc != 0) {
! printf("STS 2: PASS\n\n");
! } else {
! printf("STS 2: FAIL\n\n");
! }
!
!
! printf("3) Send Trap Severity Test\n");
! snprintf(message, 128, "%s %i", "STS Test 3", pid);
!
! printf(" Executing bn_send_trap(\"localhost\", 9021, \"localhost\",\"informational\",\"btraptest\",\"%s\")\n", message);
! rc = 0;
! rc = bn_send_trap("localhost", 9021, "localhost", "informational", "btraptest", message);
! if(rc == 0) {
! sts3++;
! }
!
! printf(" Executing bn_send_trap(\"localhost\", 9021, \"localhost\",\"warning\",\"btraptest\",\"%s\")\n", message);
! rc = 0;
! rc = bn_send_trap("localhost", 9021, "localhost", "warning", "btraptest", message);
! if(rc == 0) {
! sts3++;
! }
!
! printf(" Executing bn_send_trap(\"localhost\", 9021, \"localhost\",\"serious\",\"btraptest\",\"%s\")\n", message);
! rc = 0;
! rc = bn_send_trap("localhost", 9021, "localhost", "serious", "btraptest", message);
! if(rc == 0) {
! sts3++;
}
! printf(" Executing bn_send_trap(\"localhost\", 9021, \"localhost\",\"fatal\",\"btraptest\",\"%s\")\n", message);
! rc = 0;
! rc = bn_send_trap("localhost", 9021, "localhost", "fatal", "btraptest", message);
! if(rc == 0) {
! sts3++;
! }
!
! printf(" Executing bn_send_trap(\"localhost\", 9021, \"localhost\",\"emergency\",\"btraptest\",\"%s\")\n", message);
! rc = 0;
! rc = bn_send_trap("localhost", 9021, "localhost", "emergency", "btraptest", message);
! if(rc == 0) {
! sts3++;
! }
!
! if(sts3 == 5) {
! printf("STS 3 (5/5): PASS\n\n");
! } else {
! printf("STS 3 (%i/5): FAIL\n\n", sts3);
! }
}
--- 1,93 ----
+ #include <stdio.h>
+ #include <stdlib.h>
#include <benson/benson.h>
+ #include "network/network.h"
! typedef struct test_context {
! int last_test;
! int rc[20];
! } test_ctx;
!
! void test_succeed(test_ctx *tests)
! {
! tests->rc[tests->last_test++] = 1;
! }
!
! int test_status(test_ctx *tests)
! {
! int ctr;
! int success = 0;
! int total_tests = tests->last_test;
! for(ctr=0;ctr<=total_tests;ctr++) {
! if(tests->rc[ctr] == 1) {
! success++;
! }
! }
!
! printf("%i/%i", success, total_tests);
!
! if(total_tests == success) {
! return 0;
! }
! return 1;
! }
!
! int main(int argc, char *argv[]) {
! test_ctx tests;
! int c = 0;
short rc = 0;
int pid = 0;
char message[128];
! tests.last_test = 0;
pid = getpid();
snprintf(message, 128, "%s %i", "STS Test 2", pid);
! while((c = getopt(argc, argv, "ifs")) != -1) {
! switch(c)
! {
! case 'i':
! rc = 0;
! if((rc = bn_send_trap("localhost", 9021, "localhost", "warning", "testing", message)) == 0) {
! test_succeed(&tests);
! }
! exit(test_status(&tests));
! break;
! case 'f':
! rc = 0;
! if((rc = bn_send_trap("localhost", 9020, "localhost", "warning", "testing", message)) != 0) {
! test_succeed(&tests);
! }
! exit(test_status(&tests));
! break;
! case 's':
! rc = 0;
! if((rc = bn_send_trap("localhost", 9021, "localhost", "informational", "btraptest", message)) == 0) {
! test_succeed(&tests);
! }
! rc = 0;
! if((rc = bn_send_trap("localhost", 9021, "localhost", "warning", "btraptest", message)) == 0) {
! test_succeed(&tests);
! }
! rc = 0;
! if((rc = bn_send_trap("localhost", 9021, "localhost", "serious", "btraptest", message)) == 0) {
! test_succeed(&tests);
! }
! rc = 0;
! if((rc = bn_send_trap("localhost", 9021, "localhost", "fatal", "btraptest", message)) == 0) {
! test_succeed(&tests);
! }
! rc = 0;
! if((rc = bn_send_trap("localhost", 9021, "localhost", "emergency", "btraptest", message)) == 0) {
! test_succeed(&tests);
! }
! exit(test_status(&tests));
! break;
! default:
! printf("usage statement\n");
! }
}
! return 0;
}
Index: stacktest.c
===================================================================
RCS file: /cvsroot/benson/benson3/src/tests/stacktest.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** stacktest.c 28 Nov 2003 23:18:36 -0000 1.1
--- stacktest.c 29 Nov 2003 07:15:13 -0000 1.2
***************
*** 1,3 ****
--- 1,5 ----
#include <stdio.h>
+ #include <stdlib.h>
+ #include <getopt.h>
#include "stack.h"
***************
*** 7,16 ****
} test_ctx;
! test_succeed(test_ctx *tests)
{
tests->rc[tests->last_test++] = 1;
}
! test_status(test_ctx *tests)
{
int ctr;
--- 9,18 ----
} test_ctx;
! void test_succeed(test_ctx *tests)
{
tests->rc[tests->last_test++] = 1;
}
! int test_status(test_ctx *tests)
{
int ctr;
***************
*** 36,40 ****
test_ctx tests;
int rc = 0;
- int ctr = 0;
int c = 0;
--- 38,41 ----
|