mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-12-06 19:41:15 +01:00
Tests for simple cases of conscache code.
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user