diff options
author | David Goulet <dgoulet@torproject.org> | 2018-02-02 14:55:01 -0500 |
---|---|---|
committer | David Goulet <dgoulet@torproject.org> | 2018-02-02 14:55:01 -0500 |
commit | 475218c108ad84aa302f0daec013faab9ff778f2 (patch) | |
tree | 58054841fedbea9afe64297e00eedd5f5c0912d3 /src/test | |
parent | 33d9889a2bdd611bcc255c68c43d60b8919ab663 (diff) | |
parent | e758d659a0bc8b9a0e2bd6a0126755fd1fb58e0a (diff) | |
download | tor-475218c108ad84aa302f0daec013faab9ff778f2.tar.gz tor-475218c108ad84aa302f0daec013faab9ff778f2.zip |
Merge branch 'ticket25122_029_02' into ticket24902_029_05
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/test.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/test/test.c b/src/test/test.c index f66dee2d0a..70258addfd 100644 --- a/src/test/test.c +++ b/src/test/test.c @@ -912,6 +912,24 @@ test_geoip(void *arg) tt_str_op(entry_stats_2,OP_EQ, s); tor_free(s); + /* Test the OOM handler. Add a client, run the OOM. */ + geoip_entry_stats_init(now); + SET_TEST_ADDRESS(100); + geoip_note_client_seen(GEOIP_CLIENT_CONNECT, &addr, NULL, + now - (12 * 60 * 60)); + /* We've seen this 12 hours ago. Run the OOM, it should clean the entry + * because it is above the minimum cutoff of 4 hours. */ + size_t bytes_removed = geoip_client_cache_handle_oom(now, 1000); + tt_size_op(bytes_removed, OP_GT, 0); + + /* Do it again but this time with an entry with a lower cutoff. */ + geoip_entry_stats_init(now); + SET_TEST_ADDRESS(100); + geoip_note_client_seen(GEOIP_CLIENT_CONNECT, &addr, NULL, + now - (3 * 60 * 60)); + bytes_removed = geoip_client_cache_handle_oom(now, 1000); + tt_size_op(bytes_removed, OP_EQ, 0); + /* Stop collecting entry statistics. */ geoip_entry_stats_term(); get_options_mutable()->EntryStatistics = 0; |