From 73e9bc914f43b21f3bed5eca5d2fc837cc5aa070 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Tue, 4 Apr 2017 13:51:34 -0400 Subject: Tests for simple cases of conscache code. --- src/or/conscache.c | 19 +++++++++++++++++++ src/or/conscache.h | 4 ++++ 2 files changed, 23 insertions(+) (limited to 'src/or') diff --git a/src/or/conscache.c b/src/or/conscache.c index 4bcf29cecf..2a6e1445e3 100644 --- a/src/or/conscache.c +++ b/src/or/conscache.c @@ -485,3 +485,22 @@ consensus_cache_entry_unmap(consensus_cache_entry_t *ent) ent->unused_since = TIME_MAX; } +#ifdef TOR_UNIT_TESTS +/** + * Testing only: Return true iff ent is mapped into memory. + * + * (In normal operation, this information is not exposed.) + */ +int +consensus_cache_entry_is_mapped(consensus_cache_entry_t *ent) +{ + if (ent->map) { + tor_assert(ent->body); + return 1; + } else { + tor_assert(!ent->body); + return 0; + } +} +#endif + diff --git a/src/or/conscache.h b/src/or/conscache.h index 0a0fc61071..94d7f15457 100644 --- a/src/or/conscache.h +++ b/src/or/conscache.h @@ -44,5 +44,9 @@ int consensus_cache_entry_get_body(const consensus_cache_entry_t *ent, const uint8_t **body_out, size_t *sz_out); +#ifdef TOR_UNIT_TESTS +int consensus_cache_entry_is_mapped(consensus_cache_entry_t *ent); +#endif + #endif -- cgit v1.2.3-54-g00ecf