commit: r1755 - neon/trunk/test
joe at manyfish.co.uk
joe at manyfish.co.uk
Mon Dec 14 15:52:45 EST 2009
Author: joe
Date: Mon Dec 14 12:52:45 2009
New Revision: 1755
Modified:
neon/trunk/test/utils.c
neon/trunk/test/utils.h
Log:
* test/utils.c (session_server, proxied_session_server): New
functions. (make_session): Use session_server.
Modified: neon/trunk/test/utils.c
==============================================================================
--- neon/trunk/test/utils.c (original)
+++ neon/trunk/test/utils.c Mon Dec 14 12:52:45 2009
@@ -1,6 +1,6 @@
/*
Utility functions for HTTP client tests
- Copyright (C) 2001-2008, Joe Orton <joe at manyfish.co.uk>
+ Copyright (C) 2001-2009, Joe Orton <joe at manyfish.co.uk>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -33,12 +33,6 @@
#include "tests.h"
#include "utils.h"
-int make_session(ne_session **sess, server_fn fn, void *ud)
-{
- *sess = ne_session_create("http", "localhost", 7777);
- return spawn_server(7777, fn, ud);
-}
-
static int serve_response(ne_socket *s, const char *response)
{
CALL(discard_request(s));
@@ -180,3 +174,33 @@
return OK;
}
+int session_server(ne_session **sess, server_fn fn, void *userdata)
+{
+ unsigned int port;
+
+ CALL(new_spawn_server(fn, userdata, &port));
+
+ *sess = ne_session_create("http", "localhost", port);
+
+ return OK;
+}
+
+int proxied_session_server(ne_session **sess,
+ const char *host, unsigned int fakeport,
+ server_fn fn, void *userdata)
+{
+ unsigned int port;
+
+ CALL(new_spawn_server(fn, userdata, &port));
+
+ *sess = ne_session_create("http", host, fakeport);
+
+ ne_session_proxy(*sess, "localhost", port);
+
+ return OK;
+}
+
+int make_session(ne_session **sess, server_fn fn, void *ud)
+{
+ return session_server(sess, fn, ud);
+}
Modified: neon/trunk/test/utils.h
==============================================================================
--- neon/trunk/test/utils.h (original)
+++ neon/trunk/test/utils.h Mon Dec 14 12:52:45 2009
@@ -1,6 +1,6 @@
/*
neon-specific test utils
- Copyright (C) 2001-2008, Joe Orton <joe at manyfish.co.uk>
+ Copyright (C) 2001-2009, Joe Orton <joe at manyfish.co.uk>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -110,4 +110,18 @@
int full_write(ne_socket *sock, const char *data, size_t len);
+/* Create a session with server process running fn(userdata). Sets
+ * test suite error on failure; initializes *sess with a new session
+ * on success. Uses an unspecified hostname/port for the server. */
+int session_server(ne_session **sess, server_fn fn, void *userdata);
+
+/* Create a session with server process running fn(userdata). Sets
+ * test suite error on failure; initializes *sess with a new session
+ * on success. Uses an unspecified hostname/port for the server;
+ * session is created as if using origin 'host:fakeport' via proxy to
+ * spawned server. */
+int proxied_session_server(ne_session **sess,
+ const char *host, unsigned int fakeport,
+ server_fn fn, void *userdata);
+
#endif /* UTILS_H */
More information about the neon-commits
mailing list