You are viewing a plain text version of this content. The canonical link for it is here.
Posted to apreq-cvs@httpd.apache.org by jo...@apache.org on 2003/04/17 21:19:41 UTC

cvs commit: httpd-apreq-2/t CuTest.c CuTest.h Makefile.am README tables.c test_apr.h testall.c

joes        2003/04/17 12:19:40

  Modified:    .        Makefile.am acinclude.m4 configure.ac
               env      Makefile.am libapreq_cgi.c mod_apreq.c
               src      Makefile.am apreq_parsers.c
  Added:       .        STATUS
               t        CuTest.c CuTest.h Makefile.am README tables.c
                        test_apr.h testall.c
  Log:
  Added apr's CuTest framework. Switched --with-apache2 flag to --with-apache2-apxs and fixed install locations.
  
  Revision  Changes    Path
  1.4       +3 -2      httpd-apreq-2/Makefile.am
  
  Index: Makefile.am
  ===================================================================
  RCS file: /home/cvs/httpd-apreq-2/Makefile.am,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Makefile.am	17 Apr 2003 03:34:55 -0000	1.3
  +++ Makefile.am	17 Apr 2003 19:19:39 -0000	1.4
  @@ -1,5 +1,6 @@
   AUTOMAKE_OPTIONS = foreign
  -SUBDIRS = src env
  +SUBDIRS = src env t
   EXTRA_DIST = README
   
  -test:	check
  +test: check
  +	t/testall
  \ No newline at end of file
  
  
  
  1.4       +8 -7      httpd-apreq-2/acinclude.m4
  
  Index: acinclude.m4
  ===================================================================
  RCS file: /home/cvs/httpd-apreq-2/acinclude.m4,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- acinclude.m4	17 Apr 2003 03:34:55 -0000	1.3
  +++ acinclude.m4	17 Apr 2003 19:19:39 -0000	1.4
  @@ -1,11 +1,12 @@
   AC_DEFUN(AC_APREQ, [
  -	AC_ARG_WITH(apache2,
  -		[  --with-apache2  the apache-2 server_root directory],
  -		[APACHE2=$withval],
  -		[APACHE2="/usr/local/apache2"])
  -	APACHE2_INCLUDES="$APACHE2/include"
  -        APACHE2_MODULES="$APACHE2/modules"
  -        APACHE2_LIBS="$APACHE2/lib"
  +	AC_ARG_WITH(apache2-apxs,
  +		[  --with-apache2-apxs  path to apache2's apxs],
  +		[APACHE2_APXS=$withval],
  +		[APACHE2_APXS="/usr/local/apache2/bin/apxs"])
  +	APACHE2_INCLUDES="`$APACHE2_APXS -q INCLUDEDIR`"
  +        APACHE2_MODULES="`$APACHE2_APXS -q LIBEXECDIR`"
  +        APACHE2_LIBS="`$APACHE2_APXS -q LIBDIR`"
  +        AC_SUBST(APACHE2_APXS)
   	AC_SUBST(APACHE2_INCLUDES)
           AC_SUBST(APACHE2_MODULES)
           AC_SUBST(APACHE2_LIBS)
  
  
  
  1.2       +0 -11     httpd-apreq-2/configure.ac
  
  Index: configure.ac
  ===================================================================
  RCS file: /home/cvs/httpd-apreq-2/configure.ac,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- configure.ac	17 Apr 2003 03:34:55 -0000	1.1
  +++ configure.ac	17 Apr 2003 19:19:39 -0000	1.2
  @@ -14,17 +14,6 @@
   AC_PROG_INSTALL
   AC_PROG_LN_S
   
  -dnl AC_ARG_ENABLE(maintainer-mode,[  --enable-maintainer-mode  Turn on debugging 
  -dnl and compile time warnings],
  -dnl   [APR_ADDTO(CFLAGS,-g)
  -dnl   if test "$GCC" = "yes"; then
  -dnl     APR_ADDTO(CFLAGS,[-Wall -Wmissing-prototypes -Wstrict-prototypes 
  -dnl                       -Wmissing-declarations])
  -dnl   elif test "$AIX_XLC" = "yes"; then
  -dnl     APR_ADDTO(CFLAGS,-qfullpath -qinitauto=FE -qwarn64 -qcheck=all)
  -dnl   fi
  -dnl ])dnl
  -
   AM_MAINTAINER_MODE
   
   dnl Checks for header files.
  
  
  
  1.1                  httpd-apreq-2/STATUS
  
  Index: STATUS
  ===================================================================
  APREQ 2.0 STATUS:                                              -*-text-*-
  Last modified at [$Date: 2003/04/17 19:19:39 $]
  
       2.0.0  in development
  
  Contributors looking for a mission:
  
      * just do an egrep on "TODO" or "XXX" and see what's there
  
  
  CURRENT RELEASE NOTES:
  
  
  RELEASE SHOWSTOPPERS:
  
  
  CURRENT VOTES:
  
  
  TODO:
  
    Write tests.
    Populate the glue/ directory (perl, tcl, etc.).
  
  
  OPEN ISSUES:
  
  
  BUGS:
  
  
  1.4       +11 -7     httpd-apreq-2/env/Makefile.am
  
  Index: Makefile.am
  ===================================================================
  RCS file: /home/cvs/httpd-apreq-2/env/Makefile.am,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Makefile.am	17 Apr 2003 03:34:56 -0000	1.3
  +++ Makefile.am	17 Apr 2003 19:19:39 -0000	1.4
  @@ -1,13 +1,17 @@
  -lib_LTLIBRARIES = mod_apreq.la libapreq_cgi.la
   INCLUDES = -I@APACHE2_INCLUDES@ -I../src
   
  +lib_LIBRARIES = libapreq_cgi.a
  +noinst_LTLIBRARIES = mod_apreq.la
  +
   mod_apreq_la_SOURCES = mod_apreq.c
  -mod_apreq_la_LDFLAGS = -rpath @APACHE2_LIBS@ -dynamic -module
  +mod_apreq_la_LDFLAGS = -export-dynamic -module -rpath @APACHE2_MODULES@
   mod_apreq_la_LIBADD = ../src/libapreq.la
  -mod_apreq_ls_CPPFLAGS = -DLIBDIR=@APACHE2_MODULES@
   
  +libapreq_cgi_a_SOURCES = libapreq_cgi.c
  +libapreq_cgi_a_LIBADD = ../src/libapreq.la
  +
  +libdir = @APACHE2_LIBS@
  +includedir = @APACHE2_INCLUDES@
   
  -libapreq_cgi_la_SOURCES = libapreq_cgi.c
  -libapreq_cgi_la_LDFLAGS = -rpath @APACHE2_LIBS@ -version-info 2:0
  -libapreq_cgi_la_LIBADD = ../src/libapreq.la
  -libapreq_cgi_la_CPPFLAGS = -DLIBDIR=@APACHE2_LIBS@
  +install-exec-local: mod_apreq.la
  +	@APACHE2_APXS@ -i -a -n apreq mod_apreq.la
  
  
  
  1.2       +0 -3      httpd-apreq-2/env/libapreq_cgi.c
  
  Index: libapreq_cgi.c
  ===================================================================
  RCS file: /home/cvs/httpd-apreq-2/env/libapreq_cgi.c,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- libapreq_cgi.c	17 Apr 2003 03:34:56 -0000	1.1
  +++ libapreq_cgi.c	17 Apr 2003 19:19:39 -0000	1.2
  @@ -58,9 +58,6 @@
   #include "apreq_parsers.h"
   #include "apreq_cookie.h"
   
  -#include "apr_lib.h"
  -#include "apr_strings.h"
  -
   #include <stdlib.h>
   #include <stdio.h>
   
  
  
  
  1.5       +7 -0      httpd-apreq-2/env/mod_apreq.c
  
  Index: mod_apreq.c
  ===================================================================
  RCS file: /home/cvs/httpd-apreq-2/env/mod_apreq.c,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- mod_apreq.c	17 Apr 2003 03:34:56 -0000	1.4
  +++ mod_apreq.c	17 Apr 2003 19:19:39 -0000	1.5
  @@ -162,6 +162,13 @@
       return 1;
   }
   
  +static apr_status_t env_read(void *ctx, apr_bucket_brigade **bb, 
  +                             apr_read_type_e block, apr_off_t readbytes)
  +{
  +    dR;
  +    /* XXX: prefetch */
  +    return APR_ENOTIMPL;
  +}
   
   static apr_status_t apreq_filter(ap_filter_t *f,
                                    apr_bucket_brigade *bb,
  
  
  
  1.7       +4 -2      httpd-apreq-2/src/Makefile.am
  
  Index: Makefile.am
  ===================================================================
  RCS file: /home/cvs/httpd-apreq-2/src/Makefile.am,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- Makefile.am	17 Apr 2003 03:34:56 -0000	1.6
  +++ Makefile.am	17 Apr 2003 19:19:39 -0000	1.7
  @@ -6,5 +6,7 @@
                        apreq_tables.h apreq_env.h apreq_parsers.h
   libapreq_la_SOURCES = apreq.c apreq_tables.c apreq_cookie.c \
                         apreq_params.c apreq_parsers.c
  -libapreq_la_LDFLAGS = -lapr-0 -laprutil-0 -version-info 2:0 -rpath @APACHE2_LIBS@
  -libapreq_la_CPPFLAGS = -DLIBDIR=@APACHE2_LIBS@ -DINCLUDEDIR=@APACHE2_INCLUDES@
  +libapreq_la_LDFLAGS = -lapr-0 -laprutil-0 -version-info 2:0 
  +
  +libdir=@APACHE2_LIBS@
  +includedir=@APACHE2_INCLUDES@
  \ No newline at end of file
  
  
  
  1.13      +5 -1      httpd-apreq-2/src/apreq_parsers.c
  
  Index: apreq_parsers.c
  ===================================================================
  RCS file: /home/cvs/httpd-apreq-2/src/apreq_parsers.c,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- apreq_parsers.c	17 Apr 2003 03:34:56 -0000	1.12
  +++ apreq_parsers.c	17 Apr 2003 19:19:39 -0000	1.13
  @@ -136,8 +136,12 @@
   
       if (req->v.status == APR_INCOMPLETE) {
           apreq_parser_t *p = *(apreq_parser_t **)req->v.data;
  +        apr_status_t s = apreq_env_read();
  +
  +        if (bb = NULL) {
  +            apreq_env_read(req->env, &bb);
  +        }
           req->v.status = p->parser(req->pool, bb, p);
  -        apreq_log(APREQ_DEBUG req->v.status, req->env, "parsing request.");
       }
   
       return req->v.status;
  
  
  
  1.1                  httpd-apreq-2/t/CuTest.c
  
  Index: CuTest.c
  ===================================================================
  /*
   * Copyright (c) 2002-2006 Asim Jalis
   * 
   * This library is released under the zlib/libpng license as described at
   * 
   * http://www.opensource.org/licenses/zlib-license.html
   * 
   * Here is the statement of the license:
   * 
   * This software is provided 'as-is', without any express or implied warranty. 
   * In no event will the authors be held liable for any damages arising from 
   * the use of this software.
   * 
   * Permission is granted to anyone to use this software for any purpose, 
   * including commercial applications, and to alter it and redistribute it 
   * freely, subject to the following restrictions:
   * 
   * 1. The origin of this software must not be misrepresented; you must not 
   * claim that you wrote the original software. If you use this software in a 
   * product, an acknowledgment in the product documentation would be 
   * appreciated but is not required.
   * 
   * 2. Altered source versions must be plainly marked as such, and must not be
   * misrepresented as being the original software.
   * 
   * 3. This notice may not be removed or altered from any source distribution.
   */
  /*
   * This file has been modified from the original distribution.
   */
  
  #include <assert.h>
  #include <setjmp.h>
  #include <stdlib.h>
  #include <stdio.h>
  #include <string.h>
  
  #include "CuTest.h"
  
  static int verbose = 0;
  
  void CuInit(int argc, char *argv[])
  {
  	int i;
  	
  	/* Windows doesn't have getopt, so we have to fake it.  We can't use
  	 * apr_getopt, because CuTest is meant to be a stand-alone test suite
  	 */
  	for (i = 0; i < argc; i++) {
  		if (!strcmp(argv[i], "-v")) {
  			verbose = 1;
  		}
  	}
  }
  
  /*-------------------------------------------------------------------------*
   * CuStr
   *-------------------------------------------------------------------------*/
  
  char* CuStrAlloc(int size)
  {
  	char* new = (char*) malloc( sizeof(char) * (size) );
  	return new;
  }
  
  char* CuStrCopy(const char* old)
  {
  	int len = strlen(old);
  	char* new = CuStrAlloc(len + 1);
  	strcpy(new, old);
  	return new;
  }
  
  /*-------------------------------------------------------------------------*
   * CuString
   *-------------------------------------------------------------------------*/
  
  void CuStringInit(CuString* str)
  {
  	str->length = 0;
  	str->size = STRING_MAX;
  	str->buffer = (char*) malloc(sizeof(char) * str->size);
  	str->buffer[0] = '\0';
  }
  
  CuString* CuStringNew(void)
  {
  	CuString* str = (CuString*) malloc(sizeof(CuString));
  	str->length = 0;
  	str->size = STRING_MAX;
  	str->buffer = (char*) malloc(sizeof(char) * str->size);
  	str->buffer[0] = '\0';
  	return str;
  }
  
  void CuStringResize(CuString* str, int newSize)
  {
  	str->buffer = (char*) realloc(str->buffer, sizeof(char) * newSize);
  	str->size = newSize;
  }
  
  void CuStringAppend(CuString* str, const char* text)
  {
  	int length = strlen(text);
  	if (str->length + length + 1 >= str->size)
  		CuStringResize(str, str->length + length + 1 + STRING_INC);
  	str->length += length;
  	strcat(str->buffer, text);
  }
  
  void CuStringAppendChar(CuString* str, char ch)
  {
  	char text[2];
  	text[0] = ch;
  	text[1] = '\0';
  	CuStringAppend(str, text);
  }
  
  void CuStringAppendFormat(CuString* str, const char* format, ...)
  {
  	va_list argp;
  	char buf[HUGE_STRING_LEN];
  	va_start(argp, format);
  	vsprintf(buf, format, argp);
  	va_end(argp);
  	CuStringAppend(str, buf);
  }
  
  void CuStringRead(CuString *str, char *path)
  {
  	path = strdup(str->buffer);
  }
  
  /*-------------------------------------------------------------------------*
   * CuTest
   *-------------------------------------------------------------------------*/
  
  void CuTestInit(CuTest* t, char* name, TestFunction function)
  {
  	t->name = CuStrCopy(name);
  	t->notimpl = 0;
  	t->failed = 0;
  	t->ran = 0;
  	t->message = NULL;
  	t->function = function;
  	t->jumpBuf = NULL;
  }
  
  CuTest* CuTestNew(char* name, TestFunction function)
  {
  	CuTest* tc = CU_ALLOC(CuTest);
  	CuTestInit(tc, name, function);
  	return tc;
  }
  
  void CuNotImpl(CuTest* tc, const char* message)
  {
  	CuString* newstr = CuStringNew();
          CuStringAppend(newstr, message);
          CuStringAppend(newstr, " not implemented on this platform");
  	tc->notimpl = 1;
  	tc->message = CuStrCopy(newstr->buffer);
  	if (tc->jumpBuf != 0) longjmp(*(tc->jumpBuf), 0);
  }
  
  void CuFail(CuTest* tc, const char* message)
  {
  	tc->failed = 1;
  	tc->message = CuStrCopy(message);
  	if (tc->jumpBuf != 0) longjmp(*(tc->jumpBuf), 0);
  }
  
  void CuAssert(CuTest* tc, const char* message, int condition)
  {
  	if (condition) return;
  	CuFail(tc, message);
  }
  
  void CuAssertTrue(CuTest* tc, int condition)
  {
  	if (condition) return;
  	CuFail(tc, "assert failed");
  }
  
  void CuAssertStrNEquals(CuTest* tc, const char* expected, const char* actual,
                          int n)
  {
  	CuString* message;
  	if (strncmp(expected, actual, n) == 0) return;
  	message = CuStringNew();
  	CuStringAppend(message, "expected\n---->\n");
  	CuStringAppend(message, expected);
  	CuStringAppend(message, "\n<----\nbut saw\n---->\n");
  	CuStringAppend(message, actual);
  	CuStringAppend(message, "\n<----");
  	CuFail(tc, message->buffer);
  }
  
  void CuAssertStrEquals(CuTest* tc, const char* expected, const char* actual)
  {
  	CuString* message;
  	if (strcmp(expected, actual) == 0) return;
  	message = CuStringNew();
  	CuStringAppend(message, "expected\n---->\n");
  	CuStringAppend(message, expected);
  	CuStringAppend(message, "\n<----\nbut saw\n---->\n");
  	CuStringAppend(message, actual);
  	CuStringAppend(message, "\n<----");
  	CuFail(tc, message->buffer);
  }
  
  void CuAssertIntEquals(CuTest* tc, int expected, int actual)
  {
  	char buf[STRING_MAX];
  	if (expected == actual) return;
  	sprintf(buf, "expected <%d> but was <%d>", expected, actual);
  	CuFail(tc, buf);
  }
  
  void CuAssertPtrEquals(CuTest* tc, const void* expected, const void* actual)
  {
  	char buf[STRING_MAX];
  	if (expected == actual) return;
  	sprintf(buf, "expected pointer <%p> but was <%p>", expected, actual);
  	CuFail(tc, buf);
  }
  
  void CuAssertPtrNotNull(CuTest* tc, const void* pointer)
  {
  	char buf[STRING_MAX];
  	if (pointer != NULL ) return;
  	sprintf(buf, "null pointer unexpected, but was <%p>", pointer);
  	CuFail(tc, buf);
  }
  
  void CuTestRun(CuTest* tc)
  {
  	jmp_buf buf;
  	tc->jumpBuf = &buf;
  	if (setjmp(buf) == 0)
  	{
  		tc->ran = 1;
  		(tc->function)(tc);
  	}
  	tc->jumpBuf = 0;
  }
  
  /*-------------------------------------------------------------------------*
   * CuSuite
   *-------------------------------------------------------------------------*/
  
  void CuSuiteInit(CuSuite* testSuite, char *name)
  {
  	testSuite->name = strdup(name);
  	testSuite->count = 0;
  	testSuite->failCount = 0;
  	testSuite->notimplCount = 0;
  }
  
  CuSuite* CuSuiteNew(char *name)
  {
  	CuSuite* testSuite = CU_ALLOC(CuSuite);
  	CuSuiteInit(testSuite, name);
  	return testSuite;
  }
  
  void CuSuiteAdd(CuSuite* testSuite, CuTest *testCase)
  {
  	assert(testSuite->count < MAX_TEST_CASES);
  	testSuite->list[testSuite->count] = testCase;
  	testSuite->count++;
  }
  
  void CuSuiteAddSuite(CuSuite* testSuite, CuSuite* testSuite2)
  {
  	int i;
  	for (i = 0 ; i < testSuite2->count ; ++i)
  	{
  		CuTest* testCase = testSuite2->list[i];
  		CuSuiteAdd(testSuite, testCase);
  	}
  }
  
  void CuSuiteRun(CuSuite* testSuite)
  {
  	int i;
  	for (i = 0 ; i < testSuite->count ; ++i)
  	{
  		CuTest* testCase = testSuite->list[i];
  		CuTestRun(testCase);
  		if (testCase->failed) { testSuite->failCount += 1; }
  		if (testCase->notimpl) { testSuite->notimplCount += 1; }
  	}
  }
  
  void CuSuiteSummary(CuSuite* testSuite, CuString* summary)
  {
  	int i;
  	for (i = 0 ; i < testSuite->count ; ++i)
  	{
  		CuTest* testCase = testSuite->list[i];
  		CuStringAppend(summary, testCase->failed ? "F" : 
                                 testCase->notimpl ? "N": ".");
  	}
  	CuStringAppend(summary, "\n");
  }
  
  void CuSuiteOverView(CuSuite* testSuite, CuString* details)
  {
  	CuStringAppendFormat(details, "%d %s run:  %d passed, %d failed, "
  			     "%d not implemented.\n",
  			     testSuite->count, 
  			     testSuite->count == 1 ? "test" : "tests",
     			     testSuite->count - testSuite->failCount - 
  				testSuite->notimplCount,
  			     testSuite->failCount, testSuite->notimplCount);
  }
  
  void CuSuiteDetails(CuSuite* testSuite, CuString* details)
  {
  	int i;
  	int failCount = 0;
  
  	if (testSuite->failCount != 0 && verbose)
  	{
  		CuStringAppendFormat(details, "\nFailed tests in %s:\n", testSuite->name);
  		for (i = 0 ; i < testSuite->count ; ++i)
  		{
  			CuTest* testCase = testSuite->list[i];
  			if (testCase->failed)
  			{
  				failCount++;
  				CuStringAppendFormat(details, "%d) %s: %s\n", 
  					failCount, testCase->name, testCase->message);
  			}
  		}
  	}
  	if (testSuite->notimplCount != 0 && verbose)
  	{
  		CuStringAppendFormat(details, "\nNot Implemented tests in %s:\n", testSuite->name);
  		for (i = 0 ; i < testSuite->count ; ++i)
  		{
  			CuTest* testCase = testSuite->list[i];
  			if (testCase->notimpl)
  			{
  			        failCount++;
  			        CuStringAppendFormat(details, "%d) %s: %s\n",
  			                failCount, testCase->name, testCase->message);
  			}
  		}
  	}
  }
  
  /*-------------------------------------------------------------------------*
   * CuSuiteList
   *-------------------------------------------------------------------------*/
  
  CuSuiteList* CuSuiteListNew(char *name)
  {
  	CuSuiteList* testSuite = CU_ALLOC(CuSuiteList);
  	testSuite->name = strdup(name);
  	testSuite->count = 0;
  	return testSuite;
  }
  
  void CuSuiteListAdd(CuSuiteList *suites, CuSuite *origsuite)
  {
  	assert(suites->count < MAX_TEST_CASES);
  	suites->list[suites->count] = origsuite;
  	suites->count++;
  }
  
  void CuSuiteListRun(CuSuiteList* testSuite)
  {
  	int i;
  	for (i = 0 ; i < testSuite->count ; ++i)
  	{
  		CuSuite* testCase = testSuite->list[i];
  		CuSuiteRun(testCase);
  	}
  }
  
  static const char *genspaces(int i)
  {
      char *str = malloc((i + 1) * sizeof(char));
      memset(str, ' ', i);
      str[i] = '\0';
      return str;
  }
  
  void CuSuiteListRunWithSummary(CuSuiteList* testSuite)
  {
  	int i;
  
  	printf("%s:\n", testSuite->name);
  	for (i = 0 ; i < testSuite->count ; ++i)
  	{
  		CuSuite* testCase = testSuite->list[i];
  		CuString *str = CuStringNew();
  
  	        printf("    %s:%s", testCase->name, 
                                    genspaces(21 - strlen(testCase->name)));
  		fflush(stdout);
  		CuSuiteRun(testCase);
  		CuSuiteSummary(testCase, str);
  		printf("    %s", str->buffer);
  
  	}
  	printf("\n");
  }
  
  void CuSuiteListSummary(CuSuiteList* testSuite, CuString* summary)
  {
  	int i;
  	CuStringAppendFormat(summary, "%s:\n", testSuite->name);
  	for (i = 0 ; i < testSuite->count ; ++i)
  	{
  		CuSuite* testCase = testSuite->list[i];
  		CuString *str = CuStringNew();
  		CuSuiteSummary(testCase, str);
  		CuStringAppend(summary, "    ");
  		CuStringAppend(summary, str->buffer);
  	}
  	CuStringAppend(summary, "\n");
  }
  
  int CuSuiteListDetails(CuSuiteList* testSuite, CuString* details)
  {
  	int i;
  	int failCount = 0;
  	int notImplCount = 0;
  	int count = 0;
  
  	for (i = 0 ; i < testSuite->count ; ++i)
  	{
  		failCount += testSuite->list[i]->failCount;
  		notImplCount += testSuite->list[i]->notimplCount;
                  count += testSuite->list[i]->count;
  	}
  	CuStringAppendFormat(details, "%d %s run:  %d passed, %d failed, "
  			     "%d not implemented.\n",
  			     count, 
  			     count == 1 ? "test" : "tests",
     			     count - failCount - notImplCount,
  			     failCount, notImplCount);
  
  	if (failCount != 0 && verbose)
  	{
  		for (i = 0 ; i < testSuite->count ; ++i)
  		{
  			CuString *str = CuStringNew();
  			CuSuite* testCase = testSuite->list[i];
  			if (testCase->failCount)
  			{
  				CuSuiteDetails(testCase, str);
  				CuStringAppend(details, str->buffer);
  			}
  		}
  	}
  	if (notImplCount != 0 && verbose)
  	{
  		for (i = 0 ; i < testSuite->count ; ++i)
  		{
  			CuString *str = CuStringNew();
  			CuSuite* testCase = testSuite->list[i];
  			if (testCase->notimplCount)
  			{
  				CuSuiteDetails(testCase, str);
  				CuStringAppend(details, str->buffer);
  			}
  		}
  	} 
  	return failCount;
  }
  
  
  
  
  1.1                  httpd-apreq-2/t/CuTest.h
  
  Index: CuTest.h
  ===================================================================
  /*
   * Copyright (c) 2002-2006 Asim Jalis
   *
   * This library is released under the zlib/libpng license as described at
   *
   * http://www.opensource.org/licenses/zlib-license.html
   *
   * Here is the statement of the license:
   *
   * This software is provided 'as-is', without any express or implied warranty.
   * In no event will the authors be held liable for any damages arising from
   * the use of this software.
   *
   * Permission is granted to anyone to use this software for any purpose,
   * including commercial applications, and to alter it and redistribute it
   * freely, subject to the following restrictions:
   *
   * 1. The origin of this software must not be misrepresented; you must not
   * claim that you wrote the original software. If you use this software in a
   * product, an acknowledgment in the product documentation would be
   * appreciated but is not required.
   *
   * 2. Altered source versions must be plainly marked as such, and must not be
   * misrepresented as being the original software.
   *
   * 3. This notice may not be removed or altered from any source distribution.
   */
  /*
   * This file has been modified from the original distribution.
   */
  
  #ifndef CU_TEST_H
  #define CU_TEST_H
  
  #include <setjmp.h>
  #include <stdarg.h>
  
  /* CuString */
  
  char* CuStrAlloc(int size);
  char* CuStrCopy(const char* old);
  
  #define CU_ALLOC(TYPE)		((TYPE*) malloc(sizeof(TYPE)))
  
  #define HUGE_STRING_LEN	8192
  #define STRING_MAX		256
  #define STRING_INC		256
  
  typedef struct
  {
  	int length;
  	int size;
  	char* buffer;
  } CuString;
  
  void CuStringInit(CuString* str);
  CuString* CuStringNew(void);
  void CuStringRead(CuString* str, char* path);
  void CuStringAppend(CuString* str, const char* text);
  void CuStringAppendChar(CuString* str, char ch);
  void CuStringAppendFormat(CuString* str, const char* format, ...);
  void CuStringResize(CuString* str, int newSize);
  
  /* CuTest */
  
  typedef struct CuTest CuTest;
  
  typedef void (*TestFunction)(CuTest *);
  
  struct CuTest
  {
  	char* name;
  	TestFunction function;
          int notimpl;
  	int failed;
  	int ran;
  	char* message;
  	jmp_buf *jumpBuf;
  };
  
  void CuInit(int argc, char *argv[]);
  void CuTestInit(CuTest* t, char* name, TestFunction function);
  CuTest* CuTestNew(char* name, TestFunction function);
  void CuFail(CuTest* tc, const char* message);
  void CuNotImpl(CuTest* tc, const char* message);
  void CuAssert(CuTest* tc, const char* message, int condition);
  void CuAssertTrue(CuTest* tc, int condition);
  void CuAssertStrEquals(CuTest* tc, const char* expected, const char* actual);
  void CuAssertStrNEquals(CuTest* tc, const char* expected, const char* actual,
                          int n);
  void CuAssertIntEquals(CuTest* tc, int expected, int actual);
  void CuAssertPtrEquals(CuTest* tc, const void* expected, const void* actual);
  void CuAssertPtrNotNull(CuTest* tc, const void* pointer);
  
  void CuTestRun(CuTest* tc);
  
  /* CuSuite */
  
  #define MAX_TEST_CASES	1024	
  
  #define SUITE_ADD_TEST(SUITE,TEST)	CuSuiteAdd(SUITE, CuTestNew(#TEST, TEST))
  
  typedef struct
  {
  	char *name;
  	int count;
  	CuTest* list[MAX_TEST_CASES]; 
  	int failCount;
  	int notimplCount;
  
  } CuSuite;
  
  
  void CuSuiteInit(CuSuite* testSuite, char* name);
  CuSuite* CuSuiteNew(char* name);
  void CuSuiteAdd(CuSuite* testSuite, CuTest *testCase);
  void CuSuiteAddSuite(CuSuite* testSuite, CuSuite* testSuite2);
  void CuSuiteRun(CuSuite* testSuite);
  void CuSuiteSummary(CuSuite* testSuite, CuString* summary);
  void CuSuiteOverView(CuSuite* testSuite, CuString* details);
  void CuSuiteDetails(CuSuite* testSuite, CuString* details);
  
  typedef struct
  {
  	char *name;
  	int count;
  	CuSuite* list[MAX_TEST_CASES]; 
  } CuSuiteList;
  
  
  CuSuiteList* CuSuiteListNew(char* name);
  void CuSuiteListAdd(CuSuiteList* testSuite, CuSuite *testCase);
  void CuSuiteListRun(CuSuiteList* testSuite);
  void CuSuiteListRunWithSummary(CuSuiteList* testSuite);
  void CuSuiteListSummary(CuSuiteList* testSuite, CuString* summary);
  /* Print details of test suite results; returns total number of
   * tests which failed. */
  int CuSuiteListDetails(CuSuiteList* testSuite, CuString* details);
  #endif /* CU_TEST_H */
  
  
  
  
  1.1                  httpd-apreq-2/t/Makefile.am
  
  Index: Makefile.am
  ===================================================================
  INCLUDES = -I@APACHE2_INCLUDES@ -I../src
  LIBS = -L@APACHE2_LIBS@
  
  noinst_LIBRARIES = libapreq_tests.a
  libapreq_tests_a_SOURCES = CuTest.c env.c tables.c
  libapreq_tests_a_LIBADD = ../src/libapreq.la
  
  check_PROGRAMS = testall
  testall_LDADD =  libapreq_tests.a
  testall_LDFLAGS = -lapr-0 -laprutil-0 -lgdbm -ldb -ldl -lcrypt -lexpat -lpthread
  
  test:	check
  	./testall
  
  
  1.1                  httpd-apreq-2/t/README
  
  Index: README
  ===================================================================
  Writing APR tests
  
  All APR tests should be executable in 2 ways, as an individual program, or
  as a part of the full test suite.  The full test suite is controlled with
  the testall program.  At the beginning of the testall.c file, there is an
  array of functions called tests.  The testall program loops through this 
  array calling each function.  Each function returns a CuSuite variable, which
  is then added to the SuiteList.  Once all Suites have been added, the SuiteList
  is executed, and the output is printed to the screen.  All functions in the
  array should follow the same basic format:
  
  The Full Suite
  --------------
  
  /* The driver function.  This must return a CuSuite variable, which will
   * then be used to actually run the tests.  Essentially, all Suites are a
   * collection of tests.  The driver will take each Suite, and put it in a
   * SuiteList, which is a collection of Suites.
   */
  CuSuite *testtime(void)
  {
      /* The actual suite, this must be created for each test program.  Please
       * give it a useful name, that will inform the user of the feature being
       * tested.
       */
      CuSuite *suite = CuSuiteNew("Test Time");
  
      /* Each function must be added to the suite.  Each function represents
       * a single test.  It is possible to test multiple features in a single
       * function, although no tests currently do that.
       */
      SUITE_ADD_TEST(suite, test_now);
      SUITE_ADD_TEST(suite, test_gmtstr);
      SUITE_ADD_TEST(suite, test_localstr);
      SUITE_ADD_TEST(suite, test_exp_get_gmt);
      SUITE_ADD_TEST(suite, test_exp_get_lt);
      SUITE_ADD_TEST(suite, test_imp_gmt);
      SUITE_ADD_TEST(suite, test_rfcstr);
      SUITE_ADD_TEST(suite, test_ctime);
      SUITE_ADD_TEST(suite, test_strftime);
      SUITE_ADD_TEST(suite, test_strftimesmall);
      SUITE_ADD_TEST(suite, test_exp_tz);
      SUITE_ADD_TEST(suite, test_strftimeoffset);
  
      /* You must return the suite so that the driver knows which suites to
       * run.
       */
      return suite;
  }
  
  Building the full driver
  ------------------------
  
  All you need to do to build the full driver is run:
  
      make testall
  
  To run it, run:
  
      ./testall
  
  Caveats
  -------
  
  Currently, some tests are known to fail in certain circumstances:
  
   * 'testpoll' opens 64 sockets concurrently; ensure that resource
  limits are high enough to allow this (using ulimit or limit); for
  instance, Solaris <=2.7 and HP-UX 11.00 both set the limit to <=64 by
  default
  
   * 'testipsub' will tickle the Solaris 8 getaddrinfo() IPv6
  bug, causing the test to hang.  Configure with --disable-ipv6 if using
  an unpatched Solaris 8 installation.
  
   * The 'testdso' tests will not work if configured with
  --disable-shared since the loadable modules cannot be built.
  
  Running individual tests
  ---------------------------------
  
  It is not possible to build individual tests, however it is possible to
  run individual tests.  When running the test suite, specify the name of the
  tests that you want to run on the command line.  For example:
  
  	./testall teststr testrand
  
  Will run the Strings and Random generator tests.
  
  Reading the test suite output
  -----------------------------
  
  Once you run the test suite, you will get output like:
  
  All APR Tests:
      Test Strings:       ....
      Test Time:  ............
  
  16 tests run:  16 passed, 0 failed, 0 not implemented.
  
  There are a couple of things to look at with this.  First, if you look at the
  first function in this document, you should notice that the string passed to
  the CuSuiteNew function is in the output.  That is why the string should
  explain the feature you are testing.
  
  Second, this test passed completely.  This is obvious in two ways.  First, and
  most obvious, the summary line tells you that 16 tests were run and 16 tests
  passed.  However, the results can also be found in the lines above.  Every
  '.' in the output represents a passed test.
  
  If a test fails, the output will look like:
  
  All APR Tests:
      Test Strings:       ....
      Test Time:  ..F.........
  
  16 tests run:  15 passed, 1 failed, 0 not implemented.
  
  This is not very useful, because you don't know which test failed.  However,
  once you know that a test failed, you can run the suite again, with the
  -v option.  If you do this, you will get something like:
  
  All APR Tests:
      Test Strings:       ....
      Test Time:  ..F.........
  
  16 tests run:  15 passed, 1 failed, 0 not implemented.
  Failed tests:
  1) test_localstr: assert failed
  
  In this case, we know the test_localstr function failed, and there is an
  Assert in this that failed (I modified the test to fail for this document).
  Now, you can look at what that test does, and why it would have failed.
  
  There is one other possible output for the test suite (run with -v):
  
  All APR Tests:
      Test Strings:       ....
      Test Time:  ..N.........
  
  16 tests run:  15 passed, 0 failed, 1 not implemented.
  
  Not Implemented tests:
  
  Not Implemented tests:
  1) test_localstr: apr_time_exp_lt not implemented on this platform
  
  The 'N' means that a function has returned APR_ENOTIMPL.  This should be 
  treated as an error, and the function should be implemented as soon as
  possible.
  
  Adding New test Suites to the full driver
  -------------------------------------------
  
  To add a new Suite to the full driver, you must make a couple of modifications.
  
  1)  Edit test_apr.h, and add the prototype for the function.
  2)  Edit testall.c, and add the function and name to the tests array.
  3)  Edit Makefile.in, and add the .lo file to the testall target.
  
  Once those four things are done, your tests will automatically be added
  to the suite.
  
  Writing tests
  -------------
  
  There are a couple of rules for writing good tests for the test suite.
  
  1)  All tests can determine for themselves if it passed or not.  This means
  that there is no reason for the person running the test suite to interpret
  the results of the tests.
  2)  Never use printf to add to the output of the test suite.  The suite
  library should be able to print all of the information required to debug
  a problem.
  3)  Functions should be tested with both positive and negative tests.  This
  means that you should test things that should both succeed and fail.
  4)  Just checking the return code does _NOT_ make a useful test.  You must
  check to determine that the test actually did what you expected it to do.
  
  An example test
  ---------------
  
  Finally, we will look at a quick test:
  
  /* All tests are passed a CuTest variable.  This is how the suite determines
   * if the test succeeded or failed.
   */
  static void test_localstr(CuTest *tc)
  {
      apr_status_t rv;
      apr_time_exp_t xt;
      time_t os_now;
  
      rv = apr_time_exp_lt(&xt, now);
      os_now = now / APR_USEC_PER_SEC;
     
      /* If the function can return APR_ENOTIMPL, then you should check for it.
       * This allows platform implementors to know if they have to implement
       * the function.
       */
      if (rv == APR_ENOTIMPL) {
          CuNotImpl(tc, "apr_time_exp_lt");
      }
  
      /* It often helps to ensure that the return code was APR_SUCESS.  If it
       * wasn't, then we know the test failed.
       */
      CuAssertTrue(tc, rv == APR_SUCCESS);
  
      /* Now that we know APR thinks it worked properly, we need to check the
       * output to ensure that we got what we expected.
       */
      CuAssertStrEquals(tc, "2002-08-14 12:05:36.186711 -25200 [257 Sat] DST",
                        print_time(p, &xt));
  }
  
  Notice, the same test can fail for any of a number of reasons.  The first 
  test to fail ends the test.
  
  CuTest
  ------
  
  CuTest is an open source test suite written by Asim Jalis.  It has been 
  released under the zlib/libpng license.  That license can be found in the
  CuTest.c and CuTest.h files.
  
  The version of CuTest that is included in the APR test suite has been modified
  from the original distribution in the following ways:
  
  1)  The original distribution does not have a -v flag, the details are always
  printed.
  2)  The NotImplemented result does not exist.
  3)  SuiteLists do not exist.  In the original distribution, you can add suites
  to suites, but it just adds the tests in the first suite to the list of tests
  in the original suite.  The output wasn't as detailed as I wanted, so I created
  SuiteLists.
  
  The first two modifications have been sent to the original author of CuTest,
  but they have not been integrated into the base distribution.  The SuiteList
  changes will be sent to the original author soon.
  
  The modified version of CuTest is not currently in any CVS or Subversion
  server.  In time, it will be hosted at rkbloom.net.
  
  There are currently no docs for how to write tests, but the teststr and 
  testtime programs should give an idea of how it is done.  In time, a document
  should be written to define how tests are written.
  
  
  
  
  1.1                  httpd-apreq-2/t/tables.c
  
  Index: tables.c
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002-2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. 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.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED 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 APACHE SOFTWARE FOUNDATION OR
   * ITS 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.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  #include "test_apr.h"
  #include "apr.h"
  #include "apr_strings.h"
  #include "apr_general.h"
  #include "apr_pools.h"
  #include "apr_tables.h"
  #if APR_HAVE_STDIO_H
  #include <stdio.h>
  #endif
  #if APR_HAVE_STDLIB_H
  #include <stdlib.h>
  #endif
  #if APR_HAVE_STRING_H
  #include <string.h>
  #endif
  
  static apr_table_t *t1 = NULL;
  
  static void table_make(CuTest *tc)
  {
      t1 = apr_table_make(p, 5);
      CuAssertPtrNotNull(tc, t1);
  }
  
  static void table_get(CuTest *tc)
  {
      const char *val;
  
      apr_table_set(t1, "foo", "bar");
      val = apr_table_get(t1, "foo");
      CuAssertStrEquals(tc, val, "bar");
  }
  
  static void table_set(CuTest *tc)
  {
      const char *val;
  
      apr_table_set(t1, "setkey", "bar");
      apr_table_set(t1, "setkey", "2ndtry");
      val = apr_table_get(t1, "setkey");
      CuAssertStrEquals(tc, val, "2ndtry");
  }
  
  static void table_getnotthere(CuTest *tc)
  {
      const char *val;
  
      val = apr_table_get(t1, "keynotthere");
      CuAssertPtrEquals(tc, NULL, (void *)val);
  }
  
  static void table_add(CuTest *tc)
  {
      const char *val;
  
      apr_table_add(t1, "addkey", "bar");
      apr_table_add(t1, "addkey", "foo");
      val = apr_table_get(t1, "addkey");
      CuAssertStrEquals(tc, val, "bar");
  
  }
  
  static void table_nelts(CuTest *tc)
  {
      const char *val;
      apr_table_t *t = apr_table_make(p, 1);
  
      apr_table_set(t, "abc", "def");
      apr_table_set(t, "def", "abc");
      apr_table_set(t, "foo", "zzz");
      val = apr_table_get(t, "foo");
      CuAssertStrEquals(tc, val, "zzz");
      val = apr_table_get(t, "abc");
      CuAssertStrEquals(tc, val, "def");
      val = apr_table_get(t, "def");
      CuAssertStrEquals(tc, val, "abc");
      CuAssertIntEquals(tc, 3, apr_table_elts(t)->nelts);
  }
  
  static void table_clear(CuTest *tc)
  {
      apr_table_clear(t1);
      CuAssertIntEquals(tc, 0, apr_table_elts(t1)->nelts);
  }
  
  static void table_unset(CuTest *tc)
  {
      const char *val;
      apr_table_t *t = apr_table_make(p, 1);
  
      apr_table_set(t, "a", "1");
      apr_table_set(t, "b", "2");
      apr_table_unset(t, "b");
      CuAssertIntEquals(tc, 1, apr_table_elts(t)->nelts);
      val = apr_table_get(t, "a");
      CuAssertStrEquals(tc, val, "1");
      val = apr_table_get(t, "b");
      CuAssertPtrEquals(tc, (void *)val, (void *)NULL);
  }
  
  static void table_overlap(CuTest *tc)
  {
      const char *val;
      apr_table_t *t1 = apr_table_make(p, 1);
      apr_table_t *t2 = apr_table_make(p, 1);
  
      apr_table_addn(t1, "a", "0");
      apr_table_addn(t1, "g", "7");
      apr_table_addn(t2, "a", "1");
      apr_table_addn(t2, "b", "2");
      apr_table_addn(t2, "c", "3");
      apr_table_addn(t2, "b", "2.0");
      apr_table_addn(t2, "d", "4");
      apr_table_addn(t2, "e", "5");
      apr_table_addn(t2, "b", "2.");
      apr_table_addn(t2, "f", "6");
      apr_table_overlap(t1, t2, APR_OVERLAP_TABLES_SET);
      
      CuAssertIntEquals(tc, apr_table_elts(t1)->nelts, 7);
      val = apr_table_get(t1, "a");
      CuAssertStrEquals(tc, val, "1");
      val = apr_table_get(t1, "b");
      CuAssertStrEquals(tc, val, "2");
      val = apr_table_get(t1, "c");
      CuAssertStrEquals(tc, val, "3");
      val = apr_table_get(t1, "d");
      CuAssertStrEquals(tc, val, "4");
      val = apr_table_get(t1, "e");
      CuAssertStrEquals(tc, val, "5");
      val = apr_table_get(t1, "f");
      CuAssertStrEquals(tc, val, "6");
      val = apr_table_get(t1, "g");
      CuAssertStrEquals(tc, val, "7");
  }
  
  CuSuite *testtable(void)
  {
      CuSuite *suite = CuSuiteNew("Table");
  
      SUITE_ADD_TEST(suite, table_make);
      SUITE_ADD_TEST(suite, table_get);
      SUITE_ADD_TEST(suite, table_set);
      SUITE_ADD_TEST(suite, table_getnotthere);
      SUITE_ADD_TEST(suite, table_add);
      SUITE_ADD_TEST(suite, table_nelts);
      SUITE_ADD_TEST(suite, table_clear);
      SUITE_ADD_TEST(suite, table_unset);
      SUITE_ADD_TEST(suite, table_overlap);
  
      return suite;
  }
  
  
  
  
  1.1                  httpd-apreq-2/t/test_apr.h
  
  Index: test_apr.h
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. 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.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED 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 APACHE SOFTWARE FOUNDATION OR
   * ITS 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.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  #ifndef APR_TEST_INCLUDES
  #define APR_TEST_INCLUDES
  
  #include "CuTest.h"
  #include "apr_pools.h"
  
  /* Some simple functions to make the test apps easier to write and
   * a bit more consistent...
   */
  
  extern apr_pool_t *p;
  
  CuSuite *getsuite(void);
  
  CuSuite *teststr(void);
  CuSuite *testtime(void);
  CuSuite *testvsn(void);
  CuSuite *testipsub(void);
  CuSuite *testmmap(void);
  CuSuite *testud(void);
  CuSuite *testtable(void);
  CuSuite *testhash(void);
  CuSuite *testsleep(void);
  CuSuite *testpool(void);
  CuSuite *testfmt(void);
  CuSuite *testfile(void);
  CuSuite *testdir(void);
  CuSuite *testfileinfo(void);
  CuSuite *testrand(void);
  CuSuite *testdso(void);
  CuSuite *testoc(void);
  CuSuite *testdup(void);
  CuSuite *testsockets(void);
  CuSuite *testproc(void);
  CuSuite *testpoll(void);
  CuSuite *testlock(void);
  CuSuite *testsockopt(void);
  CuSuite *testpipe(void);
  CuSuite *testthread(void);
  CuSuite *testgetopt(void);
  CuSuite *testnames(void);
  CuSuite *testuser(void);
  CuSuite *testpath(void);
  CuSuite *testenv(void);
  
  /* Assert that RV is an APR_SUCCESS value; else fail giving strerror
   * for RV and CONTEXT message. */
  void apr_assert_success(CuTest* tc, const char *context, apr_status_t rv);
  
  
  #endif /* APR_TEST_INCLUDES */
  
  
  
  1.1                  httpd-apreq-2/t/testall.c
  
  Index: testall.c
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. 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.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED 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 APACHE SOFTWARE FOUNDATION OR
   * ITS 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.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  #include <stdio.h>
  #include <stdlib.h>
  
  #include "test_apr.h"
  
  /* Top-level pool which can be used by tests. */
  apr_pool_t *p;
  
  void apr_assert_success(CuTest* tc, const char* context, apr_status_t rv)
  {
      if (rv == APR_ENOTIMPL) {
          CuNotImpl(tc, context);
      }
  
      if (rv != APR_SUCCESS) {
          char buf[STRING_MAX], ebuf[128];
          sprintf(buf, "%s (%d): %s\n", context, rv,
                  apr_strerror(rv, ebuf, sizeof ebuf));
          CuFail(tc, buf);
      }
  }
  
  static const struct testlist {
      const char *testname;
      CuSuite *(*func)(void);
  } tests[] = {
  /*    {"teststr", teststr},
      {"testtime", testtime},
      {"testvsn", testvsn},
      {"testipsub", testipsub},
      {"testmmap", testmmap},
      {"testud", testud}, */
      {"tables", testtable},
  /*    {"testhash", testhash},
      {"testsleep", testsleep},
      {"testpool", testpool},
      {"testfmt", testfmt},
      {"testfile", testfile},
      {"testfileinfo", testfileinfo},
      {"testpipe", testpipe},
      {"testdup", testdup},
      {"testdir", testdir},
      {"testrand", testrand},
      {"testdso", testdso},
      {"testoc", testoc},
      {"testsockets", testsockets},
      {"testsockopt", testsockopt},
      {"testproc", testproc},
      {"testpoll", testpoll},
      {"testlock", testlock},
      {"testthread", testthread},
      {"testargs", testgetopt},
      {"testnames", testnames},
      {"testuser", testuser},
      {"testpath", testpath},
      {"testenv", testenv}, */
      {"LastTest", NULL}
  };
  
  int main(int argc, char *argv[])
  {
      CuSuiteList *alltests = NULL;
      CuString *output = CuStringNew();
      int i;
      int partial = 0;
  
      apr_initialize();
      atexit(apr_terminate);
  
      CuInit(argc, argv);
  
      apr_pool_create(&p, NULL);
  
      /* build the list of tests to run */
      for (i = 1; i < argc; i++) {
          int j;
          if (!strcmp(argv[i], "-v")) {
              continue;
          }
          for (j = 0; tests[j].func != NULL; j++) {
              if (!strcmp(argv[i], tests[j].testname)) {
                  if (!partial) {
                      alltests = CuSuiteListNew("Partial APR Tests");
                      partial = 1;
                  }
  
                  CuSuiteListAdd(alltests, tests[j].func());
                  break;
              }
          }
      }
  
      if (!partial) {
          alltests = CuSuiteListNew("All APR Tests");
          for (i = 0; tests[i].func != NULL; i++) {
              CuSuiteListAdd(alltests, tests[i].func());
          }
      }
  
      CuSuiteListRunWithSummary(alltests);
      i = CuSuiteListDetails(alltests, output);
      printf("%s\n", output->buffer);
  
      return i > 0 ? 1 : 0;
  }