[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor/master] Add some mocks needed to unit test ClientTransportPlugin/ServerTransportPlugin config line parsing
commit b8b46e8ef847c0683fab00783fb64bef0c6f83c6
Author: Andrea Shepard <andrea@xxxxxxxxxxxxxx>
Date: Fri Jul 25 21:41:03 2014 -0700
Add some mocks needed to unit test ClientTransportPlugin/ServerTransportPlugin config line parsing
---
src/or/entrynodes.c | 4 ++--
src/or/entrynodes.h | 2 +-
src/or/transports.c | 12 ++++++------
src/or/transports.h | 10 ++++++----
4 files changed, 15 insertions(+), 13 deletions(-)
diff --git a/src/or/entrynodes.c b/src/or/entrynodes.c
index 4d09195..8f105c7 100644
--- a/src/or/entrynodes.c
+++ b/src/or/entrynodes.c
@@ -1884,8 +1884,8 @@ bridge_resolve_conflicts(const tor_addr_t *addr, uint16_t port,
/** Return True if we have a bridge that uses a transport with name
* <b>transport_name</b>. */
-int
-transport_is_needed(const char *transport_name)
+MOCK_IMPL(int,
+transport_is_needed, (const char *transport_name))
{
if (!bridge_list)
return 0;
diff --git a/src/or/entrynodes.h b/src/or/entrynodes.h
index 5d91756..8b5ffba 100644
--- a/src/or/entrynodes.h
+++ b/src/or/entrynodes.h
@@ -151,7 +151,7 @@ struct transport_t;
int get_transport_by_bridge_addrport(const tor_addr_t *addr, uint16_t port,
const struct transport_t **transport);
-int transport_is_needed(const char *transport_name);
+MOCK_DECL(int, transport_is_needed, (const char *transport_name));
int validate_pluggable_transports_config(void);
double pathbias_get_close_success_count(entry_guard_t *guard);
diff --git a/src/or/transports.c b/src/or/transports.c
index dc30754..0fb5926 100644
--- a/src/or/transports.c
+++ b/src/or/transports.c
@@ -324,9 +324,9 @@ transport_add(transport_t *t)
/** Remember a new pluggable transport proxy at <b>addr</b>:<b>port</b>.
* <b>name</b> is set to the name of the protocol this proxy uses.
* <b>socks_ver</b> is set to the SOCKS version of the proxy. */
-int
-transport_add_from_config(const tor_addr_t *addr, uint16_t port,
- const char *name, int socks_ver)
+MOCK_IMPL(int,
+transport_add_from_config, (const tor_addr_t *addr, uint16_t port,
+ const char *name, int socks_ver))
{
transport_t *t = transport_new(addr, port, name, socks_ver, NULL);
@@ -1349,9 +1349,9 @@ managed_proxy_create(const smartlist_t *transport_list,
* Requires that proxy_argv be a NULL-terminated array of command-line
* elements, containing at least one element.
**/
-void
-pt_kickstart_proxy(const smartlist_t *transport_list,
- char **proxy_argv, int is_server)
+MOCK_IMPL(void,
+pt_kickstart_proxy, (const smartlist_t *transport_list,
+ char **proxy_argv, int is_server))
{
managed_proxy_t *mp=NULL;
transport_t *old_transport = NULL;
diff --git a/src/or/transports.h b/src/or/transports.h
index 1365ead..deacdcd 100644
--- a/src/or/transports.h
+++ b/src/or/transports.h
@@ -32,14 +32,16 @@ typedef struct transport_t {
void mark_transport_list(void);
void sweep_transport_list(void);
-int transport_add_from_config(const tor_addr_t *addr, uint16_t port,
- const char *name, int socks_ver);
+MOCK_DECL(int, transport_add_from_config,
+ (const tor_addr_t *addr, uint16_t port,
+ const char *name, int socks_ver));
void transport_free(transport_t *transport);
transport_t *transport_get_by_name(const char *name);
-void pt_kickstart_proxy(const smartlist_t *transport_list, char **proxy_argv,
- int is_server);
+MOCK_DECL(void, pt_kickstart_proxy,
+ (const smartlist_t *transport_list, char **proxy_argv,
+ int is_server));
#define pt_kickstart_client_proxy(tl, pa) \
pt_kickstart_proxy(tl, pa, 0)
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits