Author: joes
Date: Sat Feb 12 15:04:35 2005
New Revision: 153577
URL: http://svn.apache.org/viewcvs?view=rev&rev=153577
Log:
Replace CuTest-based tests with custom TAP-compliant
framework.
Added:
httpd/apreq/trunk/t/at.c
httpd/apreq/trunk/t/at.h
httpd/apreq/trunk/t/test_env.c
Removed:
httpd/apreq/trunk/t/CuTest.c
httpd/apreq/trunk/t/CuTest.h
httpd/apreq/trunk/t/README
httpd/apreq/trunk/t/testall.c
Modified:
httpd/apreq/trunk/CHANGES
httpd/apreq/trunk/Makefile.am
httpd/apreq/trunk/README
httpd/apreq/trunk/t/Makefile.am
httpd/apreq/trunk/t/cookie.c
httpd/apreq/trunk/t/params.c
httpd/apreq/trunk/t/parsers.c
httpd/apreq/trunk/t/test_apreq.h
httpd/apreq/trunk/t/version.c
Modified: httpd/apreq/trunk/CHANGES
URL:
http://svn.apache.org/viewcvs/httpd/apreq/trunk/CHANGES?view=diff&r1=153576&r2=153577
==============================================================================
--- httpd/apreq/trunk/CHANGES (original)
+++ httpd/apreq/trunk/CHANGES Sat Feb 12 15:04:35 2005
@@ -5,6 +5,10 @@
@section v2_05 Changes with libapreq2-2.05
+- C Tests [joes]
+ Replace CuTest-based tests with custom TAP-compliant
+ framework.
+
- C API [joes]
Make our "libtool current interface" number depend on apr's
major number. This allows libapreq2 to be installed into a
Modified: httpd/apreq/trunk/Makefile.am
URL:
http://svn.apache.org/viewcvs/httpd/apreq/trunk/Makefile.am?view=diff&r1=153576&r2=153577
==============================================================================
--- httpd/apreq/trunk/Makefile.am (original)
+++ httpd/apreq/trunk/Makefile.am Sat Feb 12 15:04:35 2005
@@ -78,13 +78,13 @@
-mkdir docs
echo GENERATE_TAGFILE=`pwd`/docs/apr.tag | $(APR_DOX)
-test: lib_test env_test $(PERL_TEST)
+test: all lib_test env_test $(PERL_TEST)
env_test:
cd env; $(MAKE) test
-lib_test: check
- t/testall -v
+lib_test:
+ cd t; $(MAKE) test
perl_install:
cd glue/perl; $(MAKE) install
Modified: httpd/apreq/trunk/README
URL:
http://svn.apache.org/viewcvs/httpd/apreq/trunk/README?view=diff&r1=153576&r2=153577
==============================================================================
--- httpd/apreq/trunk/README (original)
+++ httpd/apreq/trunk/README Sat Feb 12 15:04:35 2005
@@ -112,10 +112,9 @@
We wish to acknowledge the following copyrighted works that
make up portions of the Apache software:
- libapreq version 2 relies heavily on the use of GNU autoconf,
- automake and libtool to provide a build environment. The core
- unit tests for libapreq are based upon CuTest. The environment
- and perl glue tests are based on Apache::Test.
+ libapreq2 relies heavily on the use of the GNU auto-tools
+ to provide a build environment. The tests are based on
+ the Apache::Test, Test::Harness and Test::Inline.
- Doxygen generates the documentation for libapreq-2. The perl glue
+ Doxygen generates the documentation for libapreq2. The perl glue
and pods are generated by ExtUtils::XSBuilder.
Modified: httpd/apreq/trunk/t/Makefile.am
URL:
http://svn.apache.org/viewcvs/httpd/apreq/trunk/t/Makefile.am?view=diff&r1=153576&r2=153577
==============================================================================
--- httpd/apreq/trunk/t/Makefile.am (original)
+++ httpd/apreq/trunk/t/Makefile.am Sat Feb 12 15:04:35 2005
@@ -2,11 +2,20 @@
LIBS = ../src/libapreq2.la @APR_LTLIBS@ @APU_LTLIBS@
LDFLAGS = @APR_LDFLAGS@ @APU_LDFLAGS@
-noinst_LIBRARIES = libapreq2_tests.a
-libapreq2_tests_a_SOURCES = CuTest.h test_apreq.h CuTest.c version.c cookie.c
params.c parsers.c
+noinst_LIBRARIES = libapreq2_test.a
+libapreq2_test_a_SOURCES = at.h at.c test_env.c
-check_PROGRAMS = testall
-testall_LDADD = libapreq2_tests.a
+check_PROGRAMS = version cookie params parsers
+LDADD = libapreq2_test.a
-test: check
- ./testall -v
+check_SCRIPTS = version.t cookie.t params.t parsers.t
+TESTS = $(check_SCRIPTS)
+TESTS_ENVIRONMENT = @PERL@ -MTest::Harness -e 'runtests(@ARGV)'
+CLEANFILES = $(check_SCRIPTS)
+
+%.t: %
+ echo "#!perl" > $@
+ echo "exec './$*'" >> $@
+
+test: $(check_SCRIPTS)
+ $(TESTS_ENVIRONMENT) $(check_SCRIPTS)
Added: httpd/apreq/trunk/t/at.c
URL: http://svn.apache.org/viewcvs/httpd/apreq/trunk/t/at.c?view=auto&rev=153577
==============================================================================
--- httpd/apreq/trunk/t/at.c (added)
+++ httpd/apreq/trunk/t/at.c Sat Feb 12 15:04:35 2005
@@ -0,0 +1,338 @@
+/*
+** Copyright 2004-2005 The Apache Software Foundation
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+
+#include "apr_file_io.h"
+#include "at.h"
+#include "apr_lib.h"
+#include "apr_strings.h"
+#include "apr_tables.h"
+#include "apr_env.h"
+#include <assert.h>
+
+
+apr_status_t at_begin(at_t *t, int total)
+{
+ char buf[32];
+ apr_snprintf(buf, 32, "1..%d", total);
+ return at_report(t, buf);
+}
+
+static apr_status_t test_cleanup(void *data)
+{
+ at_t *t = data;
+ if (t->current < t->plan)
+ return at_report(t, "Bail out!");
+ else
+ return at_report(t, "END");
+}
+
+void at_end(at_t *t)
+{
+ apr_pool_cleanup_kill(t->pool, t, test_cleanup);
+ test_cleanup(t);
+}
+
+apr_status_t at_comment(at_t *t, const char *fmt, va_list vp)
+{
+ apr_status_t s;
+ char buf[256], *b = buf + 2;
+ char *end;
+ int rv;
+ rv = apr_vsnprintf(b, 250, fmt, vp);
+
+ if (rv <= 0)
+ return APR_EINVAL;
+
+ end = b + rv;
+
+ buf[0] = '#';
+ buf[1] = ' ';
+
+ if (rv == 250) {
+ *end++ = '.';
+ *end++ = '.';
+ *end++ = '.';
+ *end = '\n';
+ }
+ else if (end[-1] != '\n') {
+ *end = '\n';
+ }
+
+ b = buf;
+ while (1) {
+ char *eol;
+
+ eol = strchr(b + 2, '\n');
+ assert(eol != NULL);
+ *eol = 0;
+ s = at_report(t, b);
+ if (s != APR_SUCCESS || eol == end)
+ break;
+
+ b = eol - 1;
+ b[0] = '#';
+ b[1] = ' ';
+ }
+
+ return s;
+}
+
+void at_ok(at_t *t, int is_ok, const char *label, const char *file, int line)
+{
+ char format[] = "not ok %d - %s # %s (%s:%d) test %d in %s";
+ char *end = format + 10;
+ char *fmt = is_ok ? format + 4 : format;
+ char buf[256];
+ const char *comment = NULL;
+ int rv, is_fatal = 0, is_skip = 0, is_todo = 0;
+
+ t->current++;
+
+ if (*t->fatal == t->current) {
+ t->fatal++;
+ is_fatal = 1;
+ }
+
+ if (*t->skip == t->current) {
+ t->skip++;
+ is_skip = 1;
+ }
+
+ if (*t->todo == t->current) {
+ t->todo++;
+ is_todo = 1;
+ }
+
+ if (AT_FLAG_CONCISE(t->flags))
+ format[9] = '\0';
+ else if (is_ok && !AT_FLAG_TRACE(t->flags))
+ format[14] = '\0';
+ else if (is_fatal && ! is_ok)
+ comment = "bail";
+ else
+ comment = is_todo ? "todo" : is_skip ? "skip" : "at";
+
+ rv = apr_snprintf(buf, 256, fmt, t->current + t->prior,
+ label, comment, file, line, t->current, t->name);
+
+ if (rv <= 0)
+ exit(-1);
+
+ end = buf + rv;
+
+ if (rv == 250) {
+ *end++ = '.';
+ *end++ = '.';
+ *end++ = '.';
+ *end = '\0';
+ }
+
+ if (memchr(buf, '\n', rv) != NULL || at_report(t, buf) != APR_SUCCESS)
+ exit(-1);
+
+ if (!is_ok && is_fatal) {
+ if (t->abort != NULL) {
+ at_trace(t, "Abandon %s, omitting tests %d - %d from this run.",
+ t->name, t->prior + t->current + 1, t->prior + t->plan);
+ longjmp(*t->abort, 0);
+ }
+ else {
+ apr_pool_cleanup_kill(t->pool, t, test_cleanup);
+ at_report(t, "Bail out!");
+ exit(-1);
+ }
+ }
+}
+
+struct at_report_file {
+ at_report_t module;
+ apr_file_t *file;
+};
+
+
+static apr_status_t at_report_file_write(at_report_t *ctx, const char *msg)
+{
+ struct at_report_file *r = (struct at_report_file *)ctx;
+ apr_file_t *f = r->file;
+ apr_size_t len = strlen(msg);
+ apr_status_t s;
+
+ s = apr_file_write_full(f, msg, len, &len);
+ if (s != APR_SUCCESS)
+ return s;
+
+ s = apr_file_putc('\n', f);
+ if (s != APR_SUCCESS)
+ return s;
+
+ return apr_file_flush(f);
+}
+
+at_report_t *at_report_file_make(apr_pool_t *p, apr_file_t *f)
+{
+ struct at_report_file *r = apr_palloc(p, sizeof *r);
+ r->module.func = at_report_file_write;
+ r->file = f;
+ return &r->module;
+}
+
+
+
+struct at_report_local {
+ at_report_t module;
+ at_t *t;
+ at_report_t *saved_report;
+ const int *saved_fatal;
+ int dummy_fatal;
+ const char *file;
+ int line;
+ int passed;
+ apr_pool_t *pool;
+};
+
+
+static apr_status_t report_local_cleanup(void *data)
+{
+ struct at_report_local *q = data;
+ dAT = q->t;
+ char label[32];
+
+ apr_snprintf(label, 32, "collected %d passing tests", q->passed);
+
+ AT->report = q->saved_report;
+ AT->fatal = q->saved_fatal;
+
+ at_ok(q->t, 1, label, q->file, q->line);
+ return APR_SUCCESS;
+}
+
+
+static apr_status_t at_report_local_write(at_report_t *ctx, const char *msg)
+{
+ struct at_report_local *q = (struct at_report_local *)ctx;
+ dAT = q->t;
+
+ if (strncmp(msg, "not ok", 6) == 0) {
+ q->saved_report->func(q->saved_report, msg);
+ AT->report = q->saved_report;
+ AT->fatal = q->saved_fatal;
+ apr_pool_cleanup_kill(q->pool, q, report_local_cleanup);
+ at_trace(AT, "Abandon %s, omitting tests %d - %d from this run.",
+ AT->name, AT->prior + AT->current + 1, AT->prior + AT->plan);
+ longjmp(*AT->abort, 0);
+ }
+ AT->current--;
+ q->passed++;
+ return APR_SUCCESS;
+}
+
+void at_report_local(at_t *AT, apr_pool_t *p, const char *file, int line)
+{
+ struct at_report_local *q = apr_palloc(p, sizeof *q);
+ q->module.func = at_report_local_write;
+ q->t = AT;
+ q->saved_report = AT->report;
+ q->saved_fatal = AT->fatal;
+ q->dummy_fatal = 0;
+ q->file = apr_pstrdup(p, file);
+ q->line = line;
+ q->passed = 0;
+ q->pool = p;
+
+ AT->fatal = &q->dummy_fatal;
+ AT->report = &q->module;
+
+ if (*q->saved_fatal == AT->current + 1)
+ q->saved_fatal++;
+
+ apr_pool_cleanup_register(p, q, report_local_cleanup,
+ report_local_cleanup);
+}
+
+
+at_t *at_create(apr_pool_t *pool, unsigned char flags, at_report_t *report)
+{
+ at_t *t = apr_pcalloc(pool, sizeof *t);
+ t->flags = flags;
+ t->report = report;
+ t->pool = pool;
+
+ apr_pool_cleanup_register(pool, t, test_cleanup, test_cleanup);
+ return t;
+}
+
+
+#define AT_NELTS 4
+
+static int* at_list(apr_pool_t *pool, const char *spec, int *list)
+{
+ apr_array_header_t arr;
+ int prev, current = 0;
+
+ arr.pool = pool;
+ arr.elt_size = sizeof *list;
+ arr.nelts = 0;
+ arr.nalloc = AT_NELTS;
+ arr.elts = (char *)list;
+
+ do {
+ while (*spec && !apr_isdigit(*spec))
+ ++spec;
+
+ prev = current;
+ current = (int)apr_strtoi64(spec, (char **)&spec, 10);
+ *(int *)apr_array_push(&arr) = current;
+
+ } while (prev >= current);
+
+ return (int *)arr.elts;
+}
+
+
+
+apr_status_t at_run(at_t *AT, const at_test_t *test)
+{
+ int dummy = 0, fbuf[AT_NELTS], sbuf[AT_NELTS], tbuf[AT_NELTS];
+ jmp_buf j;
+
+ AT->current = 0;
+ AT->prior += AT->plan;
+ AT->name = test->name;
+ AT->plan = test->plan;
+
+ if (test->fatals)
+ AT->fatal = at_list(AT->pool, test->fatals, fbuf);
+ else
+ AT->fatal = &dummy;
+
+ if (test->skips)
+ AT->skip = at_list(AT->pool, test->skips, sbuf);
+ else
+ AT->skip = &dummy;
+
+ if (test->todos)
+ AT->todo = at_list(AT->pool, test->todos, tbuf);
+ else
+ AT->todo = &dummy;
+
+ AT->abort = &j;
+ if (setjmp(j) == 0) {
+ test->func(AT);
+ return APR_SUCCESS;
+ }
+ AT->abort = NULL;
+ return APR_EGENERAL;
+}
Added: httpd/apreq/trunk/t/at.h
URL: http://svn.apache.org/viewcvs/httpd/apreq/trunk/t/at.h?view=auto&rev=153577
==============================================================================
--- httpd/apreq/trunk/t/at.h (added)
+++ httpd/apreq/trunk/t/at.h Sat Feb 12 15:04:35 2005
@@ -0,0 +1,265 @@
+/*
+** Copyright 2004-2005 The Apache Software Foundation
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+
+
+/* at.h: TAP-compliant C utilities for the Apache::Test framework. */
+
+#ifndef AT_H
+#define AT_H
+
+#include "apr.h"
+#include "apr_file_io.h"
+#include <stdarg.h>
+#include <stdlib.h>
+#include <setjmp.h>
+
+typedef struct at_t at_t;
+typedef struct at_report_t at_report_t;
+
+typedef apr_status_t (*at_report_function_t)(at_report_t *r, const char *msg);
+typedef void(*at_test_function_t)(at_t *t);
+typedef struct at_test_t at_test_t;
+
+struct at_test_t {
+ const char *name;
+ at_test_function_t func;
+ int plan;
+ const char *fatals;
+ const char *todos;
+ const char *skips;
+};
+
+struct at_report_t {
+ at_report_function_t func;
+};
+
+/* We only need one at_t struct per test suite, so lets call it *AT.
+ * The mnemonic we follow is that (for lowercase foo) "AT_foo(bar)"
+ * should be syntactically equivalent to "at_foo(AT, bar)".
+ *
+ * Terminology: test == an at_test_t,
+ * check == an assertion which produces TAP.
+ */
+
+#define dAT at_t *AT
+
+struct at_t {
+ int current; /* current check for this test */
+ int prior; /* total # of checks prior to this test */
+ const char *name; /* name of current test */
+ int plan; /* total # of checks in this test */
+ const int *fatal; /* list of unrecoverables */
+ const int *todo; /* list of expected failures */
+ const int *skip; /* list of ignorabe assertions */
+ at_report_t *report ;/* handles the results of each check */
+ unsigned char flags; /* verbosity: concise, trace, debug, etc. */
+ apr_pool_t *pool; /* creator pool with end-of-test cleanup */
+ jmp_buf *abort; /* where fatals go to die */
+};
+
+
+
+static APR_INLINE
+apr_status_t at_report(at_t *t, const char *msg) {
+ at_report_t *r = t->report;
+ return r->func(r, msg);
+}
+#define AT_report(msg) at_report(AT, msg)
+
+/* The core assertion checker; the rest just wind up invoking this one. */
+void at_ok(at_t *t, int is_ok, const char *label, const char *file, int line);
+#define AT_ok(is_ok, label) at_ok(AT, is_ok, label, __FILE__, __LINE__)
+
+at_t *at_create(apr_pool_t *pool, unsigned char flags, at_report_t *report);
+apr_status_t at_begin(at_t *t, int total);
+#define AT_begin(total) at_begin(AT, total)
+
+apr_status_t at_run(at_t *AT, const at_test_t *test);
+#define AT_run(test) at_run(AT, test)
+
+void at_end(at_t *t);
+#define AT_end() at_end(AT)
+
+
+#define AT_FLAG_DEBUG(f) ((f) & 4)
+#define AT_FLAG_DEBUG_ON(f) ((f) |= 4)
+#define AT_FLAG_DEBUG_OFF(f) ((f) &= ~4)
+#define AT_FLAG_TRACE(f) ((f) & 2)
+#define AT_FLAG_TRACE_ON(f) ((f) |= 2)
+#define AT_FLAG_TRACE_OFF(f) ((f) &= ~2)
+#define AT_FLAG_CONCISE(f) ((f) & 1)
+#define AT_FLAG_CONCISE_ON(f) ((f) |= 1)
+#define AT_FLAG_CONCISE_OFF(f) ((f) &= ~1)
+
+#define AT_debug_on() AT_FLAG_DEBUG_ON(AT->flags)
+#define AT_debug_off() AT_FLAG_DEBUG_OFF(AT->flags)
+#define AT_trace_on() AT_FLAG_TRACE_ON(AT->flags)
+#define AT_trace_off() AT_FLAG_TRACE_OFF(AT->flags)
+#define AT_concise_on() AT_FLAG_CONCISE_ON(AT->flags)
+#define AT_concise_off() AT_FLAG_CONCISE_OFF(AT->flags)
+
+
+
+/* Additional reporting utils.
+ These emit TAP comments, and are not "checks". */
+
+apr_status_t at_comment(at_t *t, const char *fmt, va_list vp);
+
+static APR_INLINE
+void at_debug(at_t *t, const char *fmt, ...) {
+ va_list vp;
+ va_start(vp, fmt);
+ if (AT_FLAG_DEBUG(t->flags))
+ at_comment(t, fmt, vp);
+ va_end(vp);
+}
+
+static APR_INLINE
+void at_trace(at_t *t, const char *fmt, ...) {
+ va_list vp;
+ va_start(vp, fmt);
+ if (AT_FLAG_TRACE(t->flags))
+ at_comment(t, fmt, vp);
+ va_end(vp);
+}
+
+
+
+/* These are "checks". */
+
+static APR_INLINE
+void at_check(at_t *t, int is_ok, const char *label, const char *file,
+ int line, const char *fmt, ...)
+{
+ va_list vp;
+
+ va_start(vp, fmt);
+ if (AT_FLAG_TRACE(t->flags)) {
+ char format[64] = "testing: %s (%s:%d)";
+ at_trace(t, format, label, file, line);
+
+ if (fmt != NULL) {
+ char *f;
+ at_trace(t, " format: %s", fmt);
+ strcpy(format, " left: ");
+ strcpy(format + sizeof(" left: ") -1, fmt);
+ f = format + strlen(format);
+ strcpy(f+1, format);
+ *f = '\n';
+ memcpy(f+1, " right: ", sizeof(" right: ") -1);
+ at_comment(t, format, vp);
+ }
+ }
+ va_end(vp);
+ at_ok(t, is_ok, label, file, line);
+}
+
+
+#define AT_mem_ne(a, b, n) do { \
+ unsigned sz = n; \
+ const void *left = a, *right = b; \
+ char fmt[] = ", as %u-byte struct pointers"; \
+ char buf[256] = #a " != " #b; \
+ const unsigned blen = sizeof(#a " != " #b); \
+ apr_snprintf(buf + blen - 1, 256 - blen, fmt, sz); \
+ apr_snprintf(fmt, sizeof(fmt), "%%.%us", sz); \
+ at_check(AT, memcmp(left, right, sz), buf, __FILE__, __LINE__, \
+ fmt, left, right); \
+} while (0) \
+
+#define AT_mem_eq(a, b, n) do { \
+ unsigned sz = n; \
+ const void *left = a, *right = b; \
+ char fmt[] = ", as %u-byte struct pointers"; \
+ char buf[256] = #a " == " #b; \
+ const unsigned blen = sizeof(#a " == " #b); \
+ apr_snprintf(buf + blen - 1, 256 - blen , fmt, sz); \
+ apr_snprintf(fmt, sizeof(fmt), "%%.%us", sz); \
+ at_check(AT, !memcmp(left, right, sz), buf, __FILE__, __LINE__, \
+ fmt, left, right); \
+} while (0)
+
+
+
+#define AT_str_eq(a, b) do { \
+ const char *left = a, *right = b; \
+ at_check(AT,!strcmp(left, right), #a " == " #b ", as strings", \
+ __FILE__, __LINE__, "%s", left, right); \
+} while (0)
+
+
+#define AT_str_ne(a, b) do { \
+ const char *left = a, *right = b; \
+ at_check(AT, strcmp(left, right), #a " != " #b ", as strings", \
+ __FILE__, __LINE__, "%s", left, right); \
+} while (0)
+
+#define AT_ptr_eq(a, b) do { \
+ const void *left = a, *right = b; \
+ at_check(AT, left == right, #a " == " #b ", as pointers", \
+ __FILE__, __LINE__, "%pp", left, right); \
+} while (0)
+
+#define AT_ptr_ne(a, b) do { \
+ const void *left = a, *right = b; \
+ at_check(AT, left != right, #a " != " #b ", as pointers", \
+ __FILE__, __LINE__, "%pp", left, right); \
+} while (0)
+
+
+#define AT_int_eq(a, b) do { \
+ const int left = a, right = b; \
+ at_check(AT, left == right, #a " == " #b ", as integers", \
+ __FILE__, __LINE__, "%d", left, right); \
+} while (0)
+
+#define AT_int_ne(a, b) do { \
+ const int left = a, right = b; \
+ at_check(AT, left != right, #a " != " #b ", as integers", \
+ __FILE__, __LINE__, "%d", left, right); \
+} while (0)
+
+#define AT_is_null(a) AT_ptr_eq(a, NULL)
+#define AT_not_null(a) AT_ptr_ne(a, NULL)
+
+
+/* XXX these two macro checks evaluate a & b more than once, but the
+ * upshot is that they don't care too much about their types.
+ */
+
+#define AT_EQ(a, b, fmt) at_check(AT, ((a) == (b)), #a " == " #b,\
+ __FILE__, __LINE__, fmt, a, b)
+#define AT_NE(a, b, fmt) at_check(AT, ((a) != (b)), #a " != " #b,\
+ __FILE__, __LINE__, fmt, a, b)
+
+
+
+/* Report utilities. */
+
+at_report_t *at_report_file_make(apr_pool_t *p, apr_file_t *f);
+APR_INLINE
+static at_report_t *at_report_stdout_make(apr_pool_t *p)
+{
+ apr_file_t *out;
+ apr_file_open_stdout(&out, p);
+ return at_report_file_make(p, out);
+}
+
+void at_report_local(at_t *AT, apr_pool_t *p, const char *file, int line);
+#define AT_localize(p) at_report_local(AT, p, __FILE__, __LINE__)
+
+
+#endif /* AT_H */
Modified: httpd/apreq/trunk/t/cookie.c
URL:
http://svn.apache.org/viewcvs/httpd/apreq/trunk/t/cookie.c?view=diff&r1=153576&r2=153577
==============================================================================
--- httpd/apreq/trunk/t/cookie.c (original)
+++ httpd/apreq/trunk/t/cookie.c Sat Feb 12 15:04:35 2005
@@ -15,121 +15,137 @@
*/
#include "apreq_env.h"
-#include "test_apreq.h"
-#include "apreq.h"
-#include "apreq_cookie.h"
#include "apr_strings.h"
+#include "at.h"
+extern apr_pool_t *p;
static apreq_jar_t *j = NULL;
-static void jar_make(CuTest *tc)
+#define dTEST(func, plan) static const at_test_t test_##func = \
+ {#func, func, plan, NULL, NULL, NULL}
+
+static void jar_make(dAT)
{
j = apreq_jar(p,"a=1; foo=bar; fl=left; fr=right;bad; ns=foo=1&bar=2,"
"frl=right-left; flr=left-right; fll=left-left;
good_one=1;bad");
- CuAssertPtrNotNull(tc, j);
+ AT_not_null(j);
}
+dTEST(jar_make, 1);
+
-static void jar_table_get(CuTest *tc)
+static void jar_get(dAT)
{
- const char *val;
- val = apr_table_get(j->cookies,"a");
- CuAssertStrEquals(tc,"1",val);
+ AT_str_eq(apr_table_get(j->cookies,"a"), "1");
/* ignore wacky cookies that don't have an '=' sign */
- val = apr_table_get(j->cookies,"bad");
- CuAssertPtrEquals(tc,NULL,val);
+ AT_is_null(apr_table_get(j->cookies,"bad"));
/* accept wacky cookies that contain multiple '=' */
- val = apr_table_get(j->cookies,"ns");
- CuAssertStrEquals(tc,"foo=1&bar=2",val);
+ AT_str_eq(apr_table_get(j->cookies,"ns"), "foo=1&bar=2");
- val = apr_table_get(j->cookies,"foo");
- CuAssertStrEquals(tc,"bar",val);
- val = apr_table_get(j->cookies,"fl");
- CuAssertStrEquals(tc,"left",val);
- val = apr_table_get(j->cookies,"fr");
- CuAssertStrEquals(tc,"right",val);
- val = apr_table_get(j->cookies,"frl");
- CuAssertStrEquals(tc,"right-left",val);
- val = apr_table_get(j->cookies,"flr");
- CuAssertStrEquals(tc,"left-right",val);
- val = apr_table_get(j->cookies,"fll");
- CuAssertStrEquals(tc,"left-left",val);
+ AT_str_eq(apr_table_get(j->cookies,"foo"), "bar");
+ AT_str_eq(apr_table_get(j->cookies,"fl"), "left");
+ AT_str_eq(apr_table_get(j->cookies,"fr"), "right");
+ AT_str_eq(apr_table_get(j->cookies,"frl"),"right-left");
+ AT_str_eq(apr_table_get(j->cookies,"flr"),"left-right");
+ AT_str_eq(apr_table_get(j->cookies,"fll"),"left-left");
}
+dTEST(jar_get, 9);
-static void netscape_cookie(CuTest *tc)
+static void netscape_cookie(dAT)
{
apreq_cookie_t *c;
- apreq_cookie_version_t version = APREQ_COOKIE_VERSION_NETSCAPE;
-
+ char *one_year_expiration;
c = apreq_cookie(j,"foo");
- CuAssertStrEquals(tc,"bar",apreq_cookie_value(c));
- CuAssertIntEquals(tc, version,c->version);
+ AT_str_eq(apreq_cookie_value(c), "bar");
+ AT_int_eq(c->version, APREQ_COOKIE_VERSION_NETSCAPE);
+ AT_str_eq(apreq_cookie_as_string(c,p), "foo=bar");
- CuAssertStrEquals(tc,"foo=bar", apreq_cookie_as_string(c,p));
c->domain = apr_pstrdup(p, "example.com");
- CuAssertStrEquals(tc,"foo=bar; domain=example.com",
- apreq_cookie_as_string(c,p));
+ AT_str_eq(apreq_cookie_as_string(c,p),
+ "foo=bar; domain=example.com");
+
c->path = apr_pstrdup(p, "/quux");
- CuAssertStrEquals(tc, "foo=bar; path=/quux; domain=example.com",
- apreq_cookie_as_string(c,p));
+ AT_str_eq(apreq_cookie_as_string(c,p),
+ "foo=bar; path=/quux; domain=example.com");
+ one_year_expiration = apr_pstrcat(p,
+ "foo=bar; path=/quux; domain=example.com; expires=",
+ apreq_expires(p,"+1y",APREQ_EXPIRES_NSCOOKIE), NULL);
+
apreq_cookie_expires(c, "+1y");
- CuAssertStrEquals(tc,apr_pstrcat(p,
- "foo=bar; path=/quux; domain=example.com; expires=",
- apreq_expires(p,"+1y",APREQ_EXPIRES_NSCOOKIE), NULL),
- apreq_cookie_as_string(c,p));
+ AT_str_eq(apreq_cookie_as_string(c,p), one_year_expiration);
}
+dTEST(netscape_cookie, 6);
-static void rfc_cookie(CuTest *tc)
+static void rfc_cookie(dAT)
{
apreq_cookie_t *c = apreq_make_cookie(p,"rfc",3,"out",3);
- long expires;
+ char *three_month_expiration;
- CuAssertStrEquals(tc,"out",apreq_cookie_value(c));
+ AT_str_eq(apreq_cookie_value(c), "out");
c->version = APREQ_COOKIE_VERSION_RFC;
- CuAssertStrEquals(tc,"rfc=out; Version=1", apreq_cookie_as_string(c,p));
+ AT_str_eq(apreq_cookie_as_string(c,p), "rfc=out; Version=1");
+
c->domain = apr_pstrdup(p, "example.com");
- CuAssertStrEquals(tc,"rfc=out; Version=1; domain=\"example.com\"",
- apreq_cookie_as_string(c,p));
+ AT_str_eq(apreq_cookie_as_string(c,p),
+ "rfc=out; Version=1; domain=\"example.com\"");
c->path = apr_pstrdup(p, "/quux");
- CuAssertStrEquals(tc,
- "rfc=out; Version=1; path=\"/quux\"; domain=\"example.com\"",
- apreq_cookie_as_string(c,p));
+ AT_str_eq(apreq_cookie_as_string(c,p),
+ "rfc=out; Version=1; path=\"/quux\"; domain=\"example.com\"");
apreq_cookie_expires(c, "+3m");
- expires = apreq_atoi64t("+3m");
- CuAssertStrEquals(tc,apr_psprintf(p,
- "rfc=out; Version=1; path=\"/quux\"; domain=\"example.com\";
max-age=%ld",
- expires), apreq_cookie_as_string(c,p));
+ three_month_expiration = apr_psprintf(p,
+ "rfc=out; Version=1; path=\"/quux\"; domain=\"example.com\";
max-age=%ld",
+ apreq_atoi64t("+3m"));
+ AT_str_eq(apreq_cookie_as_string(c,p), three_month_expiration);
}
+dTEST(rfc_cookie, 5);
-static void ua_version(CuTest *tc)
-{
- apreq_cookie_version_t v;
-
- v = apreq_ua_cookie_version(NULL);
- CuAssertIntEquals(tc, APREQ_COOKIE_VERSION_NETSCAPE, v);
- v = apreq_ua_cookie_version("$Version=\"1\"");
- CuAssertIntEquals(tc, APREQ_COOKIE_VERSION_RFC, v);
+static void ua_version(dAT)
+{
+ AT_int_eq(apreq_ua_cookie_version(NULL), APREQ_COOKIE_VERSION_NETSCAPE);
+ AT_int_eq(apreq_ua_cookie_version("$Version=\"1\""),
APREQ_COOKIE_VERSION_RFC);
}
+dTEST(ua_version, 2);
-CuSuite *testcookie(void)
+
+int main(int argc, char *argv[])
{
- CuSuite *suite = CuSuiteNew("Cookie");
+ int i, plan = 0;
+ extern const apreq_env_t test_module;
+ dAT;
+ at_test_t cookie_list [] = {
+ test_jar_make,
+ test_jar_get,
+ test_netscape_cookie,
+ test_rfc_cookie,
+ test_ua_version,
+ };
- SUITE_ADD_TEST(suite, jar_make);
- SUITE_ADD_TEST(suite, jar_table_get);
- SUITE_ADD_TEST(suite, netscape_cookie);
- SUITE_ADD_TEST(suite, rfc_cookie);
- SUITE_ADD_TEST(suite, ua_version);
+ apr_initialize();
+ atexit(apr_terminate);
+ apreq_env_module(&test_module);
- return suite;
-}
+ apr_pool_create(&p, NULL);
+
+ AT = at_create(p, 0, at_report_stdout_make(p));
+
+ for (i = 0; i < sizeof(cookie_list) / sizeof(at_test_t); ++i)
+ plan += cookie_list[i].plan;
+ AT_begin(plan);
+
+ for (i = 0; i < sizeof(cookie_list) / sizeof(at_test_t); ++i)
+ AT_run(&cookie_list[i]);
+
+ AT_end();
+
+ return 0;
+}
Modified: httpd/apreq/trunk/t/params.c
URL:
http://svn.apache.org/viewcvs/httpd/apreq/trunk/t/params.c?view=diff&r1=153576&r2=153577
==============================================================================
--- httpd/apreq/trunk/t/params.c (original)
+++ httpd/apreq/trunk/t/params.c Sat Feb 12 15:04:35 2005
@@ -15,55 +15,51 @@
*/
#include "apreq_env.h"
-#include "test_apreq.h"
#include "apreq.h"
#include "apreq_params.h"
#include "apr_strings.h"
+#include "at.h"
static apreq_request_t *r = NULL;
+extern apr_pool_t *p;
-static void request_make(CuTest *tc)
+static void request_make(dAT)
{
r =
apreq_request(NULL,"a=1;quux=foo+bar&a=2&plus=%2B;uplus=%U002b;okie=dokie;novalue1;novalue2=");
- CuAssertPtrNotNull(tc, r);
- CuAssertIntEquals(tc,8, apr_table_elts(r->args)->nelts);
+ AT_not_null(r);
+ AT_int_eq(apr_table_elts(r->args)->nelts, 8);
}
-static void request_args_get(CuTest *tc)
+static void request_args_get(dAT)
{
const char *val;
apreq_value_t *v;
- val = apr_table_get(r->args,"a");
- CuAssertStrEquals(tc,"1",val);
+ AT_str_eq(apr_table_get(r->args,"a"), "1");
+
val = apr_table_get(r->args,"quux");
- CuAssertStrEquals(tc,"foo bar",val);
+ AT_str_eq(val, "foo bar");
v = apreq_strtoval(val);
- CuAssertIntEquals(tc, 7, v->size);
- val = apr_table_get(r->args,"plus");
- CuAssertStrEquals(tc,"+",val);
- val = apr_table_get(r->args,"uplus");
- CuAssertStrEquals(tc,"+",val);
- val = apr_table_get(r->args,"okie");
- CuAssertStrEquals(tc,"dokie",val);
- val = apr_table_get(r->args,"novalue1");
- CuAssertStrEquals(tc,"",val);
- val = apr_table_get(r->args,"novalue2");
- CuAssertStrEquals(tc,"",val);
+ AT_int_eq(v->size, 7);
+ AT_str_eq(apr_table_get(r->args,"plus"), "+");
+ AT_str_eq(apr_table_get(r->args,"uplus"), "+");
+ AT_str_eq(apr_table_get(r->args,"okie"), "dokie");
+ AT_str_eq(apr_table_get(r->args,"novalue1"), "");
+ AT_str_eq(apr_table_get(r->args,"novalue2"),"");
}
-static void params_as(CuTest *tc)
+static void params_as(dAT)
{
const char *val;
apr_array_header_t *arr;
arr = apreq_params_as_array(p,r,"a");
- CuAssertIntEquals(tc,2,arr->nelts);
+ AT_int_eq(arr->nelts, 2);
val = apreq_params_as_string(p,r,"a",APREQ_JOIN_AS_IS);
- CuAssertStrEquals(tc,"1, 2", val);
+ AT_str_eq(val, "1, 2");
}
-static void string_decoding_in_place(CuTest *tc)
+static void string_decoding_in_place(dAT)
{
char *s1 = apr_palloc(p,4096);
char *s2 = apr_palloc(p,4096);
@@ -72,24 +68,24 @@
strcpy(s1, "bend it like beckham");
strcpy(s2, "dandy %3Edons");
- CuAssertStrEquals(tc,"bend it like beckham",s1);
+ AT_str_eq(s1,"bend it like beckham");
apreq_unescape(s1);
- CuAssertStrEquals(tc,"bend it like beckham",s1);
+ AT_str_eq(s1, "bend it like beckham");
s3 = apreq_escape(p, s1, 20);
- CuAssertStrEquals(tc,"bend+it+like+beckham",s3);
+ AT_str_eq(s3, "bend+it+like+beckham");
apreq_unescape(s3);
- CuAssertStrEquals(tc,"bend it like beckham",s3);
+ AT_str_eq(s3,"bend it like beckham");
- CuAssertStrEquals(tc,"dandy %3Edons",s2);
+ AT_str_eq(s2,"dandy %3Edons");
apreq_unescape(s2);
- CuAssertStrEquals(tc,"dandy >dons",s2);
+ AT_str_eq(s2,"dandy >dons");
s3 = apreq_escape(p, s2, 11);
- CuAssertStrEquals(tc,"dandy+%3edons",s3);
+ AT_str_eq(s3,"dandy+%3edons");
apreq_unescape(s3);
- CuAssertStrEquals(tc,"dandy >dons",s3);
+ AT_str_eq(s3,"dandy >dons");
}
-static void header_attributes(CuTest *tc)
+static void header_attributes(dAT)
{
const char *hdr = "text/plain; boundary=\"-foo-\", charset=ISO-8859-1";
const char *val;
@@ -97,38 +93,37 @@
apr_status_t s;
s = apreq_header_attribute(hdr, "none", 4, &val, &vlen);
- CuAssertIntEquals(tc, APR_NOTFOUND, s);
+ AT_int_eq(s, APR_NOTFOUND);
s = apreq_header_attribute(hdr, "set", 3, &val, &vlen);
- CuAssertIntEquals(tc, APR_NOTFOUND, s);
+ AT_int_eq(s, APR_NOTFOUND);
s = apreq_header_attribute(hdr, "boundary", 8, &val, &vlen);
- CuAssertIntEquals(tc, APR_SUCCESS, s);
- CuAssertIntEquals(tc, 5, vlen);
- CuAssertStrNEquals(tc, "-foo-", val, 5);
+ AT_int_eq(s, APR_SUCCESS);
+ AT_int_eq(vlen, 5);
+ AT_mem_eq(val, "-foo-", 5);
s = apreq_header_attribute(hdr, "charset", 7, &val, &vlen);
- CuAssertIntEquals(tc, APR_SUCCESS, s);
- CuAssertIntEquals(tc, 10, vlen);
- CuAssertStrNEquals(tc, "ISO-8859-1", val, 10);
+ AT_int_eq(s, APR_SUCCESS);
+ AT_int_eq(vlen, 10);
+ AT_mem_eq(val, "ISO-8859-1", 10);
hdr = "max-age=20; no-quote=\"...";
s = apreq_header_attribute(hdr, "max-age", 7, &val, &vlen);
- CuAssertIntEquals(tc, APR_SUCCESS, s);
- CuAssertIntEquals(tc, 2, vlen);
- CuAssertStrNEquals(tc, "20", val, 2);
+ AT_int_eq(s, APR_SUCCESS);
+ AT_int_eq(vlen, 2);
+ AT_mem_eq(val, "20", 2);
s = apreq_header_attribute(hdr, "age", 3, &val, &vlen);
- CuAssertIntEquals(tc, APR_EGENERAL, s);
+ AT_int_eq(s, APR_EGENERAL);
s = apreq_header_attribute(hdr, "no-quote", 8, &val, &vlen);
- CuAssertIntEquals(tc, APR_EGENERAL, s);
-
+ AT_int_eq(s, APR_EGENERAL);
}
-static void make_values(CuTest *tc)
+static void make_values(dAT)
{
apreq_value_t *v1, *v2;
apr_size_t len = 4;
@@ -138,41 +133,41 @@
strcpy(val, "bar");
v1 = apreq_make_value(p, name, len, val, len);
- CuAssertStrEquals(tc, name, v1->name);
- CuAssertIntEquals(tc, len, v1->size);
- CuAssertStrEquals(tc, val, v1->data);
+ AT_str_eq(v1->name, name);
+ AT_int_eq(v1->size, len);
+ AT_str_eq(v1->data, val);
v2 = apreq_copy_value(p, v1);
- CuAssertStrEquals(tc, name, v2->name);
- CuAssertIntEquals(tc, len, v2->size);
- CuAssertStrEquals(tc, val, v2->data);
+ AT_str_eq(v2->name, name);
+ AT_int_eq(v2->size, len);
+ AT_str_eq(v2->data, val);
}
-static void make_param(CuTest *tc)
+static void make_param(dAT)
{
- apreq_param_t *param, *result;
+ apreq_param_t *param, *decode;
apr_size_t nlen = 3, vlen = 11;
char *name = apr_palloc(p,nlen+1);
char *val = apr_palloc(p,vlen+1);
- char *encode = apr_palloc(p,vlen+nlen+1);
+ char *encode;
strcpy(name, "foo");
strcpy(val, "bar > alpha");
param = apreq_make_param(p, name, nlen, val, vlen);
- CuAssertStrEquals(tc, name, param->v.name);
- CuAssertIntEquals(tc, vlen, param->v.size);
- CuAssertStrEquals(tc, val, param->v.data);
+ AT_str_eq(param->v.name, name);
+ AT_int_eq(param->v.size, vlen);
+ AT_str_eq(param->v.data, val);
encode = apreq_encode_param(p, param);
- CuAssertStrEquals(tc, "foo=bar+%3e+alpha", encode);
+ AT_str_eq(encode, "foo=bar+%3e+alpha");
- result = apreq_decode_param(p, encode, nlen, vlen+2);
- CuAssertStrEquals(tc, name, result->v.name);
- CuAssertIntEquals(tc, vlen, result->v.size);
- CuAssertStrEquals(tc, val, result->v.data);
+ decode = apreq_decode_param(p, encode, nlen, vlen+2);
+ AT_str_eq(decode->v.name, name);
+ AT_int_eq(decode->v.size, vlen);
+ AT_str_eq(decode->v.data, val);
}
-static void quote_strings(CuTest *tc)
+static void quote_strings(dAT)
{
apr_size_t exp_len, res_len, res_quote_len;
char *res = apr_palloc(p,24);
@@ -187,20 +182,20 @@
for (i=0; i<4; i++) {
res_len = apreq_quote(res, arr[i], arr_len[i]);
- CuAssertIntEquals(tc, arr_quote_len[i], res_len);
- CuAssertStrNEquals(tc, arr_quote[i], res, res_len);
+ AT_int_eq(res_len, arr_quote_len[i]);
+ AT_mem_eq(res, arr_quote[i], res_len);
res_quote_len = apreq_quote_once(res_quote, res, res_len);
- CuAssertIntEquals(tc, res_len, res_quote_len);
- CuAssertStrNEquals(tc, res, res_quote, res_len);
+ AT_int_eq(res_quote_len, res_len);
+ AT_mem_eq(res_quote, res, res_len);
res_len = apreq_quote_once(res, arr[i], arr_len[i]);
exp_len = (i == 3) ? arr_len[i] : arr_quote_len[i];
exp = (i == 3) ? arr[i] : arr_quote[i];
- CuAssertIntEquals(tc, exp_len, res_len);
- CuAssertStrNEquals(tc, exp, res, exp_len);
+ AT_int_eq(res_len, exp_len);
+ AT_mem_eq(res, exp, exp_len);
}
}
-static void test_memmem(CuTest *tc)
+static void test_memmem(dAT)
{
char *hay = apr_palloc(p,29);
char *partial, *full;
@@ -208,35 +203,60 @@
strcpy(hay, "The fear of fear is fearful.");
partial = apreq_memmem(hay, hlen, "fear of fly", 11, APREQ_MATCH_PARTIAL);
- if (partial == NULL) CuAssertTrue(tc, 1);
+ AT_is_null(partial);
partial = apreq_memmem(hay, hlen, "fear ", 5, APREQ_MATCH_PARTIAL);
- CuAssertStrEquals(tc, "fear of fear is fearful.", partial);
+ AT_str_eq(partial, "fear of fear is fearful.");
partial = apreq_memmem(hay, hlen, "fear is", 7, APREQ_MATCH_PARTIAL);
- CuAssertStrEquals(tc, "fear is fearful.", partial);
+ AT_str_eq(partial, "fear is fearful.");
partial = apreq_memmem(hay, hlen, hay, hlen, APREQ_MATCH_PARTIAL);
- CuAssertStrEquals(tc, hay, partial);
+ AT_str_eq(partial, hay);
+
full = apreq_memmem(hay, hlen, "fear is", 7, APREQ_MATCH_FULL);
- if (full == NULL) CuAssertTrue(tc, 1);
+ AT_not_null(full);
partial = apreq_memmem(hay, hlen, "fear of fly", 11, APREQ_MATCH_FULL);
- if (partial == NULL) CuAssertTrue(tc, 1);
+ AT_is_null(partial);
full = apreq_memmem(hay, hlen, hay, hlen, APREQ_MATCH_FULL);
- CuAssertStrEquals(tc, hay, full);
+ AT_str_eq(full, hay);
}
-CuSuite *testparam(void)
+#define dT(func, plan) {#func, func, plan}
+
+int main(int argc, char *argv[])
{
- CuSuite *suite = CuSuiteNew("Param");
+ extern const apreq_env_t test_module;
+ extern apr_pool_t *p;
+ int i, plan = 0;
+ dAT;
+ at_test_t test_list [] = {
+ dT(request_make, 2),
+ dT(request_args_get, 8),
+ dT(params_as, 2),
+ dT(string_decoding_in_place, 8),
+ dT(header_attributes, 13),
+ dT(make_values, 6),
+ dT(make_param, 7),
+ dT(quote_strings, 24),
+ dT(test_memmem, 7),
+ };
+
+ apr_initialize();
+ atexit(apr_terminate);
+ apreq_env_module(&test_module);
+
+ apr_pool_create(&p, NULL);
+
+ AT = at_create(p, 0, at_report_stdout_make(p));
+ AT_trace_on();
+ for (i = 0; i < sizeof(test_list) / sizeof(at_test_t); ++i)
+ plan += test_list[i].plan;
+
+ AT_begin(plan);
+
+ for (i = 0; i < sizeof(test_list) / sizeof(at_test_t); ++i)
+ AT_run(&test_list[i]);
- SUITE_ADD_TEST(suite, request_make);
- SUITE_ADD_TEST(suite, request_args_get);
- SUITE_ADD_TEST(suite, params_as);
- SUITE_ADD_TEST(suite, string_decoding_in_place);
- SUITE_ADD_TEST(suite, header_attributes);
- SUITE_ADD_TEST(suite, make_values);
- SUITE_ADD_TEST(suite, quote_strings);
- SUITE_ADD_TEST(suite, make_param);
- SUITE_ADD_TEST(suite, test_memmem);
+ AT_end();
- return suite;
+ return 0;
}
Modified: httpd/apreq/trunk/t/parsers.c
URL:
http://svn.apache.org/viewcvs/httpd/apreq/trunk/t/parsers.c?view=diff&r1=153576&r2=153577
==============================================================================
--- httpd/apreq/trunk/t/parsers.c (original)
+++ httpd/apreq/trunk/t/parsers.c Sat Feb 12 15:04:35 2005
@@ -15,11 +15,11 @@
*/
#include "apreq_env.h"
-#include "test_apreq.h"
#include "apreq.h"
#include "apreq_params.h"
#include "apr_strings.h"
#include "apr_xml.h"
+#include "at.h"
#define CRLF "\015\012"
@@ -101,47 +101,46 @@
extern apr_bucket_brigade *bb;
extern apr_table_t *table;
+extern apr_pool_t *p;
-static void locate_default_parsers(CuTest *tc)
+static void locate_default_parsers(dAT)
{
apreq_request_t *req;
apreq_parser_t *parser;
req = apreq_request("application/x-www-form-urlencoded", "");
- CuAssertPtrNotNull(tc, req);
- CuAssertStrEquals(tc, APREQ_URL_ENCTYPE, apreq_enctype(req->env));
+ AT_not_null(req);
+ AT_str_eq(apreq_enctype(req->env), APREQ_URL_ENCTYPE);
parser = apreq_parser(req->env, NULL);
- CuAssertPtrNotNull(tc, parser);
- CuAssertStrEquals(tc, APREQ_URL_ENCTYPE, parser->enctype);
+ AT_not_null(parser);
+ AT_str_eq(parser->enctype, APREQ_URL_ENCTYPE);
req = apreq_request(APREQ_MFD_ENCTYPE
"; charset=\"iso-8859-1\"; boundary=\"AaB03x\"" ,"");
- CuAssertPtrNotNull(tc, req);
+ AT_not_null(req);
parser = apreq_parser(req->env, NULL);
- CuAssertPtrNotNull(tc, parser);
- CuAssertStrNEquals(tc, APREQ_MFD_ENCTYPE, parser->enctype,
- strlen(APREQ_MFD_ENCTYPE));
+ AT_not_null(parser);
+ AT_mem_eq(APREQ_MFD_ENCTYPE, parser->enctype, sizeof(APREQ_MFD_ENCTYPE)-1);
req = apreq_request("multipart/related; boundary=f93dcbA3; "
"type=application/xml; start=\"<[EMAIL PROTECTED]>\"","");
- CuAssertPtrNotNull(tc, req);
+ AT_not_null(req);
parser = apreq_parser(req->env, NULL);
- CuAssertPtrNotNull(tc, parser);
- CuAssertStrNEquals(tc, "multipart/related", parser->enctype,
- strlen("multipart/related"));
+ AT_not_null(parser);
+ AT_mem_eq("multipart/related", parser->enctype,
sizeof("multipart/related")-1);
}
-static void parse_urlencoded(CuTest *tc)
+static void parse_urlencoded(dAT)
{
const char *val;
apreq_request_t *req = apreq_request(APREQ_URL_ENCTYPE,"");
apr_status_t rv;
const char *enctype;
- CuAssertPtrNotNull(tc, req);
+ AT_not_null(req);
enctype = apreq_enctype(req->env);
- CuAssertStrEquals(tc, APREQ_URL_ENCTYPE, enctype);
+ AT_str_eq(APREQ_URL_ENCTYPE, enctype);
bb = apr_brigade_create(p, apr_bucket_alloc_create(p));
@@ -150,7 +149,7 @@
bb->bucket_alloc));
rv = apreq_parse_request(req,bb);
- CuAssertIntEquals(tc, APR_INCOMPLETE, rv);
+ AT_int_eq(APR_INCOMPLETE, rv);
APR_BRIGADE_INSERT_HEAD(bb,
apr_bucket_immortal_create("blast",5,
@@ -160,19 +159,19 @@
rv = apreq_parse_request(req,bb);
- CuAssertIntEquals(tc, APR_SUCCESS, rv);
+ AT_int_eq(APR_SUCCESS, rv);
val = apr_table_get(req->body,"alpha");
- CuAssertStrEquals(tc, "one", val);
+ AT_str_eq("one", val);
val = apr_table_get(req->body,"beta");
- CuAssertStrEquals(tc, "two", val);
+ AT_str_eq("two", val);
val = apr_table_get(req->body,"omega");
- CuAssertStrEquals(tc, "last+last", val);
+ AT_str_eq("last+last", val);
}
-static void parse_multipart(CuTest *tc)
+static void parse_multipart(dAT)
{
apr_status_t rv;
apr_size_t i, j;
@@ -184,15 +183,23 @@
apreq_request_t *req = apreq_request(APREQ_MFD_ENCTYPE
"; charset=\"iso-8859-1\"; boundary=\"AaB03x\"" ,"");
- CuAssertPtrNotNull(tc, req);
- CuAssertStrEquals(tc, req->env, apreq_env_content_type(req->env));
+ AT_not_null(req);
+ AT_str_eq(req->env, apreq_env_content_type(req->env));
enctype = apreq_enctype(req->env);
- CuAssertStrEquals(tc, APREQ_MFD_ENCTYPE, enctype);
+ AT_str_eq(APREQ_MFD_ENCTYPE, enctype);
ba = apr_bucket_alloc_create(p);
bb = apr_brigade_create(p, ba);
+ /* AT_localize checks the inner loop tests itself
+ * (and interprets any such failures as being fatal),
+ * because doing IO to Test::Harness is just too slow
+ * when this many (~1M) tests are involved.
+ */
+
+ AT_localize(p);
+
for (i = 0; i <= strlen(form_data); ++i) {
const char *val;
apr_size_t len;
@@ -205,7 +212,6 @@
apr_bucket_brigade *tail;
APR_BRIGADE_INSERT_HEAD(bb, e);
APR_BRIGADE_INSERT_TAIL(bb,
apr_bucket_eos_create(bb->bucket_alloc));
-
/* Split e into three buckets */
apr_bucket_split(e, j);
f = APR_BUCKET_NEXT(e);
@@ -219,28 +225,28 @@
req->parser = NULL;
req->body_status = APR_EINIT;
rv = apreq_parse_request(req,bb);
- CuAssertIntEquals(tc, (j < strlen(form_data)) ? APR_INCOMPLETE :
APR_SUCCESS, rv);
+ AT_int_eq(rv, (j < strlen(form_data)) ? APR_INCOMPLETE :
APR_SUCCESS);
rv = apreq_parse_request(req, tail);
- CuAssertIntEquals(tc, APR_SUCCESS, rv);
- CuAssertPtrNotNull(tc, req->body);
- CuAssertIntEquals(tc, 2, apr_table_elts(req->body)->nelts);
+ AT_int_eq(rv, APR_SUCCESS);
+ AT_not_null(req->body);
+ AT_int_eq(apr_table_elts(req->body)->nelts, 2);
val = apr_table_get(req->body,"field1");
- CuAssertStrEquals(tc, "Joe owes =80100.", val);
+ AT_str_eq("Joe owes =80100.", val);
t = apreq_value_to_param(apreq_strtoval(val))->info;
val = apr_table_get(t, "content-transfer-encoding");
- CuAssertStrEquals(tc,"quoted-printable", val);
+ AT_str_eq("quoted-printable", val);
val = apr_table_get(req->body, "pics");
- CuAssertStrEquals(tc, "file1.txt", val);
+ AT_str_eq("file1.txt", val);
t = apreq_value_to_param(apreq_strtoval(val))->info;
bb = apreq_value_to_param(apreq_strtoval(val))->bb;
apr_brigade_pflatten(bb, (char **)&val, &len, p);
- CuAssertIntEquals(tc,strlen("... contents of file1.txt ..." CRLF),
len);
- CuAssertStrNEquals(tc,"... contents of file1.txt ..." CRLF, val,
len);
+ AT_int_eq(strlen("... contents of file1.txt ..." CRLF), len);
+ AT_mem_eq("... contents of file1.txt ..." CRLF, val, len);
val = apr_table_get(t, "content-type");
- CuAssertStrEquals(tc, "text/plain", val);
+ AT_str_eq("text/plain", val);
apr_brigade_cleanup(bb);
}
apr_bucket_alloc_destroy(ba);
@@ -248,7 +254,7 @@
}
}
-static void parse_disable_uploads(CuTest *tc)
+static void parse_disable_uploads(dAT)
{
const char *val;
apr_table_t *t;
@@ -261,8 +267,8 @@
strlen(form_data),
bb->bucket_alloc);
- CuAssertPtrNotNull(tc, req);
- CuAssertStrEquals(tc, req->env, apreq_env_content_type(req->env));
+ AT_not_null(req);
+ AT_str_eq(req->env, apreq_env_content_type(req->env));
APR_BRIGADE_INSERT_HEAD(bb, e);
APR_BRIGADE_INSERT_TAIL(bb, apr_bucket_eos_create(bb->bucket_alloc));
@@ -272,21 +278,21 @@
apreq_hook_disable_uploads, NULL, NULL));
rv = apreq_parse_request(req,bb);
- CuAssertIntEquals(tc, APR_EGENERAL, rv);
- CuAssertPtrNotNull(tc, req->body);
- CuAssertIntEquals(tc, 1, apr_table_elts(req->body)->nelts);
+ AT_int_eq(APR_EGENERAL, rv);
+ AT_not_null(req->body);
+ AT_int_eq(apr_table_elts(req->body)->nelts, 1);
val = apr_table_get(req->body,"field1");
- CuAssertStrEquals(tc, "Joe owes =80100.", val);
+ AT_str_eq("Joe owes =80100.", val);
t = apreq_value_to_param(apreq_strtoval(val))->info;
val = apr_table_get(t, "content-transfer-encoding");
- CuAssertStrEquals(tc,"quoted-printable", val);
+ AT_str_eq("quoted-printable", val);
val = apr_table_get(req->body, "pics");
- CuAssertPtrEquals(tc, NULL, val);
+ AT_is_null(val);
}
-static void parse_generic(CuTest *tc)
+static void parse_generic(dAT)
{
const char *val;
apr_size_t vlen;
@@ -299,7 +305,7 @@
strlen(xml_data),
bb->bucket_alloc);
- CuAssertPtrNotNull(tc, req);
+ AT_not_null(req);
APR_BRIGADE_INSERT_HEAD(bb, e);
APR_BRIGADE_INSERT_TAIL(bb, apr_bucket_eos_create(bb->bucket_alloc));
@@ -307,16 +313,16 @@
req->parser = apreq_make_parser(p, APREQ_XML_ENCTYPE,
apreq_parse_generic, NULL, NULL);
rv = apreq_parse_request(req,bb);
- CuAssertIntEquals(tc, APR_SUCCESS, rv);
+ AT_int_eq(APR_SUCCESS, rv);
dummy = *(apreq_param_t **)req->parser->ctx;
- CuAssertPtrNotNull(tc, dummy);
+ AT_not_null(dummy);
apr_brigade_pflatten(dummy->bb, (char **)&val, &vlen, p);
- CuAssertIntEquals(tc, strlen(xml_data), vlen);
- CuAssertStrNEquals(tc, xml_data, val, vlen);
+ AT_int_eq(strlen(xml_data), vlen);
+ AT_mem_eq(xml_data, val, vlen);
}
-static void hook_discard(CuTest *tc)
+static void hook_discard(dAT)
{
apr_status_t rv;
apreq_param_t *dummy;
@@ -327,7 +333,7 @@
strlen(xml_data),
bb->bucket_alloc);
- CuAssertPtrNotNull(tc, req);
+ AT_not_null(req);
APR_BRIGADE_INSERT_HEAD(bb, e);
APR_BRIGADE_INSERT_TAIL(bb, apr_bucket_eos_create(bb->bucket_alloc));
@@ -337,16 +343,16 @@
apreq_make_hook(p,
apreq_hook_discard_brigade,
NULL,NULL), NULL);
rv = apreq_parse_request(req,bb);
- CuAssertIntEquals(tc, APR_SUCCESS, rv);
+ AT_int_eq(rv, APR_SUCCESS);
dummy = *(apreq_param_t **)req->parser->ctx;
- CuAssertPtrNotNull(tc, dummy);
- CuAssertPtrNotNull(tc, dummy->bb);
- CuAssertTrue(tc, APR_BRIGADE_EMPTY(dummy->bb));
+ AT_not_null(dummy);
+ AT_not_null(dummy->bb);
+ AT_ok(APR_BRIGADE_EMPTY(dummy->bb), "nothing in dummy brigade");
}
-static void parse_related(CuTest *tc)
+static void parse_related(dAT)
{
char ct[] = "multipart/related; boundary=f93dcbA3; "
"type=application/xml; start=\"<[EMAIL PROTECTED]>\"";
@@ -366,7 +372,7 @@
strlen(rel_data),
bb->bucket_alloc);
- CuAssertPtrNotNull(tc, req);
+ AT_not_null(req);
APR_BRIGADE_INSERT_HEAD(bb, e);
APR_BRIGADE_INSERT_TAIL(bb, apr_bucket_eos_create(bb->bucket_alloc));
xml_hook = apreq_make_hook(p, apreq_hook_apr_xml_parser, NULL, NULL);
@@ -375,38 +381,38 @@
req->parser = apreq_make_parser(p, ct,
apreq_parse_multipart, xml_hook, NULL);
rv = apreq_parse_request(req,bb);
- CuAssertIntEquals(tc, APR_SUCCESS, rv);
- CuAssertPtrNotNull(tc, req->body);
+ AT_int_eq(rv, APR_SUCCESS);
+ AT_not_null(req->body);
param = apreq_param(req, "<[EMAIL PROTECTED]>");
- CuAssertPtrNotNull(tc, param);
- CuAssertPtrNotNull(tc, param->info);
+ AT_not_null(param);
+ AT_not_null(param->info);
val = apr_table_get(param->info, "Content-Length");
- CuAssertStrEquals(tc, "400", val);
- CuAssertPtrNotNull(tc, param->bb);
+ AT_str_eq(val, "400");
+ AT_not_null(param->bb);
apr_brigade_pflatten(param->bb, (char **)&val, &vlen, p);
- CuAssertIntEquals(tc, 400, vlen);
- CuAssertStrNEquals(tc,rel_data + 122, val, 400);
+ AT_int_eq(vlen, 400);
+ AT_mem_eq(val, rel_data + 122, 400);
doc = *(apr_xml_doc **)xml_hook->ctx;
apr_xml_to_text(p, doc->root, APR_XML_X2T_FULL,
doc->namespaces, &ns_map, &val, &vlen);
- CuAssertIntEquals(tc, 400 - 22, vlen);
- CuAssertStrNEquals(tc, rel_data + 122 + 23, val, 400 - 23);
+ AT_int_eq(vlen, 400 - 22);
+ AT_mem_eq(val, rel_data + 122 + 23, 400 - 23);
param = apreq_param(req, "<[EMAIL PROTECTED]>");
- CuAssertPtrNotNull(tc, param);
- CuAssertPtrNotNull(tc, param->bb);
+ AT_not_null(param);
+ AT_not_null(param->bb);
apr_brigade_pflatten(param->bb, (char **)&val, &vlen, p);
- CuAssertIntEquals(tc, dlen, vlen);
- CuAssertStrNEquals(tc, data, val, vlen);
+ AT_int_eq(dlen, vlen);
+ AT_mem_eq(data, val, vlen);
param = apreq_param(req, "<[EMAIL PROTECTED]>");
- CuAssertPtrNotNull(tc, param);
- CuAssertPtrNotNull(tc, param->bb);
+ AT_not_null(param);
+ AT_not_null(param->bb);
apr_brigade_pflatten(param->bb, (char **)&val, &vlen, p);
- CuAssertIntEquals(tc, dlen, vlen);
- CuAssertStrNEquals(tc, data, val, vlen);
+ AT_int_eq(dlen, vlen);
+ AT_mem_eq(data, val, vlen);
}
typedef struct {
@@ -415,7 +421,7 @@
} array_elt;
-static void parse_mixed(CuTest *tc)
+static void parse_mixed(dAT)
{
const char *val;
apr_size_t vlen;
@@ -431,56 +437,85 @@
strlen(mix_data),
bb->bucket_alloc);
- CuAssertPtrNotNull(tc, req);
+ AT_not_null(req);
APR_BRIGADE_INSERT_HEAD(bb, e);
APR_BRIGADE_INSERT_TAIL(bb, apr_bucket_eos_create(bb->bucket_alloc));
rv = apreq_parse_request(req,bb);
- CuAssertIntEquals(tc, APR_SUCCESS, rv);
+ AT_int_eq(APR_SUCCESS, rv);
param = apreq_param(req, "submit-name");
- CuAssertPtrNotNull(tc, param);
- CuAssertStrEquals(tc, "Larry", param->v.data);
+ AT_not_null(param);
+ AT_str_eq("Larry", param->v.data);
val = apr_table_get(req->body,"field1");
- CuAssertStrEquals(tc, "Joe owes =80100.", val);
+ AT_str_eq("Joe owes =80100.", val);
param = apreq_param(req, "files");
- CuAssertPtrNotNull(tc, param);
- CuAssertStrEquals(tc, "file1.txt", param->v.data);
+ AT_not_null(param);
+ AT_str_eq("file1.txt", param->v.data);
- CuAssertPtrNotNull(tc, param->bb);
+ AT_not_null(param->bb);
apr_brigade_pflatten(param->bb, (char **)&val, &vlen, p);
- CuAssertIntEquals(tc, strlen("... contents of file1.txt ..."), vlen);
- CuAssertStrNEquals(tc, "... contents of file1.txt ...", val, vlen);
+ AT_int_eq(strlen("... contents of file1.txt ..."), vlen);
+ AT_mem_eq("... contents of file1.txt ...", val, vlen);
arr = apr_table_elts(req->body);
- CuAssertIntEquals(tc, 4, arr->nelts);
+ AT_int_eq(4, arr->nelts);
elt = (array_elt *)&arr->elts[2 * arr->elt_size];
- CuAssertStrEquals(tc, "files", elt->key);
- CuAssertStrEquals(tc, "file2.gif", elt->val);
+ AT_str_eq("files", elt->key);
+ AT_str_eq("file2.gif", elt->val);
param = apreq_value_to_param(apreq_strtoval(elt->val));
- CuAssertPtrNotNull(tc, param->bb);
+ AT_not_null(param->bb);
apr_brigade_pflatten(param->bb, (char **)&val, &vlen, p);
- CuAssertIntEquals(tc, strlen("...contents of file2.gif..."), vlen);
- CuAssertStrNEquals(tc, "...contents of file2.gif...", val, vlen);
+ AT_int_eq(strlen("...contents of file2.gif..."), vlen);
+ AT_mem_eq("...contents of file2.gif...", val, vlen);
}
-CuSuite *testparser(void)
+#define dT(func, plan) {#func, func, plan}
+
+int main(int argc, char *argv[])
{
- CuSuite *suite = CuSuiteNew("Parsers");
- SUITE_ADD_TEST(suite, locate_default_parsers);
- SUITE_ADD_TEST(suite, parse_urlencoded);
- SUITE_ADD_TEST(suite, parse_multipart);
- SUITE_ADD_TEST(suite, parse_disable_uploads);
- SUITE_ADD_TEST(suite, parse_generic);
- SUITE_ADD_TEST(suite, parse_related);
- SUITE_ADD_TEST(suite, parse_mixed);
- SUITE_ADD_TEST(suite, hook_discard);
- return suite;
+ extern const apreq_env_t test_module;
+ extern apr_pool_t *p;
+ apr_pool_t *test_pool;
+ int i, plan = 0;
+ dAT;
+ at_test_t test_list [] = {
+ dT(locate_default_parsers, 10),
+ dT(parse_urlencoded, 7),
+ dT(parse_multipart, 4 * sizeof form_data),
+ dT(parse_disable_uploads, 8),
+ dT(parse_generic, 5),
+ dT(hook_discard, 5),
+ dT(parse_related, 19),
+ dT(parse_mixed, 16)
+ };
+
+ apr_initialize();
+ atexit(apr_terminate);
+ apreq_env_module(&test_module);
+
+ apr_pool_create(&p, NULL);
+ apr_pool_create(&test_pool, NULL);
+
+ AT = at_create(test_pool, 0, at_report_stdout_make(test_pool));
+// AT_trace_on();
+ for (i = 0; i < sizeof(test_list) / sizeof(at_test_t); ++i)
+ plan += test_list[i].plan;
+
+ AT_begin(plan);
+
+ for (i = 0; i < sizeof(test_list) / sizeof(at_test_t); ++i)
+ AT_run(&test_list[i]);
+
+ AT_end();
+
+ return 0;
}
+
Modified: httpd/apreq/trunk/t/test_apreq.h
URL:
http://svn.apache.org/viewcvs/httpd/apreq/trunk/t/test_apreq.h?view=diff&r1=153576&r2=153577
==============================================================================
--- httpd/apreq/trunk/t/test_apreq.h (original)
+++ httpd/apreq/trunk/t/test_apreq.h Sat Feb 12 15:04:35 2005
@@ -16,7 +16,7 @@
#ifndef APREQ_TEST_INCLUDES
#define APREQ_TEST_INCLUDES
-
+#include "at.h"
#include "CuTest.h"
#include "apr_pools.h"
#ifndef apr_table_nelts
@@ -41,5 +41,10 @@
* for RV and CONTEXT message. */
void apr_assert_success(CuTest* tc, const char *context, apr_status_t rv);
+AT_DECLARE_TEST(jar_make);
+AT_DECLARE_TEST(jar_get);
+AT_DECLARE_TEST(netscape_cookie);
+AT_DECLARE_TEST(rfc_cookie);
+AT_DECLARE_TEST(ua_version);
#endif /* APR_TEST_INCLUDES */
Added: httpd/apreq/trunk/t/test_env.c
URL:
http://svn.apache.org/viewcvs/httpd/apreq/trunk/t/test_env.c?view=auto&rev=153577
==============================================================================
--- httpd/apreq/trunk/t/test_env.c (added)
+++ httpd/apreq/trunk/t/test_env.c Sat Feb 12 15:04:35 2005
@@ -0,0 +1,141 @@
+/*
+** Copyright 2003-2004 The Apache Software Foundation
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "apreq_env.h"
+#include "apr_strings.h"
+
+apr_pool_t *p;
+
+/* rigged environent for unit tests */
+
+#define APREQ_MODULE_NAME "TEST"
+#define APREQ_MODULE_MAGIC_NUMBER 20040324
+
+#define CRLF "\015\012"
+
+apr_bucket_brigade *bb;
+apr_table_t *table;
+
+static apr_pool_t *test_pool(void *env)
+{
+ return p;
+}
+
+static apr_status_t bucket_alloc_cleanup(void *data)
+{
+ apr_bucket_alloc_t *ba = data;
+ apr_bucket_alloc_destroy(ba);
+ return APR_SUCCESS;
+}
+
+static apr_bucket_alloc_t *test_bucket_alloc(void *env)
+{
+ apr_bucket_alloc_t *ba = apr_bucket_alloc_create(p);
+ apr_pool_cleanup_register(p, ba, bucket_alloc_cleanup, NULL);
+ return ba;
+}
+
+static const char *test_header_in(void *env, const char *name)
+{
+ return env;
+}
+
+static apr_status_t test_header_out(void *env,
+ const char *name,
+ char *value)
+{
+ return printf("%s: %s" CRLF, name, value) > 0 ? APR_SUCCESS : APR_EGENERAL;
+}
+
+static const char *test_query_string(void *env)
+{
+ return env;
+}
+
+static apreq_jar_t *test_jar(void *env, apreq_jar_t *jar)
+{
+ return NULL;
+}
+
+static apreq_request_t *test_request(void *env, apreq_request_t *req)
+{
+ return NULL;
+}
+
+static void test_log(const char *file, int line, int level,
+ apr_status_t status, void *env, const char *fmt,
+ va_list vp)
+{
+ char buf[256];
+ if (level < APREQ_LOG_ERR)
+ fprintf(stderr, "[%s(%d)]%s (%s)\n", file, line,
apr_strerror(status,buf,255), apr_pvsprintf(p,fmt,vp));
+}
+
+static apr_status_t test_read(void *env, apr_read_type_e block,
+ apr_off_t bytes)
+{
+ return APR_ENOTIMPL;
+}
+
+static const char *test_temp_dir(void *env, const char *path)
+{
+ static const char *temp_dir;
+ if (path != NULL) {
+ const char *rv = temp_dir;
+ temp_dir = apr_pstrdup(p, path);
+ return rv;
+ }
+ if (temp_dir == NULL) {
+ if (apr_temp_dir_get(&temp_dir, p) != APR_SUCCESS)
+ temp_dir = NULL;
+ }
+
+ return temp_dir;
+}
+
+
+static apr_off_t test_max_body(void *env, apr_off_t bytes)
+{
+ static apr_off_t max_body = -1;
+ if (bytes >= 0) {
+ apr_off_t rv = max_body;
+ max_body = bytes;
+ return rv;
+ }
+ return max_body;
+}
+
+
+static apr_ssize_t test_max_brigade(void *env, apr_ssize_t bytes)
+{
+ static apr_ssize_t max_brigade = -1;
+
+ if (bytes >= 0) {
+ apr_ssize_t rv = max_brigade;
+ max_brigade = bytes;
+ return rv;
+ }
+ return max_brigade;
+}
+
+
+
+APREQ_ENV_MODULE(test, APREQ_MODULE_NAME,
+ APREQ_MODULE_MAGIC_NUMBER);
+
Modified: httpd/apreq/trunk/t/version.c
URL:
http://svn.apache.org/viewcvs/httpd/apreq/trunk/t/version.c?view=diff&r1=153576&r2=153577
==============================================================================
--- httpd/apreq/trunk/t/version.c (original)
+++ httpd/apreq/trunk/t/version.c Sat Feb 12 15:04:35 2005
@@ -14,49 +14,58 @@
** limitations under the License.
*/
+#include "apreq_env.h"
#include "apreq_version.h"
-#include "test_apreq.h"
-#include "apreq.h"
+#include "at.h"
-apr_version_t v;
-const char *vstring;
-
-static void version_string(CuTest *tc)
+static void version_string(dAT)
{
- vstring = apreq_version_string();
- CuAssertPtrNotNull(tc, vstring);
- CuAssertStrEquals(tc, APREQ_VERSION_STRING, vstring);
+ const char *vstring = apreq_version_string();
+ AT_not_null(vstring);
+ AT_str_eq(vstring, APREQ_VERSION_STRING);
}
-static void version_major(CuTest *tc)
+static void version_type(dAT)
{
+ apr_version_t v;
apreq_version(&v);
- CuAssertIntEquals(tc, APREQ_MAJOR_VERSION, v.major);
-}
-static void version_minor(CuTest *tc)
-{
- CuAssertIntEquals(tc, APREQ_MINOR_VERSION, v.minor);
-}
-static void version_patch(CuTest *tc)
-{
- CuAssertIntEquals(tc, APREQ_PATCH_VERSION, v.patch);
-}
-static void version_is_dev(CuTest *tc)
-{
+ AT_int_eq(v.major, APREQ_MAJOR_VERSION);
+ AT_int_eq(v.minor, APREQ_MINOR_VERSION);
+ AT_int_eq(v.patch, APREQ_PATCH_VERSION);
#ifdef APREQ_IS_DEV_VERSION
- CuAssertIntEquals(tc, 1, v.is_dev);
+ AT_int_eq(v.is_dev, 1);
#else
- CuAssertIntEquals(tc, 0, v.is_dev);
+ AT_int_eq(v.is_dev, 0);
#endif
}
-CuSuite *testversion(void)
+int main(int argc, char *argv[])
{
- CuSuite *suite = CuSuiteNew("Version");
- SUITE_ADD_TEST(suite, version_string);
- SUITE_ADD_TEST(suite, version_major);
- SUITE_ADD_TEST(suite, version_minor);
- SUITE_ADD_TEST(suite, version_patch);
- SUITE_ADD_TEST(suite, version_is_dev);
- return suite;
-}
+ extern const apreq_env_t test_module;
+ extern apr_pool_t *p;
+ int i, plan = 0;
+ dAT;
+ at_test_t test_list [] = {
+ {"version_string", version_string, 2, "1"},
+ {"version_type", version_type, 4}
+ };
+ apr_initialize();
+ atexit(apr_terminate);
+ apreq_env_module(&test_module);
+
+ apr_pool_create(&p, NULL);
+
+ AT = at_create(p, 0, at_report_stdout_make(p));
+
+ for (i = 0; i < sizeof(test_list) / sizeof(at_test_t); ++i)
+ plan += test_list[i].plan;
+
+ AT_begin(plan);
+
+ for (i = 0; i < sizeof(test_list) / sizeof(at_test_t); ++i)
+ AT_run(&test_list[i]);
+
+ AT_end();
+
+ return 0;
+}