aboutsummaryrefslogtreecommitdiff
path: root/src/or
diff options
context:
space:
mode:
authorAndrea Shepard <andrea@torproject.org>2016-06-28 21:30:57 +0000
committerAndrea Shepard <andrea@torproject.org>2016-06-29 05:55:42 +0000
commit657eaee6ae640d5abffc760bed14b5d31ad1ea73 (patch)
treef38d042a7c80a8146da8acd1a8bc96174b6924ee /src/or
parentc69290072819d20e43bd0dd83fa8cefc1167b544 (diff)
downloadtor-657eaee6ae640d5abffc760bed14b5d31ad1ea73.tar.gz
tor-657eaee6ae640d5abffc760bed14b5d31ad1ea73.zip
Expose GETINFO download status statics for test suite and make things mockable
Diffstat (limited to 'src/or')
-rw-r--r--src/or/control.c10
-rw-r--r--src/or/control.h25
-rw-r--r--src/or/entrynodes.c8
-rw-r--r--src/or/entrynodes.h5
-rw-r--r--src/or/networkstatus.c16
-rw-r--r--src/or/networkstatus.h17
-rw-r--r--src/or/routerlist.c18
-rw-r--r--src/or/routerlist.h14
8 files changed, 71 insertions, 42 deletions
diff --git a/src/or/control.c b/src/or/control.c
index 77a09f08c7..f127090612 100644
--- a/src/or/control.c
+++ b/src/or/control.c
@@ -2179,7 +2179,7 @@ download_status_to_string(const download_status_t *dl)
}
/** Handle the consensus download cases for getinfo_helper_downloads() */
-static void
+STATIC void
getinfo_helper_downloads_networkstatus(const char *flavor,
download_status_t **dl_to_emit,
const char **errmsg)
@@ -2208,7 +2208,7 @@ getinfo_helper_downloads_networkstatus(const char *flavor,
}
/** Handle the cert download cases for getinfo_helper_downloads() */
-static void
+STATIC void
getinfo_helper_downloads_cert(const char *fp_sk_req,
download_status_t **dl_to_emit,
smartlist_t **digest_list,
@@ -2308,7 +2308,7 @@ getinfo_helper_downloads_cert(const char *fp_sk_req,
}
/** Handle the routerdesc download cases for getinfo_helper_downloads() */
-static void
+STATIC void
getinfo_helper_downloads_desc(const char *desc_req,
download_status_t **dl_to_emit,
smartlist_t **digest_list,
@@ -2354,7 +2354,7 @@ getinfo_helper_downloads_desc(const char *desc_req,
}
/** Handle the bridge download cases for getinfo_helper_downloads() */
-static void
+STATIC void
getinfo_helper_downloads_bridge(const char *bridge_req,
download_status_t **dl_to_emit,
smartlist_t **digest_list,
@@ -2397,7 +2397,7 @@ getinfo_helper_downloads_bridge(const char *bridge_req,
/** Implementation helper for GETINFO: knows the answers for questions about
* download status information. */
-static int
+STATIC int
getinfo_helper_downloads(control_connection_t *control_conn,
const char *question, char **answer,
const char **errmsg)
diff --git a/src/or/control.h b/src/or/control.h
index b3902e64bd..6330c85571 100644
--- a/src/or/control.h
+++ b/src/or/control.h
@@ -261,6 +261,31 @@ STATIC crypto_pk_t *add_onion_helper_keyarg(const char *arg, int discard_pk,
char **err_msg_out);
STATIC rend_authorized_client_t *
add_onion_helper_clientauth(const char *arg, int *created, char **err_msg_out);
+
+STATIC void getinfo_helper_downloads_networkstatus(
+ const char *flavor,
+ download_status_t **dl_to_emit,
+ const char **errmsg);
+STATIC void getinfo_helper_downloads_cert(
+ const char *fp_sk_req,
+ download_status_t **dl_to_emit,
+ smartlist_t **digest_list,
+ const char **errmsg);
+STATIC void getinfo_helper_downloads_desc(
+ const char *desc_req,
+ download_status_t **dl_to_emit,
+ smartlist_t **digest_list,
+ const char **errmsg);
+STATIC void getinfo_helper_downloads_bridge(
+ const char *bridge_req,
+ download_status_t **dl_to_emit,
+ smartlist_t **digest_list,
+ const char **errmsg);
+STATIC int getinfo_helper_downloads(
+ control_connection_t *control_conn,
+ const char *question, char **answer,
+ const char **errmsg);
+
#endif
#endif
diff --git a/src/or/entrynodes.c b/src/or/entrynodes.c
index 72ac6e7e4f..17507fefbd 100644
--- a/src/or/entrynodes.c
+++ b/src/or/entrynodes.c
@@ -2425,8 +2425,8 @@ num_bridges_usable(void)
}
/** Return a smartlist containing all bridge identity digests */
-smartlist_t *
-list_bridge_identities(void)
+MOCK_IMPL(smartlist_t *,
+list_bridge_identities, (void))
{
smartlist_t *result = NULL;
char *digest_tmp;
@@ -2445,8 +2445,8 @@ list_bridge_identities(void)
}
/** Get the download status for a bridge descriptor given its identity */
-download_status_t *
-get_bridge_dl_status_by_id(const char *digest)
+MOCK_IMPL(download_status_t *,
+get_bridge_dl_status_by_id, (const char *digest))
{
download_status_t *dl = NULL;
diff --git a/src/or/entrynodes.h b/src/or/entrynodes.h
index 285367d4d7..1021e67d43 100644
--- a/src/or/entrynodes.h
+++ b/src/or/entrynodes.h
@@ -179,8 +179,9 @@ guard_get_guardfraction_bandwidth(guardfraction_bandwidth_t *guardfraction_bw,
int orig_bandwidth,
uint32_t guardfraction_percentage);
-smartlist_t * list_bridge_identities(void);
-download_status_t * get_bridge_dl_status_by_id(const char *digest);
+MOCK_DECL(smartlist_t *, list_bridge_identities, (void));
+MOCK_DECL(download_status_t *, get_bridge_dl_status_by_id,
+ (const char *digest));
#endif
diff --git a/src/or/networkstatus.c b/src/or/networkstatus.c
index a582b852ae..99680472f5 100644
--- a/src/or/networkstatus.c
+++ b/src/or/networkstatus.c
@@ -683,8 +683,8 @@ router_get_descriptor_digests_in_consensus(networkstatus_t *consensus)
/** Return a smartlist of all router descriptor digests in the current
* consensus */
-smartlist_t *
-router_get_descriptor_digests(void)
+MOCK_IMPL(smartlist_t *,
+router_get_descriptor_digests,(void))
{
smartlist_t *result = NULL;
@@ -1219,8 +1219,8 @@ consensus_is_waiting_for_certs(void)
/** Look up the currently active (depending on bootstrap status) download
* status for this consensus flavor and return a pointer to it.
*/
-download_status_t *
-networkstatus_get_dl_status_by_flavor(consensus_flavor_t flavor)
+MOCK_IMPL(download_status_t *,
+networkstatus_get_dl_status_by_flavor,(consensus_flavor_t flavor))
{
download_status_t *dl = NULL;
const int we_are_bootstrapping =
@@ -1236,8 +1236,8 @@ networkstatus_get_dl_status_by_flavor(consensus_flavor_t flavor)
/** Look up the bootstrap download status for this consensus flavor
* and return a pointer to it. */
-download_status_t *
-networkstatus_get_dl_status_by_flavor_bootstrap(consensus_flavor_t flavor)
+MOCK_IMPL(download_status_t *,
+networkstatus_get_dl_status_by_flavor_bootstrap,(consensus_flavor_t flavor))
{
download_status_t *dl = NULL;
@@ -1250,8 +1250,8 @@ networkstatus_get_dl_status_by_flavor_bootstrap(consensus_flavor_t flavor)
/** Look up the running (non-bootstrap) download status for this consensus
* flavor and return a pointer to it. */
-download_status_t *
-networkstatus_get_dl_status_by_flavor_running(consensus_flavor_t flavor)
+MOCK_IMPL(download_status_t *,
+networkstatus_get_dl_status_by_flavor_running,(consensus_flavor_t flavor))
{
download_status_t *dl = NULL;
diff --git a/src/or/networkstatus.h b/src/or/networkstatus.h
index 6d5d05aefc..65923b67ba 100644
--- a/src/or/networkstatus.h
+++ b/src/or/networkstatus.h
@@ -38,14 +38,17 @@ routerstatus_t *networkstatus_vote_find_mutable_entry(networkstatus_t *ns,
int networkstatus_vote_find_entry_idx(networkstatus_t *ns,
const char *digest, int *found_out);
-download_status_t * networkstatus_get_dl_status_by_flavor(
- consensus_flavor_t flavor);
-download_status_t * networkstatus_get_dl_status_by_flavor_bootstrap(
- consensus_flavor_t flavor);
-download_status_t * networkstatus_get_dl_status_by_flavor_running(
- consensus_flavor_t flavor);
+MOCK_DECL(download_status_t *,
+ networkstatus_get_dl_status_by_flavor,
+ (consensus_flavor_t flavor));
+MOCK_DECL(download_status_t *,
+ networkstatus_get_dl_status_by_flavor_bootstrap,
+ (consensus_flavor_t flavor));
+MOCK_DECL(download_status_t *,
+ networkstatus_get_dl_status_by_flavor_running,
+ (consensus_flavor_t flavor));
-smartlist_t * router_get_descriptor_digests(void);
+MOCK_DECL(smartlist_t *, router_get_descriptor_digests, (void));
MOCK_DECL(download_status_t *,router_get_dl_status_by_descriptor_digest,
(const char *d));
diff --git a/src/or/routerlist.c b/src/or/routerlist.c
index 6bd494bc03..0a28edefb0 100644
--- a/src/or/routerlist.c
+++ b/src/or/routerlist.c
@@ -257,8 +257,8 @@ get_cert_list(const char *id_digest)
* of download_status_t objects; used by controller GETINFO queries.
*/
-smartlist_t *
-list_authority_ids_with_downloads(void)
+MOCK_IMPL(smartlist_t *,
+list_authority_ids_with_downloads, (void))
{
smartlist_t *ids = smartlist_new();
digestmap_iter_t *i;
@@ -288,8 +288,8 @@ list_authority_ids_with_downloads(void)
/** Given an authority ID digest, return a pointer to the default download
* status, or NULL if there is no such entry in trusted_dir_certs */
-download_status_t *
-id_only_download_status_for_authority_id(const char *digest)
+MOCK_IMPL(download_status_t *,
+id_only_download_status_for_authority_id, (const char *digest))
{
download_status_t *dl = NULL;
cert_list_t *cl;
@@ -308,8 +308,8 @@ id_only_download_status_for_authority_id(const char *digest)
* for which download_status_t is potentially queryable, or NULL if no such
* authority ID digest is known. */
-smartlist_t *
-list_sk_digests_for_authority_id(const char *digest)
+MOCK_IMPL(smartlist_t *,
+list_sk_digests_for_authority_id, (const char *digest))
{
smartlist_t *sks = NULL;
cert_list_t *cl;
@@ -342,9 +342,9 @@ list_sk_digests_for_authority_id(const char *digest)
/** Given an authority ID digest and a signing key digest, return the
* download_status_t or NULL if none exists. */
-download_status_t *
-download_status_for_authority_id_and_sk(const char *id_digest,
- const char *sk_digest)
+MOCK_IMPL(download_status_t *,
+ download_status_for_authority_id_and_sk,
+ (const char *id_digest, const char *sk_digest))
{
download_status_t *dl = NULL;
cert_list_t *cl = NULL;
diff --git a/src/or/routerlist.h b/src/or/routerlist.h
index 65ba88db42..e75c922d4e 100644
--- a/src/or/routerlist.h
+++ b/src/or/routerlist.h
@@ -104,13 +104,13 @@ void routerlist_remove(routerlist_t *rl, routerinfo_t *ri, int make_old,
void routerlist_free_all(void);
void routerlist_reset_warnings(void);
-smartlist_t * list_authority_ids_with_downloads(void);
-download_status_t * id_only_download_status_for_authority_id(
- const char *digest);
-smartlist_t * list_sk_digests_for_authority_id(const char *digest);
-download_status_t * download_status_for_authority_id_and_sk(
- const char *id_digest,
- const char *sk_digest);
+MOCK_DECL(smartlist_t *, list_authority_ids_with_downloads, (void);)
+MOCK_DECL(download_status_t *, id_only_download_status_for_authority_id,
+ (const char *digest));
+MOCK_DECL(smartlist_t *, list_sk_digests_for_authority_id,
+ (const char *digest));
+MOCK_DECL(download_status_t *, download_status_for_authority_id_and_sk,
+ (const char *id_digest, const char *sk_digest));
static int WRA_WAS_ADDED(was_router_added_t s);
static int WRA_WAS_OUTDATED(was_router_added_t s);