You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by dr...@apache.org on 2004/06/21 17:19:10 UTC
cvs commit: apr-util/test Makefile.in abts_tests.h testuri.c testutil.h
dreid 2004/06/21 08:19:10
Modified: test Makefile.in abts_tests.h testuri.c testutil.h
Log:
Change testuri to use the abts test suite.
This presently fails 2 tests.
Revision Changes Path
1.42 +2 -7 apr-util/test/Makefile.in
Index: Makefile.in
===================================================================
RCS file: /home/cvs/apr-util/test/Makefile.in,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -r1.41 -r1.42
--- Makefile.in 5 Jun 2004 22:19:41 -0000 1.41
+++ Makefile.in 21 Jun 2004 15:19:10 -0000 1.42
@@ -3,7 +3,7 @@
INCLUDES = @APRUTIL_PRIV_INCLUDES@ @APR_INCLUDES@ @APRUTIL_INCLUDES@
PROGRAMS = testall testdbm testdate testmd4 testmd5 testxml testrmm \
- teststrmatch testreslist testqueue testuri testpass
+ teststrmatch testreslist testqueue testpass
TARGETS = $(PROGRAMS)
APRUTIL_DOTTED_VERSION=@APRUTIL_DOTTED_VERSION@
@@ -71,17 +71,12 @@
testqueue: $(testqueue_OBJECTS) $(testqueue_LDADD)
$(LINK) $(APRUTIL_LDFLAGS) $(testqueue_OBJECTS) $(testqueue_LDADD) $(PROGRAM_DEPENDENCIES)
-testuri_OBJECTS = testuri.lo
-testuri_LDADD = $(TARGET_LIB_PATH)
-testuri: $(testuri_OBJECTS) $(testuri_LDADD)
- $(LINK) $(APRUTIL_LDFLAGS) $(testuri_OBJECTS) $(testuri_LDADD) $(PROGRAM_DEPENDENCIES)
-
testpass_OBJECTS = testpass.lo
testpass_LDADD = $(TARGET_LIB_PATH)
testpass: $(testpass_OBJECTS) $(testpass_LDADD)
$(LINK) $(APRUTIL_LDFLAGS) $(testpass_OBJECTS) $(testpass_LDADD) $(PROGRAM_DEPENDENCIES)
-testall_OBJECTS = testuuid.lo abts.lo testutil.lo
+testall_OBJECTS = testuri.lo testuuid.lo abts.lo testutil.lo
testall_LDADD = $(TARGET_LIB_PATH)
testall: $(testall_OBJECTS) $(testall_LDADD)
$(LINK) $(APRUTIL_LDFLAGS) $(testall_OBJECTS) $(testall_LDADD) $(PROGRAM_DEPENDENCIES)
1.2 +1 -0 apr-util/test/abts_tests.h
Index: abts_tests.h
===================================================================
RCS file: /home/cvs/apr-util/test/abts_tests.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- abts_tests.h 5 Jun 2004 22:19:41 -0000 1.1
+++ abts_tests.h 21 Jun 2004 15:19:10 -0000 1.2
@@ -22,6 +22,7 @@
const struct testlist {
abts_suite *(*func)(abts_suite *suite);
} alltests[] = {
+ (testuri),
{testuuid}
};
1.5 +32 -83 apr-util/test/testuri.c
Index: testuri.c
===================================================================
RCS file: /home/cvs/apr-util/test/testuri.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- testuri.c 13 Feb 2004 09:55:26 -0000 1.4
+++ testuri.c 21 Jun 2004 15:19:10 -0000 1.5
@@ -16,6 +16,7 @@
#include <stdio.h>
#include <stdlib.h>
+#include "testutil.h"
#include "apr_general.h"
#include "apr_uri.h"
@@ -150,77 +151,40 @@
}
}
-static int same_str(const char *s1, const char *s2)
-{
- if (s1 == s2) { /* e.g., NULL and NULL */
- return 1;
- }
- else if (!s1 || !s2) { /* only 1 is NULL */
- return 0;
- }
- else {
- return strcmp(s1, s2) == 0;
- }
-}
-
-static int test_aup(apr_pool_t *p)
+static void test_aup(abts_case *tc, void *data)
{
+ apr_pool_t *p = (apr_pool_t *)data;
int i;
apr_status_t rv;
apr_uri_t info;
struct aup_test *t;
- const char *failed;
+ const char *s = NULL;
int rc = 0;
for (i = 0; i < sizeof(aup_tests) / sizeof(aup_tests[0]); i++) {
memset(&info, 0, sizeof(info));
t = &aup_tests[i];
rv = apr_uri_parse(p, t->uri, &info);
- failed = (rv != t->rv) ? "bad rc" : NULL;
- if (!failed && t->rv == APR_SUCCESS) {
- if (!same_str(info.scheme, t->scheme))
- failed = "bad scheme";
- if (!same_str(info.hostinfo, t->hostinfo))
- failed = "bad hostinfo";
- if (!same_str(info.user, t->user))
- failed = "bad user";
- if (!same_str(info.password, t->password))
- failed = "bad password";
- if (!same_str(info.hostname, t->hostname))
- failed = "bad hostname";
- if (!same_str(info.port_str, t->port_str))
- failed = "bad port_str";
- if (!same_str(info.path, t->path))
- failed = "bad path";
- if (!same_str(info.query, t->query))
- failed = "bad query";
- if (!same_str(info.fragment, t->fragment))
- failed = "bad fragment";
- if (info.port != t->port)
- failed = "bad port";
- }
- if (failed) {
- ++rc;
- fprintf(stderr, "failure for testcase %d/uri %s: %s\n", i,
- t->uri, failed);
- show_info(rv, t->rv, &info);
- }
- else if (t->rv == APR_SUCCESS) {
- const char *s = apr_uri_unparse(p, &info,
- APR_URI_UNP_REVEALPASSWORD);
-
- if (strcmp(s, t->uri)) {
- fprintf(stderr, "apr_uri_unparsed failed for testcase %d\n", i);
- fprintf(stderr, " got %s, expected %s\n", s, t->uri);
- }
- }
- }
+ ABTS_INT_EQUAL(tc, rv, t->rv);
+ ABTS_STR_EQUAL(tc, info.scheme, t->scheme);
+ ABTS_STR_EQUAL(tc, info.hostinfo, t->hostinfo);
+ ABTS_STR_EQUAL(tc, info.user, t->user);
+ ABTS_STR_EQUAL(tc, info.password, t->password);
+ ABTS_STR_EQUAL(tc, info.hostname, t->hostname);
+ ABTS_STR_EQUAL(tc, info.port_str, t->port_str);
+ ABTS_STR_EQUAL(tc, info.path, t->path);
+ ABTS_STR_EQUAL(tc, info.query, t->query);
+ ABTS_STR_EQUAL(tc, info.user, t->user);
+ ABTS_INT_EQUAL(tc, info.port, t->port);
- return rc;
+ s = apr_uri_unparse(p, &info, APR_URI_UNP_REVEALPASSWORD);
+ ABTS_STR_EQUAL(tc, s, t->uri);
+ }
}
-static int test_uph(apr_pool_t *p)
+static void test_uph(abts_case *tc, void *data)
{
+ apr_pool_t *p = (apr_pool_t *)data;
int i;
apr_status_t rv;
apr_uri_t info;
@@ -232,41 +196,26 @@
memset(&info, 0, sizeof(info));
t = &uph_tests[i];
rv = apr_uri_parse_hostinfo(p, t->hostinfo, &info);
- failed = (rv != t->rv) ? "bad rc" : NULL;
- if (!failed && t->rv == APR_SUCCESS) {
- if (!same_str(info.hostname, t->hostname))
- failed = "bad hostname";
- if (!same_str(info.port_str, t->port_str))
- failed = "bad port_str";
- if (info.port != t->port)
- failed = "bad port";
- }
- if (failed) {
- ++rc;
- fprintf(stderr, "failure for testcase %d/hostinfo %s: %s\n", i,
- t->hostinfo, failed);
- show_info(rv, t->rv, &info);
- }
+ ABTS_INT_EQUAL(tc, rv, t->rv);
+ ABTS_STR_EQUAL(tc, info.hostname, t->hostname);
+ ABTS_STR_EQUAL(tc, info.port_str, t->port_str);
+ ABTS_INT_EQUAL(tc, info.port, t->port);
}
-
- return rc;
}
-int main(void)
+abts_suite *testuri(abts_suite *suite)
{
apr_pool_t *pool;
- int rc;
- apr_initialize();
- atexit(apr_terminate);
+ suite = ADD_SUITE(suite);
+
+ /* do we need to run the apr_initialize and set an atexit() here? */
apr_pool_create(&pool, NULL);
- rc = test_aup(pool);
+ abts_run_test(suite, test_aup, pool);
+ abts_run_test(suite, test_uph, pool);
- if (!rc) {
- rc = test_uph(pool);
- }
-
- return rc;
+ return suite;
}
+
1.2 +1 -0 apr-util/test/testutil.h
Index: testutil.h
===================================================================
RCS file: /home/cvs/apr-util/test/testutil.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- testutil.h 5 Jun 2004 22:19:41 -0000 1.1
+++ testutil.h 21 Jun 2004 15:19:10 -0000 1.2
@@ -42,6 +42,7 @@
void initialize(void);
+abts_suite *testuri(abts_suite *);
abts_suite *testuuid(abts_suite *suite);
#endif /* APR_TEST_INCLUDES */