summaryrefslogtreecommitdiff
path: root/srclib
diff options
context:
space:
mode:
authorPhilip M. Gollucci <pgollucci@apache.org>2011-11-10 18:05:46 +0000
committerPhilip M. Gollucci <pgollucci@apache.org>2011-11-10 18:05:46 +0000
commit9ba9dfc5ff9bb1e912f3bec38a3b836bdefaa6ca (patch)
tree6308f0593a407c748a9f874a5701ee379d214d6c /srclib
parentc1902d9d282a57c6af2ab2265d4fa378b7549892 (diff)
downloadhttpd-9ba9dfc5ff9bb1e912f3bec38a3b836bdefaa6ca.tar.gz
drop tests and automake code for now
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1200455 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'srclib')
-rw-r--r--srclib/libapreq/Makefile.am42
-rw-r--r--srclib/libapreq/t/Makefile.am19
-rw-r--r--srclib/libapreq/t/at.c394
-rw-r--r--srclib/libapreq/t/at.h301
-rw-r--r--srclib/libapreq/t/cookie.c246
-rw-r--r--srclib/libapreq/t/error.c93
-rw-r--r--srclib/libapreq/t/params.c229
-rw-r--r--srclib/libapreq/t/parsers.c555
-rw-r--r--srclib/libapreq/t/util.c340
-rw-r--r--srclib/libapreq/t/version.c69
10 files changed, 0 insertions, 2288 deletions
diff --git a/srclib/libapreq/Makefile.am b/srclib/libapreq/Makefile.am
deleted file mode 100644
index 122e52238b..0000000000
--- a/srclib/libapreq/Makefile.am
+++ /dev/null
@@ -1,42 +0,0 @@
-EXTRA_DIST = t
-AM_CPPFLAGS = @APR_INCLUDES@
-BUILT_SOURCES = @APR_LA@ @APU_LA@
-lib_LTLIBRARIES = libapreq2.la
-libapreq2_la_SOURCES = util.c version.c cookie.c param.c parser.c \
- parser_urlencoded.c parser_header.c parser_multipart.c \
- module.c module_custom.c module_cgi.c error.c
-libapreq2_la_LDFLAGS = -version-info @APREQ_LIBTOOL_VERSION@ @APR_LTFLAGS@ @APR_LIBS@
-
-test: all
- cd t; $(MAKE) test
-
-if ENABLE_PROFILE
-
-AM_CFLAGS= -pg -fprofile-arcs -ftest-coverage
-
-clean-local:
- -rm *.bb *.bbg *.da *.gcov
- cd t; $(MAKE) clean
-else
-
-clean-local:
- cd t; $(MAKE) clean
-endif
-
-distclean-am: clean-am distclean-compile distclean-generic \
- distclean-tags
- cd t; $(MAKE) distclean
-
-if BUILD_APR
-
-@APR_LA@:
- cd `@APR_CONFIG@ --srcdir` && $(MAKE)
-
-endif
-
-if BUILD_APU
-
-@APU_LA@: @APR_LA@
- cd `@APU_CONFIG@ --srcdir` && $(MAKE)
-
-endif
diff --git a/srclib/libapreq/t/Makefile.am b/srclib/libapreq/t/Makefile.am
deleted file mode 100644
index 8b2d6f55a7..0000000000
--- a/srclib/libapreq/t/Makefile.am
+++ /dev/null
@@ -1,19 +0,0 @@
-AM_CPPFLAGS = @APR_INCLUDES@
-AM_LDFLAGS = `@APREQ_CONFIG@ --link-libtool --libs` @APR_LTFLAGS@
-noinst_LIBRARIES = libapache_test.a
-libapache_test_a_SOURCES = at.h at.c
-
-check_PROGRAMS = version cookie params parsers error util
-LDADD = libapache_test.a
-
-check_SCRIPTS = version.t cookie.t params.t parsers.t error.t util.t
-TESTS = $(check_SCRIPTS)
-TESTS_ENVIRONMENT = @PERL@ -MTest::Harness -e 'runtests(@ARGV)'
-CLEANFILES = $(check_PROGRAMS) $(check_SCRIPTS)
-
-%.t: %
- echo "#!perl" > $@
- echo "exec './$*'" >> $@
-
-test: $(check_SCRIPTS)
- $(TESTS_ENVIRONMENT) $(check_SCRIPTS)
diff --git a/srclib/libapreq/t/at.c b/srclib/libapreq/t/at.c
deleted file mode 100644
index 19e59cbb93..0000000000
--- a/srclib/libapreq/t/at.c
+++ /dev/null
@@ -1,394 +0,0 @@
-/*
-** Licensed to the Apache Software Foundation (ASF) under one or more
-** contributor license agreements. See the NOTICE file distributed with
-** this work for additional information regarding copyright ownership.
-** The ASF licenses this file to You 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 "at.h"
-#include <errno.h>
-#include <ctype.h>
-
-#define AT_SUCCESS 0
-#define AT_EGENERAL 14
-#define min(a, b) ((a < b) ? a : b)
-
-int at_begin(at_t *t, int total)
-{
- char buf[32];
- at_snprintf(buf, 32, "1..%d", total);
- return at_report(t, buf);
-}
-
-static int 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)
-{
- test_cleanup(t);
- free(t);
-}
-
-int at_comment(at_t *t, const char *fmt, va_list vp)
-{
- int s;
- char buf[256], *b = buf + 2;
- char *end;
- int rv;
- rv = at_vsnprintf(b, 250, fmt, vp);
-
- if (rv <= 0)
- return EINVAL;
-
-
- end = b + min(rv, 250);
-
- buf[0] = '#';
- buf[1] = ' ';
-
- if (rv >= 250) {
- end[-1] = '.';
- *end++ = '.';
- *end++ = '.';
- *end++ = '\n';
- *end = 0;
- }
- else if (end[-1] != '\n') {
- *end++ = '\n';
- *end = 0;
- }
-
- b = buf;
- while (1) {
- char *eol;
-
- eol = strchr(b + 2, '\n');
- *eol = 0;
- s = at_report(t, b);
- if (s != AT_SUCCESS || eol == end - 1)
- 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_TODO(t->flags))
- is_todo = 1;
-
- if (AT_FLAG_CONCISE(t->flags))
- format[9] = '\0';
- else if (is_ok && ! is_todo && !AT_FLAG_TRACE(t->flags))
- format[14] = '\0';
- else if (is_fatal && ! is_ok)
- comment = "fatal";
- else
- comment = is_todo ? "todo" : is_skip ? "skip" : "at";
-
- rv = at_snprintf(buf, 256, fmt, t->current + t->prior,
- label, comment, file, line, t->current, t->name);
-
- if (rv <= 0)
- exit(-1);
-
- end = buf + min(rv, 250);
-
- if (rv >= 250) {
- *end++ = '.';
- *end++ = '.';
- *end++ = '.';
- *end = '\0';
- }
-
- if (memchr(buf, '\n', rv) != NULL || at_report(t, buf) != AT_SUCCESS)
- exit(-1);
-
- if (!is_ok && is_fatal) {
- while (t->current++ < t->plan) {
- at_snprintf(buf, 256, "not ok %d # skipped: aborting test %s",
- t->prior + t->current, t->name);
- at_report(t, buf);
- }
- longjmp(*t->abort, 0);
- }
-}
-
-struct at_report_file {
- at_report_t module;
- FILE *file;
-};
-
-static int at_report_file_write(at_report_t *ctx, const char *msg)
-{
- struct at_report_file *r = (struct at_report_file *)ctx;
- FILE *f = r->file;
- size_t len = strlen(msg);
- size_t bytes_written;
- int status;
-
- bytes_written = fwrite(msg, sizeof(char), len, f);
- if (bytes_written != len)
- return errno;
-
- status = putc('\n', f);
- if (status == EOF)
- return errno;
-
- return fflush(f);
-}
-
-at_report_t *at_report_file_make(FILE *f)
-{
- struct at_report_file *r = malloc(sizeof *r);
- r->module.func = at_report_file_write;
- r->file = f;
- return &r->module;
-}
-
-void at_report_file_cleanup(at_report_t *r)
-{
- free(r);
-}
-
-struct at_report_local {
- at_report_t module;
- at_t *t;
- at_report_t *saved_report;
- const int *saved_fatal;
- const int *saved_skip;
- const int *saved_todo;
- int dummy_fatal;
- char *file;
- int line;
- int passed;
-};
-
-static int report_local_cleanup(void *data)
-{
- struct at_report_local *q = data;
- dAT = q->t;
- char label[32];
-
- at_snprintf(label, 32, "collected %d passing tests", q->passed);
-
- AT->report = q->saved_report;
- AT->fatal = q->saved_fatal;
- AT->skip = q->saved_skip;
- AT->todo = q->saved_todo;
-
- at_ok(q->t, 1, label, q->file, q->line);
-
- free(q->file);
- free(q);
-
- return AT_SUCCESS;
-}
-
-void at_report_delocalize(at_t *AT) {
- report_local_cleanup(AT->report);
-}
-
-static int at_report_local_write(at_report_t *ctx, const char *msg)
-{
- char buf[256];
- 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);
- report_local_cleanup(q);
- while (AT->current++ < AT->plan) {
- at_snprintf(buf, 256, "not ok %d # skipped: aborting test %s",
- AT->prior + AT->current, AT->name);
- at_report(AT, buf);
- }
- longjmp(*AT->abort, 0);
- }
- else if (strncmp(msg, "ok", 2) == 0) {
- AT->current--;
- q->passed++;
- }
- return AT_SUCCESS;
-}
-
-void at_report_local(at_t *AT, const char *file, int line)
-{
- struct at_report_local *q = malloc(sizeof *q);
- size_t len;
-
- q->module.func = at_report_local_write;
- q->t = AT;
- q->saved_report = AT->report;
- q->saved_fatal = AT->fatal;
- q->saved_skip = AT->skip;
- q->saved_todo = AT->todo;
- q->dummy_fatal = 0;
- q->line = line;
- q->passed = 0;
-
- len = strlen(file) + 1;
- q->file = (char*)malloc(len);
- memcpy(q->file, file, len);
-
- AT->fatal = AT->skip = AT->todo = &q->dummy_fatal;
- AT->report = &q->module;
-
- if (*q->saved_fatal == AT->current + 1)
- q->saved_fatal++;
-
-}
-
-at_t *at_create(unsigned char flags, at_report_t *report)
-{
- at_t *t = calloc(sizeof *t, 1);
- t->flags = flags;
- t->report = report;
- return t;
-}
-
-static int* at_list(const char *spec)
-{
- int prev, current = 0, count = 0, idx = 0, *elts;
- const char *start = spec;
-
- do {
- while (*spec && !isdigit((unsigned char)*spec))
- ++spec;
- prev = current;
- current = (int)strtol(spec, (char **)(void *)&spec, 10);
- ++count;
-
- } while (prev <= current);
-
- elts = malloc(++count * sizeof *elts);
- spec = start;
- current = 0;
-
- do {
- while (*spec && !isdigit((unsigned char)*spec))
- ++spec;
- prev = current;
- current = (int)strtol(spec, (char **)(void *)&spec, 10);
- elts[idx++] = current;
-
- } while (prev <= current);
-
- elts[idx] = 0; /* sentinel */
-
- return elts;
-}
-
-#define at_free_lists do { if (flist) free((void *)flist); \
- if (slist) free((void *)slist); \
- if (tlist) free((void *)tlist); } while (0)
-
-int at_run(at_t *AT, const at_test_t *test)
-{
- int dummy = 0;
- const int *flist = NULL, *slist = NULL, *tlist = NULL;
- jmp_buf j;
-
- AT->current = 0;
- AT->prior += AT->plan;
- AT->name = test->name;
- AT->plan = test->plan;
-
- if (test->fatals)
- flist = AT->fatal = at_list(test->fatals);
- else
- AT->fatal = &dummy;
-
- if (test->skips)
- slist = AT->skip = at_list(test->skips);
- else
- AT->skip = &dummy;
-
- if (test->todos)
- tlist = AT->todo = at_list(test->todos);
- else
- AT->todo = &dummy;
-
- AT->abort = &j;
- if (setjmp(j) == 0) {
- test->func(AT, test->ctx);
- at_free_lists;
- return AT_SUCCESS;
- }
- at_free_lists;
- AT->abort = NULL;
- return AT_EGENERAL;
-}
-
-int at_snprintf(char *buf, int size, const char *format, ...)
-{
- va_list args;
- int status;
- va_start(args, format);
- status = at_vsnprintf(buf, size, format, args);
- va_end(args);
- return status;
-}
-
-int at_vsnprintf(char *buf, int size, const char *format, va_list args)
-{
-#ifdef _MSC_VER
- int status = _vsnprintf(buf, size, format, args);
- /* Make Microsoft's _vsnprintf behave like C99 vsnprintf on overflow:
- * NULL-terminate, and return the number of chars printed minus one. */
- if (status < 0) {
- if (errno != EINVAL) {
- status = size - 1;
- buf[status] = '\0';
- }
- }
- return status;
-#else
- return vsnprintf(buf, size, format, args);
-#endif /* _MSC_VER */
-}
-
diff --git a/srclib/libapreq/t/at.h b/srclib/libapreq/t/at.h
deleted file mode 100644
index 2ec318fc37..0000000000
--- a/srclib/libapreq/t/at.h
+++ /dev/null
@@ -1,301 +0,0 @@
-/*
-** Licensed to the Apache Software Foundation (ASF) under one or more
-** contributor license agreements. See the NOTICE file distributed with
-** this work for additional information regarding copyright ownership.
-** The ASF licenses this file to You 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 <stdarg.h>
-#include <stdlib.h>
-#include <setjmp.h>
-#include <stdio.h>
-#include <string.h>
-
-typedef struct at_t at_t;
-typedef struct at_report_t at_report_t;
-
-typedef int (*at_report_function_t)(at_report_t *r, const char *msg);
-typedef void(*at_test_function_t)(at_t *t, void *ctx);
-typedef struct at_test_t at_test_t;
-
-struct at_test_t {
- const char *name;
- at_test_function_t func;
- int plan;
- void *ctx;
- const char *fatals;
- const char *skips;
- const char *todos;
-};
-
-struct at_report_t {
- at_report_function_t func;
-};
-
-/* Private, portable snprintf implementation.
- */
-int at_snprintf(char *buf, int size, const char *format, ...);
-int at_vsnprintf(char *buf, int size, const char *format, va_list args);
-
-/* 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 *skip; /* list of ignorabe assertions */
- const int *todo; /* list of expected failures */
- at_report_t *report ;/* handles the results of each check */
- unsigned char flags; /* verbosity: concise, trace, debug, etc. */
- jmp_buf *abort; /* where fatals go to die */
-};
-
-
-
-static inline
-int 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(unsigned char flags, at_report_t *report);
-int at_begin(at_t *t, int total);
-#define AT_begin(total) at_begin(AT, total)
-
-int 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_TODO(f) ((f) & 8)
-#define AT_FLAG_TODO_ON(f) ((f) |= 8)
-#define AT_FLAG_TODO_OFF(f) ((f) &= ~8)
-#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_todo_on() AT_FLAG_TODO_ON(AT->flags)
-#define AT_todo_off() AT_FLAG_TODO_OFF(AT->flags)
-#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". */
-
-int at_comment(at_t *t, const char *fmt, va_list vp);
-
-static 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 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 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[32] = "testing: %s (%s:%d)";
- at_trace(t, format, label, file, line);
-
- if (fmt != NULL) {
- char *f;
- at_snprintf(format, sizeof format, " format: %s", fmt);
- at_trace(t, "%s", format);
- memcpy(format, " left:", 8);
- f = format + strlen(format);
- at_snprintf(f, sizeof format - strlen(format), "\n right: %s", fmt);
- at_comment(t, format, vp);
- }
- }
- else if (AT_FLAG_DEBUG(t->flags) && !is_ok) {
- char format[32] = "testing: %s (%s:%d)";
- at_debug(t, format, label, file, line);
-
- if (fmt != NULL) {
- char *f;
- at_snprintf(format, sizeof format, " format: %s", fmt);
- at_debug(t, "%s", format);
- memcpy(format, " left:", 8);
- f = format + strlen(format);
- at_snprintf(f, sizeof format - strlen(format), "\n right: %s", fmt);
- 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); \
- at_snprintf(buf + blen - 1, 256 - blen, fmt, sz); \
- at_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); \
- at_snprintf(buf + blen - 1, 256 - blen , fmt, sz); \
- at_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__, "%p", 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__, "%p", 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)
-
-
-static inline
-void at_skip(at_t *t, int n, const char *reason, const char *file, int line) {
- char buf[256];
- while (n-- > 0) {
- ++t->current;
- at_snprintf(buf, 256, "ok %d - %s (%d) #skipped: %s (%s:%d)",
- t->current + t->prior, t->name, t->current, reason, file, line);
- at_report(t, buf);
- }
-}
-
-#define AT_skip(n, reason) at_skip(AT, n, reason, __FILE__, __LINE__)
-
-
-/* Report utilities. */
-
-at_report_t *at_report_file_make(FILE *f);
-inline
-static at_report_t *at_report_stdout_make(void)
-{
- return at_report_file_make(stdout);
-}
-void at_report_file_cleanup(at_report_t *r);
-#define at_report_stdout_cleanup(r) at_report_file_cleanup(r)
-
-void at_report_local(at_t *AT, const char *file, int line);
-#define AT_localize() at_report_local(AT, __FILE__, __LINE__)
-void at_report_delocalize(at_t *AT);
-#define AT_delocalize() at_report_delocalize(AT)
-
-#endif /* AT_H */
diff --git a/srclib/libapreq/t/cookie.c b/srclib/libapreq/t/cookie.c
deleted file mode 100644
index 4399e4fd5a..0000000000
--- a/srclib/libapreq/t/cookie.c
+++ /dev/null
@@ -1,246 +0,0 @@
-/*
-** Licensed to the Apache Software Foundation (ASF) under one or more
-** contributor license agreements. See the NOTICE file distributed with
-** this work for additional information regarding copyright ownership.
-** The ASF licenses this file to You 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_strings.h"
-#include "apreq_cookie.h"
-#include "apreq_error.h"
-#include "apreq_module.h"
-#include "apreq_util.h"
-#include "at.h"
-
-static const char nscookies[] = "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";
-
-static const char rfccookies[] = "$Version=1; first=a;$domain=quux;second=be,"
- "$Version=1;third=cie";
-
-static const char wpcookies[] = "wordpressuser_c580712eb86cad2660b3601ac"
- "04202b2=admin; wordpresspass_c580712eb8"
- "6cad2660b3601ac04202b2=7ebeeed42ef50720"
- "940f5b8db2f9db49; rs_session=59ae9b8b50"
- "3e3af7d17b97e7f77f7ea5; dbx-postmeta=gr"
- "abit=0-,1-,2-,3-,4-,5-,6-&advancedstuff"
- "=0-,1+,2-";
-
-static const char cgcookies1[] = "UID=MTj9S8CoAzMAAFEq21YAAAAG|c85a9e59db"
- "92b261408eb7539ff7f949b92c7d58; $Versio"
- "n=0;SID=MTj9S8CoAzMAAFEq21YAAAAG|c85a9e"
- "59db92b261408eb7539ff7f949b92c7d58;$Dom"
- "ain=www.xxxx.com;$Path=/";
-
-static const char cgcookies2[] = "UID=Gh9VxX8AAAIAAHP7h6AAAAAC|2e809a9cc9"
- "9c2dca778c385ebdefc5cb86c95dc3; SID=Gh9"
- "VxX8AAAIAAHP7h6AAAAAC|2e809a9cc99c2dca7"
- "78c385ebdefc5cb86c95dc3; $Version=1";
-
-static const char cgcookies3[] = "UID=hCijN8CoAzMAAGVDO2QAAAAF|50299f0793"
- "43fd6146257c105b1370f2da78246a; SID=hCi"
- "jN8CoAzMAAGVDO2QAAAAF|50299f079343fd614"
- "6257c105b1370f2da78246a; $Path=\"/\"; $"
- "Domain=\"www.xxxx.com\"";
-
-static const char cgcookies4[] = "SID=66XUEH8AAAIAAFmLLRkAAAAV|2a48c4ae2e"
- "9fb8355e75192db211f0779bdce244; UID=66X"
- "UEH8AAAIAAFmLLRkAAAAV|2a48c4ae2e9fb8355"
- "e75192db211f0779bdce244; __utma=1441491"
- "62.4479471199095321000.1234471650.12344"
- "71650.1234471650.1; __utmb=144149162.24"
- ".10.1234471650; __utmc=144149162; __utm"
- "z=\"144149162.1234471650.1.1.utmcsr=szu"
- "kaj.xxxx.pl|utmccn=(referral)|utmcmd=re"
- "ferral|utmcct=/internet/0,0.html\"";
-
-static apr_table_t *jar, *jar2, *jar3, *jar4, *jar5, *jar6, *jar7;
-static apr_pool_t *p;
-
-static void jar_make(dAT, void *ctx)
-{
- jar = apr_table_make(p, APREQ_DEFAULT_NELTS);
- AT_not_null(jar);
- AT_int_eq(apreq_parse_cookie_header(p, jar, nscookies), APREQ_ERROR_NOTOKEN);
- jar2 = apr_table_make(p, APREQ_DEFAULT_NELTS);
- AT_not_null(jar2);
- AT_int_eq(apreq_parse_cookie_header(p, jar2, rfccookies), APR_SUCCESS);
- jar3 = apr_table_make(p, APREQ_DEFAULT_NELTS);
- AT_not_null(jar3);
- AT_int_eq(apreq_parse_cookie_header(p, jar3, wpcookies), APREQ_ERROR_NOTOKEN);
- jar4 = apr_table_make(p, APREQ_DEFAULT_NELTS);
- AT_not_null(jar4);
- AT_int_eq(apreq_parse_cookie_header(p, jar4, cgcookies1), APREQ_ERROR_MISMATCH);
- jar5 = apr_table_make(p, APREQ_DEFAULT_NELTS);
- AT_not_null(jar5);
- AT_int_eq(apreq_parse_cookie_header(p, jar5, cgcookies2), APREQ_ERROR_MISMATCH);
- jar6 = apr_table_make(p, APREQ_DEFAULT_NELTS);
- AT_not_null(jar6);
- AT_int_eq(apreq_parse_cookie_header(p, jar6, cgcookies3), APREQ_ERROR_MISMATCH);
- jar7 = apr_table_make(p, APREQ_DEFAULT_NELTS);
- AT_not_null(jar7);
- AT_int_eq(apreq_parse_cookie_header(p, jar7, cgcookies4), APR_SUCCESS);
-}
-
-static void jar_get_rfc(dAT, void *ctx)
-{
- const char *val;
- AT_not_null(val = apr_table_get(jar2, "first"));
- AT_str_eq(val, "a");
- AT_not_null(val = apr_table_get(jar2, "second"));
- AT_str_eq(val, "be");
- AT_not_null(val = apr_table_get(jar2, "third"));
- AT_str_eq(val, "cie");
-}
-
-static void jar_get_ns(dAT, void *ctx)
-{
-
- AT_str_eq(apr_table_get(jar, "a"), "1");
-
- /* ignore wacky cookies that don't have an '=' sign */
- AT_is_null(apr_table_get(jar, "bad"));
-
- /* accept wacky cookies that contain multiple '=' */
- AT_str_eq(apr_table_get(jar, "ns"), "foo=1&bar=2");
-
- AT_str_eq(apr_table_get(jar,"foo"), "bar");
- AT_str_eq(apr_table_get(jar,"fl"), "left");
- AT_str_eq(apr_table_get(jar,"fr"), "right");
- AT_str_eq(apr_table_get(jar,"frl"), "right-left");
- AT_str_eq(apr_table_get(jar,"flr"), "left-right");
- AT_str_eq(apr_table_get(jar,"fll"), "left-left");
- AT_is_null(apr_table_get(jar,""));
-}
-
-
-static void netscape_cookie(dAT, void *ctx)
-{
- char expires[APR_RFC822_DATE_LEN];
- char *val;
- apreq_cookie_t *c;
-
- *(const char **)&val = apr_table_get(jar, "foo");
- AT_not_null(val);
-
- c = apreq_value_to_cookie(val);
-
- AT_str_eq(c->v.data, "bar");
- AT_int_eq(apreq_cookie_version(c), 0);
- AT_str_eq(apreq_cookie_as_string(c, p), "foo=bar");
-
- c->domain = apr_pstrdup(p, "example.com");
- AT_str_eq(apreq_cookie_as_string(c, p), "foo=bar; domain=example.com");
-
- c->path = apr_pstrdup(p, "/quux");
- AT_str_eq(apreq_cookie_as_string(c, p),
- "foo=bar; path=/quux; domain=example.com");
-
- apreq_cookie_expires(c, "+1y");
- apr_rfc822_date(expires, apr_time_now()
- + apr_time_from_sec(apreq_atoi64t("+1y")));
- expires[7] = '-';
- expires[11] = '-';
- val = apr_pstrcat(p, "foo=bar; path=/quux; domain=example.com; expires=",
- expires, NULL);
-
- AT_str_eq(apreq_cookie_as_string(c, p), val);
-}
-
-
-static void rfc_cookie(dAT, void *ctx)
-{
- apreq_cookie_t *c = apreq_cookie_make(p,"rfc",3,"out",3);
- const char *expected;
- long expires;
-
- AT_str_eq(c->v.data, "out");
-
- apreq_cookie_version_set(c, 1);
- AT_int_eq(apreq_cookie_version(c), 1);
- AT_str_eq(apreq_cookie_as_string(c,p),"rfc=out; Version=1");
-
- c->domain = apr_pstrdup(p, "example.com");
-
-#ifndef WIN32
-
- AT_str_eq(apreq_cookie_as_string(c,p),
- "rfc=out; Version=1; domain=\"example.com\"");
- c->path = apr_pstrdup(p, "/quux");
- 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");
- expected = apr_psprintf(p, "rfc=out; Version=1; path=\"/quux\"; "
- "domain=\"example.com\"; max-age=%ld",
- expires);
- AT_str_eq(apreq_cookie_as_string(c,p), expected);
-
-#else
-
- expected = "rfc=out; Version=1; domain=\"example.com\"";
- AT_str_eq(apreq_cookie_as_string(c,p), expected);
-
- c->path = apr_pstrdup(p, "/quux");
- expected = "rfc=out; Version=1; path=\"/quux\"; domain=\"example.com\"";
- AT_str_eq(apreq_cookie_as_string(c,p), expected);
-
- apreq_cookie_expires(c, "+3m");
- expires = apreq_atoi64t("+3m");
- expected = apr_psprintf(p, "rfc=out; Version=1; path=\"/quux\"; "
- "domain=\"example.com\"; max-age=%ld",
- expires);
- AT_str_eq(apreq_cookie_as_string(c,p), expected);
-
-#endif
-
-}
-
-
-#define dT(func, plan) #func, func, plan, NULL
-
-
-int main(int argc, char *argv[])
-{
- unsigned i, plan = 0;
- dAT;
- at_test_t test_list [] = {
- { dT(jar_make, 14) },
- { dT(jar_get_rfc, 6), "1 3 5" },
- { dT(jar_get_ns, 10) },
- { dT(netscape_cookie, 7) },
- { dT(rfc_cookie, 6) },
- };
-
- apr_initialize();
- atexit(apr_terminate);
-
- apr_pool_create(&p, NULL);
-
- AT = at_create(0, at_report_stdout_make());
- 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;
-}
diff --git a/srclib/libapreq/t/error.c b/srclib/libapreq/t/error.c
deleted file mode 100644
index 49c21d1e3c..0000000000
--- a/srclib/libapreq/t/error.c
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
-** Licensed to the Apache Software Foundation (ASF) under one or more
-** contributor license agreements. See the NOTICE file distributed with
-** this work for additional information regarding copyright ownership.
-** The ASF licenses this file to You 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_strings.h"
-#include "apreq_error.h"
-#include "at.h"
-
-
-static void test_strerror(dAT, void *ctx)
-{
- char buf[256], *str;
-
- str = apreq_strerror(APREQ_ERROR_GENERAL, buf, sizeof buf);
- AT_ptr_eq(str, buf);
- AT_str_eq(str, "Internal apreq error");
-
- str = apreq_strerror(APREQ_ERROR_TAINTED, buf, sizeof buf);
- AT_str_eq(str, "Attempt to perform unsafe action with tainted data");
-
- str = apreq_strerror(APREQ_ERROR_BADSEQ, buf, sizeof buf);
- AT_str_eq(str, "Invalid byte sequence");
-
- str = apreq_strerror(APREQ_ERROR_NODATA, buf, sizeof buf);
- AT_str_eq(str, "Missing input data");
-
- str = apreq_strerror(APREQ_ERROR_GENERAL+99, buf, sizeof buf);
- AT_str_eq(str, "Error string not yet specified by apreq");
-
-
-
-
- /* Test some common APR status codes also */
-
- str = apreq_strerror(APR_EINIT, buf, sizeof buf);
- AT_str_eq(str, "There is no error, this value signifies an initialized "
- "error code");
-
- str = apreq_strerror(APR_INCOMPLETE, buf, sizeof buf);
- AT_str_eq(str, "Partial results are valid but processing is incomplete");
-
- str = apreq_strerror(APR_EOF, buf, sizeof buf);
- AT_str_eq(str, "End of file found");
-
- str = apreq_strerror(APR_ENOTIMPL, buf, sizeof buf);
- AT_str_eq(str, "This function has not been implemented on this platform");
-
- }
-
-#define dT(func, plan) #func, func, plan, NULL
-
-
-int main(int argc, char *argv[])
-{
- unsigned i, plan = 0;
- apr_pool_t *p;
- dAT;
- at_test_t test_list [] = {
- { dT(test_strerror, 10), "1" }
- };
-
- apr_initialize();
- atexit(apr_terminate);
-
- apr_pool_create(&p, NULL);
-
- AT = at_create(0, at_report_stdout_make());
-
- 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;
-}
diff --git a/srclib/libapreq/t/params.c b/srclib/libapreq/t/params.c
deleted file mode 100644
index b142450886..0000000000
--- a/srclib/libapreq/t/params.c
+++ /dev/null
@@ -1,229 +0,0 @@
-/*
-** Licensed to the Apache Software Foundation (ASF) under one or more
-** contributor license agreements. See the NOTICE file distributed with
-** this work for additional information regarding copyright ownership.
-** The ASF licenses this file to You 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 "apreq_param.h"
-#include "apreq_util.h"
-#include "apreq_error.h"
-#include "apr_strings.h"
-#include "at.h"
-
-
-static const char query_string[] = "a=1;quux=foo+bar&a=2&plus=%2B;"
- "uplus=%U002b;okie=dokie;foo=a%E1;"
- "novalue1;novalue2=";
-static apr_table_t *args;
-static apr_pool_t *p;
-
-
-static void request_make(dAT, void *ctx)
-{
- apr_status_t s;
- args = apr_table_make(p, APREQ_DEFAULT_NELTS);
- AT_not_null(args);
- s = apreq_parse_query_string(p, args, query_string);
- AT_int_eq(s, APR_SUCCESS);
- AT_int_eq(apr_table_elts(args)->nelts, 9);
-}
-
-
-static void request_args_get(dAT, void *ctx)
-{
- const char *val;
- const apreq_param_t *param;
-
- AT_str_eq(apr_table_get(args,"a"), "1");
-
- val = apr_table_get(args,"quux");
- AT_str_eq(val, "foo bar");
- param = apreq_value_to_param(val);
- AT_int_eq(param->v.dlen, 7);
-
- AT_str_eq(apr_table_get(args,"plus"), "+");
- AT_str_eq(apr_table_get(args,"uplus"), "+");
- AT_str_eq(apr_table_get(args,"okie"), "dokie");
- AT_str_eq(apr_table_get(args,"novalue1"), "");
- AT_str_eq(apr_table_get(args,"novalue2"),"");
-}
-
-static void params_as(dAT, void *ctx)
-{
- const char *val;
- apr_array_header_t *arr;
- arr = apreq_params_as_array(p,args,"a");
- AT_int_eq(arr->nelts, 2);
- val = apreq_params_as_string(p,args,"a",APREQ_JOIN_AS_IS);
- AT_str_eq(val, "1, 2");
- val = apreq_params_as_string(p,args,"does_not_exist",APREQ_JOIN_AS_IS);
- AT_str_eq(val, "");
-}
-
-static void string_decoding_in_place(dAT, void *ctx)
-{
- char *s1 = apr_palloc(p,4096);
- char *s2 = apr_palloc(p,4096);
- char *s3;
-
- strcpy(s1, "bend it like beckham");
- strcpy(s2, "dandy %3Edons");
-
- AT_str_eq(s1,"bend it like beckham");
- apreq_unescape(s1);
- AT_str_eq(s1, "bend it like beckham");
- s3 = apreq_escape(p, s1, 20);
- AT_str_eq(s3, "bend+it+like+beckham");
- apreq_unescape(s3);
- AT_str_eq(s3,"bend it like beckham");
-
- AT_str_eq(s2,"dandy %3Edons");
- apreq_unescape(s2);
- AT_str_eq(s2,"dandy >dons");
- s3 = apreq_escape(p, s2, 11);
- AT_str_eq(s3,"dandy+%3Edons");
- apreq_unescape(s3);
- AT_str_eq(s3,"dandy >dons");
-}
-
-static void header_attributes(dAT, void *ctx)
-{
- const char *hdr = "text/plain; boundary=\"-foo-\", charset=ISO-8859-1";
- const char *val;
- apr_size_t vlen;
- apr_status_t s;
-
- s = apreq_header_attribute(hdr, "none", 4, &val, &vlen);
- AT_int_eq(s, APREQ_ERROR_NOATTR);
-
- s = apreq_header_attribute(hdr, "set", 3, &val, &vlen);
- AT_int_eq(s, APREQ_ERROR_NOATTR);
-
- s = apreq_header_attribute(hdr, "boundary", 8, &val, &vlen);
- 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);
- 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);
- 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);
- AT_int_eq(s, APREQ_ERROR_BADSEQ);
-
- s = apreq_header_attribute(hdr, "no-quote", 8, &val, &vlen);
- AT_int_eq(s, APREQ_ERROR_BADSEQ);
-
-}
-
-
-static void make_param(dAT, void *ctx)
-{
- apreq_param_t *param, *decode;
- apr_status_t s;
- apr_size_t nlen = 3, vlen = 11;
- char *name = apr_palloc(p,nlen+1);
- char *val = apr_palloc(p,vlen+1);
- char *encode;
- strcpy(name, "foo");
- strcpy(val, "bar > alpha");
-
- param = apreq_param_make(p, name, nlen, val, vlen);
- AT_str_eq(param->v.name, name);
- AT_int_eq(param->v.dlen, vlen);
- AT_str_eq(param->v.data, val);
-
- encode = apreq_param_encode(p, param);
- AT_str_eq(encode, "foo=bar+%3E+alpha");
-
- s = apreq_param_decode(&decode, p, encode, nlen, vlen+2);
- AT_int_eq(s, APR_SUCCESS);
- AT_str_eq(decode->v.name, name);
- AT_int_eq(decode->v.dlen, vlen);
- AT_str_eq(decode->v.data, val);
-}
-
-static void quote_strings(dAT, void *ctx)
-{
- apr_size_t exp_len, res_len, res_quote_len;
- char *res = apr_palloc(p,24);
- char *res_quote = apr_palloc(p,24);
- const char *expr;
- int i;
- const char * arr[] = {"cest", "\"cest", "ce\"st", "\"cest\""};
- const char * arr_quote[] =
- {"\"cest\"", "\"\\\"cest\"", "\"ce\\\"st\"", "\"\\\"cest\\\"\""};
- apr_size_t arr_len[] = {4, 5, 5, 6};
- apr_size_t arr_quote_len[] = {6, 8, 8, 10};
-
- for (i=0; i<4; i++) {
- res_len = apreq_quote(res, arr[i], arr_len[i]);
- 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);
- 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];
- expr = (i == 3) ? arr[i] : arr_quote[i];
- AT_int_eq(res_len, exp_len);
- AT_mem_eq(res, expr, exp_len);
- }
-}
-
-#define dT(func, plan) {#func, func, plan}
-
-int main(int argc, char *argv[])
-{
- unsigned i, plan = 0;
- dAT;
- at_test_t test_list [] = {
- dT(request_make, 3),
- dT(request_args_get, 8),
- dT(params_as, 3),
- dT(string_decoding_in_place, 8),
- dT(header_attributes, 13),
- dT(make_param, 8),
- dT(quote_strings, 24),
- };
-
- apr_initialize();
- atexit(apr_terminate);
- apr_pool_create(&p, NULL);
-
- apreq_initialize(p);
-
- AT = at_create(0, at_report_stdout_make());
- 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;
-}
-
diff --git a/srclib/libapreq/t/parsers.c b/srclib/libapreq/t/parsers.c
deleted file mode 100644
index f8449d1424..0000000000
--- a/srclib/libapreq/t/parsers.c
+++ /dev/null
@@ -1,555 +0,0 @@
-/*
-** Licensed to the Apache Software Foundation (ASF) under one or more
-** contributor license agreements. See the NOTICE file distributed with
-** this work for additional information regarding copyright ownership.
-** The ASF licenses this file to You 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 "apreq_parser.h"
-#include "apreq_util.h"
-#include "apreq_error.h"
-#include "apr_strings.h"
-#include "apr_xml.h"
-#include "at.h"
-
-#define CRLF "\015\012"
-
-static apr_pool_t *p;
-
-static char url_data[] = "alpha=one&beta=two;omega=last%2";
-
-static char form_data[] =
-"--AaB03x" CRLF /* 10 chars
- 012345678901234567890123456789012345678901234567890123456789 */
-"content-disposition: form-data; name=\"field1\"" CRLF /* 47 chars */
-"content-type: text/plain;charset=windows-1250" CRLF
-"content-transfer-encoding: quoted-printable" CRLF CRLF
-"Joe owes =80100." CRLF
-"--AaB03x" CRLF
-"content-disposition: form-data; name=\"pics\"; filename=\"file1.txt\"" CRLF
-"Content-Type: text/plain" CRLF CRLF
-"... contents of file1.txt ..." CRLF CRLF
-"--AaB03x" CRLF
-"content-disposition: form-data; name=\"\"" CRLF
-"content-type: text/plain;" CRLF " charset=windows-1250" CRLF
-"content-transfer-encoding: quoted-printable" CRLF CRLF
-"Joe owes =80100." CRLF
-"--AaB03x--" CRLF;
-
-static char xml_data[] =
-"<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>"
-"<methodCall>"
-" <methodName>foo.bar</methodName>"
-" <params>"
-" <param><value><int>1</int></value></param>"
-" </params>"
-"</methodCall>";
-
-static char rel_data[] = /*offsets: 122, 522, */
-"--f93dcbA3" CRLF
-"Content-Type: application/xml; charset=UTF-8" CRLF
-"Content-Length: 400" CRLF
-"Content-ID: <980119.X53GGT@example.com>" CRLF CRLF /*122*/
-"<?xml version=\"1.0\"?>" CRLF
-"<uploadDocument>"
-" <title>My Proposal</title>"
-" <author>E. X. Ample</author>"
-" <summary>A proposal for a new project.</summary>"
-" <notes image=\"cid:980119.X17AXM@example.com\">(see handwritten region)</notes>"
-" <keywords>project proposal funding</keywords>"
-" <readonly>false</readonly>"
-" <filename>image.png</filename>"
-" <content>cid:980119.X25MNC@example.com</content>"
-"</uploadDocument>" /*400*/ CRLF
-"--f93dcbA3" CRLF /*14*/
-"Content-Type: image/png" CRLF
-"Content-Transfer-Encoding: binary" CRLF
-"Content-ID: <980119.X25MNC@example.com>" CRLF CRLF /*103*/
-"...Binary data here..." /*22*/ CRLF
-"--f93dcbA3" CRLF /*14*/
-"Content-Type: image/png" CRLF
-"Content-Transfer-Encoding: binary" CRLF
-"Content-ID: <980119.X17AXM@example.com>" CRLF CRLF
-"...Binary data here..." CRLF
-"--f93dcbA3--" CRLF;
-
-static char mix_data[] =
-"--AaB03x" CRLF
-"Content-Disposition: form-data; name=\"submit-name\"" CRLF CRLF
-"Larry" CRLF
-"--AaB03x" CRLF
-"Content-Disposition: form-data; name=\"files\"" CRLF
-"Content-Type: multipart/mixed; boundary=BbC04y" CRLF CRLF
-"--BbC04y" CRLF
-"Content-Disposition: file; filename=\"file1.txt\"" CRLF
-"Content-Type: text/plain" CRLF CRLF
-"... contents of file1.txt ..." CRLF
-"--BbC04y" CRLF
-"Content-Disposition: file; filename=\"file2.gif\"" CRLF
-"Content-Type: image/gif" CRLF
-"Content-Transfer-Encoding: binary" CRLF CRLF
-"...contents of file2.gif..." CRLF
-"--BbC04y--" CRLF
-"--AaB03x " CRLF
-"content-disposition: form-data; name=\"field1\"" CRLF
-"content-type: text/plain;charset=windows-1250" CRLF
-"content-transfer-encoding: quoted-printable" CRLF CRLF
-"Joe owes =80100." CRLF
-"--AaB03x--"; /* omit CRLF, which is ok per rfc 2046 */
-
-
-#define URL_ENCTYPE "application/x-www-form-urlencoded"
-#define MFD_ENCTYPE "multipart/form-data"
-#define MR_ENCTYPE "multipart/related"
-#define XML_ENCTYPE "application/xml"
-
-static void locate_default_parsers(dAT, void *ctx)
-{
-
-#ifdef __ELF__
- apreq_parser_function_t f;
-
- AT_trace_on();
-
- f = apreq_parser(URL_ENCTYPE);
- AT_EQ(f, (apreq_parser_function_t)apreq_parse_urlencoded, "%pp");
-
- f = apreq_parser(MFD_ENCTYPE);
- AT_EQ(f, (apreq_parser_function_t)apreq_parse_multipart, "%pp");
-
- f = apreq_parser(MR_ENCTYPE);
- AT_EQ(f, (apreq_parser_function_t)apreq_parse_multipart, "%pp");
-
- AT_trace_off();
-#else
- AT_skip(3, "skipping ELF-dependent tests");
-#endif
-
-}
-
-static void parse_urlencoded(dAT, void *ctx)
-{
- apr_status_t rv;
- apr_bucket_alloc_t *ba;
- apr_bucket_brigade *bb;
- apreq_parser_t *parser;
- apr_table_t *body;
-
- body = apr_table_make(p, APREQ_DEFAULT_NELTS);
- ba = apr_bucket_alloc_create(p);
- bb = apr_brigade_create(p, ba);
- parser = apreq_parser_make(p, ba, URL_ENCTYPE, apreq_parse_urlencoded,
- 100, NULL, NULL, NULL);
-
- APR_BRIGADE_INSERT_HEAD(bb,
- apr_bucket_immortal_create(url_data,strlen(url_data),
- bb->bucket_alloc));
-
- rv = apreq_parser_run(parser, body, bb);
- AT_int_eq(rv, APR_INCOMPLETE);
-
- APR_BRIGADE_INSERT_HEAD(bb,
- apr_bucket_immortal_create("blast",5,
- bb->bucket_alloc));
- APR_BRIGADE_INSERT_TAIL(bb,
- apr_bucket_eos_create(bb->bucket_alloc));
-
- rv = apreq_parser_run(parser, body, bb);
- AT_int_eq(rv, APR_SUCCESS);
-
- AT_str_eq(apr_table_get(body,"alpha"), "one");
- AT_str_eq(apr_table_get(body,"beta"), "two");
- AT_str_eq(apr_table_get(body,"omega"),"last+last");
-
-}
-
-static void parse_multipart(dAT, void *ctx)
-{
- apr_size_t i, j;
- apr_bucket_alloc_t *ba;
-
-
- for (j = 0; j <= strlen(form_data); ++j) {
-
- ba = apr_bucket_alloc_create(p);
-
- /* 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();
-
- for (i = 0; i <= strlen(form_data); ++i) {
- const char *val;
- char *val2;
- apr_size_t len;
- apr_table_t *t, *body;
- apreq_parser_t *parser;
- apr_bucket_brigade *bb, *vb, *tail;
- apr_status_t rv;
- apr_bucket *e, *f;
-
- bb = apr_brigade_create(p, ba);
- body = apr_table_make(p, APREQ_DEFAULT_NELTS);
- parser = apreq_parser_make(p, ba, MFD_ENCTYPE
- "; charset=\"iso-8859-1\""
- "; boundary=\"AaB03x\"",
- apreq_parse_multipart,
- 1000, NULL, NULL, NULL);
-
- e = apr_bucket_immortal_create(form_data,
- strlen(form_data),
- bb->bucket_alloc);
- 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);
- if (i < j)
- apr_bucket_split(e, i);
- else
- apr_bucket_split(f, i - j);
-
- tail = apr_brigade_split(bb, f);
- rv = apreq_parser_run(parser, body, bb);
- AT_int_eq(rv, (j < strlen(form_data)) ? APR_INCOMPLETE : APR_SUCCESS);
- rv = apreq_parser_run(parser, body, tail);
- AT_int_eq(rv, APR_SUCCESS);
- AT_int_eq(apr_table_elts(body)->nelts, 3);
-
- val = apr_table_get(body,"field1");
- AT_str_eq(val, "Joe owes =80100.");
- t = apreq_value_to_param(val)->info;
- val = apr_table_get(t, "content-transfer-encoding");
- AT_str_eq(val, "quoted-printable");
-
- val = apr_table_get(body, "pics");
- AT_str_eq(val, "file1.txt");
- t = apreq_value_to_param(val)->info;
- vb = apreq_value_to_param(val)->upload;
- apr_brigade_pflatten(vb, &val2, &len, p);
- AT_int_eq(len, strlen("... contents of file1.txt ..." CRLF));
- AT_mem_eq(val2 ,"... contents of file1.txt ..." CRLF, len);
- val = apr_table_get(t, "content-type");
- AT_str_eq(val, "text/plain");
-
- val = apr_table_get(body, "");
- AT_str_eq(val, "Joe owes =80100.");
- t = apreq_value_to_param(val)->info;
- val = apr_table_get(t, "content-type");
- AT_int_eq(apreq_header_attribute(val, "charset", 7, &val, &len),
- APR_SUCCESS);
- AT_str_eq(val, "windows-1250");
-
- apr_brigade_cleanup(vb);
- apr_brigade_cleanup(bb);
- }
-
-#ifdef APR_POOL_DEBUG
- apr_bucket_alloc_destroy(ba);
-#endif
- AT_delocalize();
- apr_pool_clear(p);
- }
-}
-
-static void parse_disable_uploads(dAT, void *ctx)
-{
- const char *val;
- apr_table_t *t, *body;
- apr_status_t rv;
- apr_bucket_alloc_t *ba;
- apr_bucket_brigade *bb;
- apr_bucket *e;
- apreq_parser_t *parser;
- apreq_hook_t *hook;
-
- ba = apr_bucket_alloc_create(p);
- bb = apr_brigade_create(p, ba);
-
- e = apr_bucket_immortal_create(form_data, strlen(form_data), ba);
- APR_BRIGADE_INSERT_HEAD(bb, e);
- APR_BRIGADE_INSERT_TAIL(bb, apr_bucket_eos_create(bb->bucket_alloc));
-
- body = apr_table_make(p, APREQ_DEFAULT_NELTS);
- hook = apreq_hook_make(p, apreq_hook_disable_uploads, NULL, NULL);
-
- parser = apreq_parser_make(p, ba, MFD_ENCTYPE
- "; charset=\"iso-8859-1\""
- "; boundary=\"AaB03x\"",
- apreq_parse_multipart,
- 1000, NULL, hook, NULL);
-
-
- rv = apreq_parser_run(parser, body, bb);
- AT_int_eq(rv, APREQ_ERROR_GENERAL);
- AT_int_eq(apr_table_elts(body)->nelts, 1);
-
- val = apr_table_get(body,"field1");
- AT_str_eq(val, "Joe owes =80100.");
- t = apreq_value_to_param(val)->info;
- val = apr_table_get(t, "content-transfer-encoding");
- AT_str_eq(val, "quoted-printable");
-
- val = apr_table_get(body, "pics");
- AT_is_null(val);
-}
-
-
-static void parse_generic(dAT, void *ctx)
-{
- char *val;
- apr_size_t vlen;
- apr_status_t rv;
- apreq_param_t *dummy;
- apreq_parser_t *parser;
- apr_table_t *body;
- apr_bucket_alloc_t *ba = apr_bucket_alloc_create(p);
- apr_bucket_brigade *bb = apr_brigade_create(p, ba);
- apr_bucket *e = apr_bucket_immortal_create(xml_data,
- strlen(xml_data),
- ba);
-
- APR_BRIGADE_INSERT_HEAD(bb, e);
- APR_BRIGADE_INSERT_TAIL(bb, apr_bucket_eos_create(ba));
-
- body = apr_table_make(p, APREQ_DEFAULT_NELTS);
-
- parser = apreq_parser_make(p, ba, "application/xml",
- apreq_parse_generic, 1000, NULL, NULL, NULL);
-
- rv = apreq_parser_run(parser, body, bb);
- AT_int_eq(rv, APR_SUCCESS);
- dummy = *(apreq_param_t **)parser->ctx;
- AT_not_null(dummy);
- apr_brigade_pflatten(dummy->upload, &val, &vlen, p);
-
- AT_int_eq(vlen, strlen(xml_data));
- AT_mem_eq(val, xml_data, vlen);
-}
-
-static void hook_discard(dAT, void *ctx)
-{
- apr_status_t rv;
- apreq_param_t *dummy;
- apreq_parser_t *parser;
- apreq_hook_t *hook;
- apr_table_t *body;
- apr_bucket_alloc_t *ba = apr_bucket_alloc_create(p);
- apr_bucket_brigade *bb = apr_brigade_create(p, ba);
- apr_bucket *e = apr_bucket_immortal_create(xml_data,
- strlen(xml_data),
- ba);
-
- APR_BRIGADE_INSERT_HEAD(bb, e);
- APR_BRIGADE_INSERT_TAIL(bb, apr_bucket_eos_create(ba));
-
- body = apr_table_make(p, APREQ_DEFAULT_NELTS);
-
- hook = apreq_hook_make(p, apreq_hook_discard_brigade, NULL, NULL);
- parser = apreq_parser_make(p, ba, "application/xml",
- apreq_parse_generic, 1000, NULL, hook, NULL);
-
-
- rv = apreq_parser_run(parser, body, bb);
- AT_int_eq(rv, APR_SUCCESS);
- dummy = *(apreq_param_t **)parser->ctx;
- AT_not_null(dummy);
- AT_not_null(dummy->upload);
- AT_ok(APR_BRIGADE_EMPTY(dummy->upload), "brigade has no contents");
-}
-
-
-static void parse_related(dAT, void *ctx)
-{
- char ct[] = "multipart/related; boundary=f93dcbA3; "
- "type=application/xml; start=\"<980119.X53GGT@example.com>\"";
- char data[] = "...Binary data here...";
- int dlen = strlen(data);
- const char *val;
- char *val2;
- apr_size_t vlen;
- apr_status_t rv;
- int ns_map = 0;
- apr_xml_doc *doc;
- apr_table_t *body;
- apreq_parser_t *parser;
- apreq_hook_t *xml_hook;
- apreq_param_t *param;
- apr_bucket_alloc_t *ba = apr_bucket_alloc_create(p);
- apr_bucket_brigade *bb = apr_brigade_create(p, ba);
- apr_bucket *e = apr_bucket_immortal_create(rel_data,
- strlen(rel_data),
- bb->bucket_alloc);
-
- APR_BRIGADE_INSERT_HEAD(bb, e);
- APR_BRIGADE_INSERT_TAIL(bb, apr_bucket_eos_create(bb->bucket_alloc));
- xml_hook = apreq_hook_make(p, apreq_hook_apr_xml_parser, NULL, NULL);
-
- body = apr_table_make(p, APREQ_DEFAULT_NELTS);
- parser = apreq_parser_make(p, ba, ct, apreq_parse_multipart,
- 1000, NULL, xml_hook, NULL);
-
- rv = apreq_parser_run(parser, body, bb);
- AT_int_eq(rv, APR_SUCCESS);
-
- val = apr_table_get(body, "<980119.X53GGT@example.com>");
- AT_not_null(val);
- param = apreq_value_to_param(val);
-
- AT_not_null(param);
- AT_not_null(param->info);
- val = apr_table_get(param->info, "Content-Length");
- AT_str_eq(val, "400");
- AT_not_null(param->upload);
- apr_brigade_pflatten(param->upload, &val2, &vlen, p);
- AT_int_eq(vlen, 400);
- AT_mem_eq(val2, 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);
- AT_int_eq(vlen, 400 - 22);
- AT_mem_eq(val, rel_data + 122 + 23, 400 - 23);
-
-
- val = apr_table_get(body, "<980119.X25MNC@example.com>");
- AT_not_null(val);
- param = apreq_value_to_param(val);
- AT_not_null(param);
- AT_not_null(param->upload);
- apr_brigade_pflatten(param->upload, &val2, &vlen, p);
- AT_int_eq(vlen, dlen);
- AT_mem_eq(val2, data, vlen);
-
- val = apr_table_get(body, "<980119.X17AXM@example.com>");
- AT_not_null(val);
- param = apreq_value_to_param(val);
- AT_not_null(param);
- AT_not_null(param->upload);
- apr_brigade_pflatten(param->upload, &val2, &vlen, p);
- AT_int_eq(vlen, dlen);
- AT_mem_eq(val2, data, vlen);
-}
-
-typedef struct {
- const char *key;
- const char *val;
-} array_elt;
-
-
-static void parse_mixed(dAT, void *ctx)
-{
- const char *val;
- char *val2;
- apr_size_t vlen;
- apr_status_t rv;
- apreq_param_t *param;
- const apr_array_header_t *arr;
- array_elt *elt;
- char ct[] = MFD_ENCTYPE "; charset=\"iso-8859-1\"; boundary=\"AaB03x\"";
- apreq_parser_t *parser;
- apr_table_t *body = apr_table_make(p, APREQ_DEFAULT_NELTS);
- apr_bucket_alloc_t *ba = apr_bucket_alloc_create(p);
- apr_bucket_brigade *bb = apr_brigade_create(p, ba);
- apr_bucket *e = apr_bucket_immortal_create(mix_data,
- strlen(mix_data),
- bb->bucket_alloc);
-
- APR_BRIGADE_INSERT_HEAD(bb, e);
- APR_BRIGADE_INSERT_TAIL(bb, apr_bucket_eos_create(bb->bucket_alloc));
-
- parser = apreq_parser_make(p, ba, ct, apreq_parse_multipart,
- 1000, NULL, NULL, NULL);
-
- rv = apreq_parser_run(parser, body, bb);
- AT_int_eq(rv, APR_SUCCESS);
-
- val = apr_table_get(body, "submit-name");
- AT_not_null(val);
- AT_str_eq(val, "Larry");
-
- val = apr_table_get(body,"field1");
- AT_str_eq(val, "Joe owes =80100.");
-
- val = apr_table_get(body, "files");
- AT_not_null(val);
- AT_str_eq(val, "file1.txt");
- param = apreq_value_to_param(val);
-
- AT_not_null(param->upload);
- apr_brigade_pflatten(param->upload, &val2, &vlen, p);
- AT_int_eq(vlen, strlen("... contents of file1.txt ..."));
- AT_mem_eq(val2, "... contents of file1.txt ...", vlen);
-
- arr = apr_table_elts(body);
- AT_int_eq(arr->nelts, 4);
-
- elt = (array_elt *)&arr->elts[2 * arr->elt_size];
- AT_str_eq(elt->key, "files");
- AT_str_eq(elt->val, "file2.gif");
-
- param = apreq_value_to_param(elt->val);
- AT_not_null(param->upload);
- apr_brigade_pflatten(param->upload, &val2, &vlen, p);
- AT_int_eq(vlen, strlen("...contents of file2.gif..."));
- AT_mem_eq(val2, "...contents of file2.gif...", vlen);
-
-}
-
-
-#define dT(func, plan) {#func, func, plan}
-
-int main(int argc, char *argv[])
-{
- apr_pool_t *test_pool;
- unsigned i, plan = 0;
- dAT;
- at_test_t test_list [] = {
- dT(locate_default_parsers, 3),
- dT(parse_urlencoded, 5),
- dT(parse_multipart, sizeof form_data),
- dT(parse_disable_uploads, 5),
- dT(parse_generic, 4),
- dT(hook_discard, 4),
- dT(parse_related, 20),
- dT(parse_mixed, 15)
- };
-
- apr_initialize();
- atexit(apr_terminate);
-
- apr_pool_create(&p, NULL);
- apr_pool_create(&test_pool, NULL);
- apreq_initialize(p);
-
-
- AT = at_create(0, at_report_stdout_make());
-
- 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;
-}
-
-
diff --git a/srclib/libapreq/t/util.c b/srclib/libapreq/t/util.c
deleted file mode 100644
index f857626eca..0000000000
--- a/srclib/libapreq/t/util.c
+++ /dev/null
@@ -1,340 +0,0 @@
-/*
-** Licensed to the Apache Software Foundation (ASF) under one or more
-** contributor license agreements. See the NOTICE file distributed with
-** this work for additional information regarding copyright ownership.
-** The ASF licenses this file to You 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_strings.h"
-#include "apreq_error.h"
-#include "apreq_util.h"
-#include "at.h"
-
-
-static void test_atoi64f(dAT, void *ctx)
-{
- AT_int_eq(apreq_atoi64f("0"), 0);
- AT_int_eq(apreq_atoi64f("-1"), -1);
- AT_int_eq(apreq_atoi64f("-"), 0);
- AT_int_eq(apreq_atoi64f("5"), 5);
- AT_int_eq(apreq_atoi64f("3.333"), 3);
- AT_int_eq(apreq_atoi64f("33k"), 33 * 1024);
- AT_int_eq(apreq_atoi64f(" +8M "), 8 * 1024 * 1024);
- AT_ok(apreq_atoi64f("44GB") == (apr_int64_t)44 * 1024 * 1024 * 1024,
- "44GB test");
- AT_ok(apreq_atoi64f("0xaBcDefg") == (apr_int64_t)11259375 * 1024 * 1024 * 1024,
- "hex test");
-}
-
-static void test_atoi64t(dAT, void *ctx)
-{
- AT_int_eq(apreq_atoi64t("0"), 0);
- AT_int_eq(apreq_atoi64t("-1"), -1);
- AT_int_eq(apreq_atoi64t("-g088l3dyg00k"), 0);
- AT_int_eq(apreq_atoi64t("5s"), 5);
- AT_int_eq(apreq_atoi64t("3.333"), 3);
- AT_int_eq(apreq_atoi64t("33d"), 33 * 60 * 60 * 24);
- AT_int_eq(apreq_atoi64t(" +8M "), 8 * 60 * 60 * 24 * 30);
- AT_int_eq(apreq_atoi64t("+9m"), 9 * 60);
- AT_int_eq(apreq_atoi64t("6h"), 6 * 60 * 60);
-
-}
-
-static void test_index(dAT, void *ctx)
-{
- const char haystack[] = "Four score and seven years ago";
- apr_size_t hlen = sizeof haystack - 1;
- AT_int_eq(apreq_index(haystack, hlen, "Four", 4, APREQ_MATCH_FULL),
- 0);
- AT_int_eq(apreq_index(haystack, hlen, "Four", 4, APREQ_MATCH_PARTIAL),
- 0);
- AT_int_eq(apreq_index(haystack, hlen, "Fourteen", 8, APREQ_MATCH_FULL),
- -1);
- AT_int_eq(apreq_index(haystack, hlen, "Fourteen", 8, APREQ_MATCH_PARTIAL),
- -1);
- AT_int_eq(apreq_index(haystack, hlen, "agoraphobia", 11, APREQ_MATCH_FULL),
- -1);
- AT_int_eq(apreq_index(haystack, hlen, "agoraphobia", 11, APREQ_MATCH_PARTIAL),
- hlen - 3);
-}
-
-#define A_GRAVE 0xE5
-#define KATAKANA_A 0xFF71
-
-static void test_decode(dAT, void *ctx)
-{
- apr_size_t elen;
- char src1[] = "%C3%80%E3%82%a2"; /* A_GRAVE KATAKANA_A as utf8 */
- unsigned char expect[6];
-
- AT_int_eq(apreq_decode((char *)expect, &elen, src1, sizeof(src1) -1),
- APR_SUCCESS);
- AT_int_eq(elen, 5);
- AT_int_eq(expect[0], 0xC3);
- AT_int_eq(expect[1], 0x80);
- AT_int_eq(expect[2], 0xE3);
- AT_int_eq(expect[3], 0x82);
- AT_int_eq(expect[4], 0xA2);
-}
-
-static void test_charset_divine(dAT, void *ctx)
-{
- apr_size_t elen;
- char src1[] = "%C3%80%E3%82%a2"; /* A_GRAVE KATAKANA_A as utf8 */
- char src2[] = "pound%A3";/* latin-1 */
- char src3[] = "euro%80";/* cp-1252 */
- char expect[7];
-
- AT_int_eq(apreq_decode(expect, &elen, src1, sizeof(src1) -1),
- APR_SUCCESS);
-
- AT_int_eq(apreq_charset_divine(expect, elen), APREQ_CHARSET_UTF8);
-
- AT_int_eq(apreq_decode(expect, &elen, src2, sizeof(src2) -1),
- APR_SUCCESS);
-
- AT_int_eq(apreq_charset_divine(expect, elen), APREQ_CHARSET_LATIN1);
- AT_int_eq(apreq_decode(expect, &elen, src3, sizeof(src3) -1),
- APR_SUCCESS);
-
- AT_int_eq(apreq_charset_divine(expect, elen), APREQ_CHARSET_CP1252);
-
-}
-
-
-static void test_decodev(dAT, void *ctx)
-{
- char src1[] = "%2540%2";
- char src2[] = "0%u0";
- char src3[] = "041";
- struct iovec iovec1[] = {
- { src1, sizeof(src1) - 1 },
- { src2, sizeof(src2) - 1 },
- { src3, sizeof(src3) - 1 },
- };
- struct iovec iovec2[] = {
- { src1, sizeof(src1) - 1 },
- { src2, sizeof(src2) - 1 },
- };
- const char expect1[] = "%40 A";
- const char expect2[] = "%40 ";
- char dest[sizeof(src1) + sizeof(src2) + sizeof(src3)];
- apr_size_t dest_len;
- apr_status_t status;
-
- status = apreq_decodev(dest, &dest_len, iovec1, 3);
- AT_int_eq(status, APR_SUCCESS);
- AT_int_eq(dest_len, sizeof(expect1) - 1);
- AT_mem_eq(dest, expect1, sizeof(expect1) - 1);
-
- status = apreq_decodev(dest, &dest_len, iovec2, 2);
- AT_int_eq(status, APR_INCOMPLETE);
- AT_int_eq(dest_len, sizeof(expect2) - 1);
- AT_mem_eq(dest, expect2, sizeof(expect2) - 1);
-}
-
-
-static void test_encode(dAT, void *ctx)
-{
-
-}
-
-static void test_cp1252_to_utf8(dAT, void *ctx)
-{
- char src1[] = "%C3%80%E3%82%a2"; /* A_GRAVE KATAKANA_A as utf8 */
- char src2[5];
- unsigned char expect[16];
- apr_size_t slen;
-
- AT_int_eq(apreq_decode((char *)src2, &slen, src1, sizeof(src1) -1),
- APR_SUCCESS);
- AT_int_eq(apreq_cp1252_to_utf8((char *)expect, src2, 5),
- 12);
-
- /* 0xC3 */
- AT_int_eq(expect[0], 0xC0 | (0xC3 >> 6));
- AT_int_eq(expect[1], 0xC3 - 0x40);
-
- /* 0x20AC */
- AT_int_eq(expect[2], 0xE0 | (0x20AC >> 12));
- AT_int_eq(expect[3], 0x80 | ((0x20AC >> 6) & 0x3F));
- AT_int_eq(expect[4], 0x80 | (0x20AC & 0x3F));
-
- /* 0xE3 */
- AT_int_eq(expect[5], 0xC3);
- AT_int_eq(expect[6], 0xE3 - 0x40);
-
- /* 0x201A */
- AT_int_eq(expect[7], 0xE0 | (0x201A >> 12));
- AT_int_eq(expect[8], 0x80 | ((0x201A >> 6) & 0x3F));
- AT_int_eq(expect[9], 0x80 | (0x201A & 0x3F));
-
-
- /* 0xA2 */
- AT_int_eq(expect[10], 0xC0 | (0xA2 >> 6));
- AT_int_eq(expect[11], 0xA2);
-
-}
-
-static void test_quote(dAT, void *ctx)
-{
- size_t len;
- char dst[64];
-
- len = apreq_quote(dst, "foo", 3);
- AT_int_eq(len, 5);
- AT_str_eq(dst, "\"foo\"");
-
- len = apreq_quote(dst, "\"foo", 4);
- AT_int_eq(len, 7);
- AT_str_eq(dst, "\"\\\"foo\"");
-
- len = apreq_quote(dst, "foo\\bar", 7);
- AT_int_eq(len, 10);
- AT_str_eq(dst, "\"foo\\\\bar\"");
-
- len = apreq_quote(dst, "foo\0bar", 7);
- AT_int_eq(len, 10);
- AT_str_eq(dst, "\"foo\\0bar\"");
-}
-
-static void test_quote_once(dAT, void *ctx)
-{
- size_t len;
- char dst[64];
-
- len = apreq_quote_once(dst, "foo", 3);
- AT_int_eq(len, 5);
- AT_str_eq(dst, "\"foo\"");
-
- len = apreq_quote_once(dst, "\"foo", 4);
- AT_int_eq(len, 7);
- AT_str_eq(dst, "\"\\\"foo\"");
-
- len = apreq_quote_once(dst, "foo\"", 4);
- AT_int_eq(len, 7);
- AT_str_eq(dst, "\"foo\\\"\"");
-
- len = apreq_quote_once(dst, "foo\0bar", 7);
- AT_int_eq(len, 10);
- AT_str_eq(dst, "\"foo\\0bar\"");
-
- /* null byte must be escaped, even when there are already double
- quotes */
- len = apreq_quote_once(dst, "\"foo\0bar\"", 9);
- AT_int_eq(len, 14);
- AT_str_eq(dst, "\"\\\"foo\\0bar\\\"\"");
-
- len = apreq_quote_once(dst, "\"foo\"", 5);
- AT_int_eq(len, 5);
- AT_str_eq(dst, "\"foo\"");
-
- len = apreq_quote_once(dst, "'foo'", 5);
- AT_int_eq(len, 7);
- AT_str_eq(dst, "\"'foo'\"");
-
- len = apreq_quote_once(dst, "\"fo\\o\"", 6);
- AT_int_eq(len, 6);
- AT_str_eq(dst, "\"fo\\o\"");
-
- len = apreq_quote_once(dst, "\"foo\"bar\"", 9);
- AT_int_eq(len, 14);
- AT_str_eq(dst, "\"\\\"foo\\\"bar\\\"\"");
-}
-
-static void test_join(dAT, void *ctx)
-{
-
-}
-
-static void test_brigade_fwrite(dAT, void *ctx)
-{
-
-}
-
-static void test_file_mktemp(dAT, void *ctx)
-{
-
-
-}
-
-static void test_header_attribute(dAT, void *ctx)
-{
- const char hdr[] = "filename=\"filename=foo\" filename=\"quux.txt\"";
- const char *val;
- apr_size_t vlen;
-
- AT_int_eq(apreq_header_attribute(hdr+4, "name", 4, &val, &vlen),
- APR_SUCCESS);
- AT_int_eq(vlen, 12);
- AT_mem_eq("filename=foo", val, 12);
-
- AT_int_eq(apreq_header_attribute(hdr+4, "filename", 8, &val, &vlen),
- APR_SUCCESS);
- AT_int_eq(vlen, 8);
- AT_mem_eq("quux.txt", val, 8);
-
-}
-
-static void test_brigade_concat(dAT, void *ctx)
-{
-
-}
-
-
-
-#define dT(func, plan) #func, func, plan, NULL
-
-
-int main(int argc, char *argv[])
-{
- unsigned i, plan = 0;
- apr_pool_t *p;
- dAT;
- at_test_t test_list [] = {
- { dT(test_atoi64f, 9) },
- { dT(test_atoi64t, 9) },
- { dT(test_index, 6) },
- { dT(test_decode, 7) },
- { dT(test_charset_divine, 6) },
- { dT(test_decodev, 6) },
- { dT(test_encode, 0) },
- { dT(test_cp1252_to_utf8, 14) },
- { dT(test_quote, 8) },
- { dT(test_quote_once, 18), },
- { dT(test_join, 0) },
- { dT(test_brigade_fwrite, 0) },
- { dT(test_file_mktemp, 0) },
- { dT(test_header_attribute, 6) },
- { dT(test_brigade_concat, 0) },
- };
-
- apr_initialize();
- atexit(apr_terminate);
-
- apr_pool_create(&p, NULL);
-
- AT = at_create(0, at_report_stdout_make());
-
- 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;
-}
diff --git a/srclib/libapreq/t/version.c b/srclib/libapreq/t/version.c
deleted file mode 100644
index 955b6a9e34..0000000000
--- a/srclib/libapreq/t/version.c
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
-** Licensed to the Apache Software Foundation (ASF) under one or more
-** contributor license agreements. See the NOTICE file distributed with
-** this work for additional information regarding copyright ownership.
-** The ASF licenses this file to You 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 "apreq_version.h"
-#include "at.h"
-
-static void version_string(dAT, void *ctx)
-{
- const char *vstring = apreq_version_string();
- AT_not_null(vstring);
- AT_str_eq(vstring, APREQ_VERSION_STRING);
-}
-static void version_type(dAT, void *ctx)
-{
- apr_version_t v;
- apreq_version(&v);
- 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
- AT_int_eq(v.is_dev, 1);
-#else
- AT_int_eq(v.is_dev, 0);
-#endif
-}
-
-int main(int argc, char *argv[])
-{
- apr_pool_t *p;
- unsigned i, plan = 0;
- dAT;
- at_test_t test_list [] = {
- {"version_string", version_string, 2, NULL, "1"},
- {"version_type", version_type, 4}
- };
-
- apr_initialize();
- atexit(apr_terminate);
-
- apr_pool_create(&p, NULL);
-
- AT = at_create(0, at_report_stdout_make());
-
- 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;
-}