From d5e860e3dca8cd9159e17555541262c828d05976 Mon Sep 17 00:00:00 2001 From: Reinaldo de Souza Jr Date: Mon, 7 Sep 2015 14:04:51 -0500 Subject: Add tests for src/or/directory.c --- src/or/directory.c | 28 ++++++++++++++-------------- src/or/directory.h | 24 ++++++++++++++++-------- 2 files changed, 30 insertions(+), 22 deletions(-) (limited to 'src/or') diff --git a/src/or/directory.c b/src/or/directory.c index 9461606f1b..01ed69452a 100644 --- a/src/or/directory.c +++ b/src/or/directory.c @@ -143,7 +143,7 @@ purpose_needs_anonymity(uint8_t dir_purpose, uint8_t router_purpose) /** Return a newly allocated string describing auth. Only describes * authority features. */ -static char * +STATIC char * authdir_type_to_string(dirinfo_type_t auth) { char *result; @@ -162,7 +162,7 @@ authdir_type_to_string(dirinfo_type_t auth) } /** Return a string describing a given directory connection purpose. */ -static const char * +STATIC const char * dir_conn_purpose_to_string(int purpose) { switch (purpose) @@ -370,7 +370,7 @@ directory_post_to_dirservers(uint8_t dir_purpose, uint8_t router_purpose, /** Return true iff, according to the values in options, we should be * using directory guards for direct downloads of directory information. */ -static int +STATIC int should_use_directory_guards(const or_options_t *options) { /* Public (non-bridge) servers never use directory guards. */ @@ -666,15 +666,15 @@ directory_initiate_command_routerstatus_rend(const routerstatus_t *status, * When fetching a rendezvous descriptor, resource is the service ID we * want to fetch. */ -void -directory_initiate_command_routerstatus(const routerstatus_t *status, - uint8_t dir_purpose, - uint8_t router_purpose, - dir_indirection_t indirection, - const char *resource, - const char *payload, - size_t payload_len, - time_t if_modified_since) +MOCK_IMPL(void, directory_initiate_command_routerstatus, + (const routerstatus_t *status, + uint8_t dir_purpose, + uint8_t router_purpose, + dir_indirection_t indirection, + const char *resource, + const char *payload, + size_t payload_len, + time_t if_modified_since)) { directory_initiate_command_routerstatus_rend(status, dir_purpose, router_purpose, @@ -2593,7 +2593,7 @@ client_likes_consensus(networkstatus_t *v, const char *want_url) /** Return the compression level we should use for sending a compressed * response of size n_bytes. */ -static zlib_compression_level_t +STATIC zlib_compression_level_t choose_compression_level(ssize_t n_bytes) { if (! have_been_under_memory_pressure()) { @@ -3460,7 +3460,7 @@ connection_dir_finished_connecting(dir_connection_t *conn) * then return a list of int pointers defining download delays in seconds. * Helper function for download_status_increment_failure() and * download_status_reset(). */ -static const smartlist_t * +STATIC const smartlist_t * find_dl_schedule_and_len(download_status_t *dls, int server) { switch (dls->schedule) { diff --git a/src/or/directory.h b/src/or/directory.h index 4899eb5c8c..d859df3061 100644 --- a/src/or/directory.h +++ b/src/or/directory.h @@ -37,14 +37,16 @@ typedef enum { DIRIND_ANON_DIRPORT, } dir_indirection_t; -void directory_initiate_command_routerstatus(const routerstatus_t *status, - uint8_t dir_purpose, - uint8_t router_purpose, - dir_indirection_t indirection, - const char *resource, - const char *payload, - size_t payload_len, - time_t if_modified_since); +MOCK_DECL(void, directory_initiate_command_routerstatus, + (const routerstatus_t *status, + uint8_t dir_purpose, + uint8_t router_purpose, + dir_indirection_t indirection, + const char *resource, + const char *payload, + size_t payload_len, + time_t if_modified_since)); + void directory_initiate_command_routerstatus_rend(const routerstatus_t *status, uint8_t dir_purpose, uint8_t router_purpose, @@ -127,6 +129,12 @@ STATIC int purpose_needs_anonymity(uint8_t dir_purpose, uint8_t router_purpose); STATIC dirinfo_type_t dir_fetch_type(int dir_purpose, int router_purpose, const char *resource); +STATIC char* authdir_type_to_string(dirinfo_type_t auth); +STATIC const char * dir_conn_purpose_to_string(int purpose); +STATIC int should_use_directory_guards(const or_options_t *options); +STATIC zlib_compression_level_t choose_compression_level(ssize_t n_bytes); +STATIC const smartlist_t * find_dl_schedule_and_len(download_status_t *dls, + int server); #endif #endif -- cgit v1.2.3-54-g00ecf