diff options
author | Nick Mathewson <nickm@torproject.org> | 2018-12-03 14:06:53 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2018-12-05 09:24:45 -0500 |
commit | a2f81b644b2a4679c634744d3830cdb6397f0814 (patch) | |
tree | 3242f87650d1a34d6ae0fe6cce32bee94b22dcdc /src/feature | |
parent | 31a6d9f49997cfb1266a55b742a15706ae16db5e (diff) | |
download | tor-a2f81b644b2a4679c634744d3830cdb6397f0814.tar.gz tor-a2f81b644b2a4679c634744d3830cdb6397f0814.zip |
Write tests for mark_my_descriptor_dirty_if_too_old()
Diffstat (limited to 'src/feature')
-rw-r--r-- | src/feature/nodelist/networkstatus.c | 4 | ||||
-rw-r--r-- | src/feature/nodelist/networkstatus.h | 5 | ||||
-rw-r--r-- | src/feature/relay/router.c | 4 | ||||
-rw-r--r-- | src/feature/relay/router.h | 4 |
4 files changed, 11 insertions, 6 deletions
diff --git a/src/feature/nodelist/networkstatus.c b/src/feature/nodelist/networkstatus.c index f1def9afb1..a730f7d834 100644 --- a/src/feature/nodelist/networkstatus.c +++ b/src/feature/nodelist/networkstatus.c @@ -724,8 +724,8 @@ networkstatus_vote_find_mutable_entry(networkstatus_t *ns, const char *digest) /** Return the entry in <b>ns</b> for the identity digest <b>digest</b>, or * NULL if none was found. */ -const routerstatus_t * -networkstatus_vote_find_entry(networkstatus_t *ns, const char *digest) +MOCK_IMPL(const routerstatus_t *, +networkstatus_vote_find_entry,(networkstatus_t *ns, const char *digest)) { return networkstatus_vote_find_mutable_entry(ns, digest); } diff --git a/src/feature/nodelist/networkstatus.h b/src/feature/nodelist/networkstatus.h index 8802de2d65..3fd151cf37 100644 --- a/src/feature/nodelist/networkstatus.h +++ b/src/feature/nodelist/networkstatus.h @@ -40,8 +40,9 @@ int compare_digest_to_routerstatus_entry(const void *_key, const void **_member); int compare_digest_to_vote_routerstatus_entry(const void *_key, const void **_member); -const routerstatus_t *networkstatus_vote_find_entry(networkstatus_t *ns, - const char *digest); +MOCK_DECL(const routerstatus_t *,networkstatus_vote_find_entry,( + networkstatus_t *ns, + const char *digest)); routerstatus_t *networkstatus_vote_find_mutable_entry(networkstatus_t *ns, const char *digest); int networkstatus_vote_find_entry_idx(networkstatus_t *ns, diff --git a/src/feature/relay/router.c b/src/feature/relay/router.c index 2d4ab9b0a0..ef433db8bc 100644 --- a/src/feature/relay/router.c +++ b/src/feature/relay/router.c @@ -1471,9 +1471,9 @@ static extrainfo_t *desc_extrainfo = NULL; static const char *desc_gen_reason = "uninitialized reason"; /** Since when has our descriptor been "clean"? 0 if we need to regenerate it * now. */ -static time_t desc_clean_since = 0; +STATIC time_t desc_clean_since = 0; /** Why did we mark the descriptor dirty? */ -static const char *desc_dirty_reason = "Tor just started"; +STATIC const char *desc_dirty_reason = "Tor just started"; /** Boolean: do we need to regenerate the above? */ static int desc_needs_upload = 0; diff --git a/src/feature/relay/router.h b/src/feature/relay/router.h index 4575172afb..217511df9f 100644 --- a/src/feature/relay/router.h +++ b/src/feature/relay/router.h @@ -117,6 +117,10 @@ void router_free_all(void); /* Used only by router.c and test.c */ STATIC void get_platform_str(char *platform, size_t len); STATIC int router_write_fingerprint(int hashed); +#ifdef TOR_UNIT_TESTS +extern time_t desc_clean_since; +extern const char *desc_dirty_reason; +#endif #endif #endif /* !defined(TOR_ROUTER_H) */ |