Tests for simple cases of conscache code.

This commit is contained in:
Nick Mathewson
2017-04-04 13:51:34 -04:00
parent 4404dc5756
commit 73e9bc914f
6 changed files with 137 additions and 0 deletions
+19
View File
@@ -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 <b>ent</b> 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
+4
View File
@@ -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