diff options
author | Karsten Loesing <karsten.loesing@gmx.net> | 2010-11-23 21:09:12 +0100 |
---|---|---|
committer | Karsten Loesing <karsten.loesing@gmx.net> | 2010-11-24 08:45:05 +0100 |
commit | 4fed43ab2e84eacac738bce6ae74d41b71eb614c (patch) | |
tree | 1affb5fdb33307a24309d5dfce7e7a02f837e795 /src/test | |
parent | e57cb6b9762a2f94818738b5790d09c292e1bc24 (diff) | |
download | tor-4fed43ab2e84eacac738bce6ae74d41b71eb614c.tar tor-4fed43ab2e84eacac738bce6ae74d41b71eb614c.tar.gz |
Report only the top 10 ports in exit-port stats.
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/test.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/test/test.c b/src/test/test.c index 8d8c46fca..8782ef507 100644 --- a/src/test/test.c +++ b/src/test/test.c @@ -1081,6 +1081,7 @@ test_stats(void) { time_t now = 1281533250; /* 2010-08-11 13:27:30 UTC */ char *s = NULL; + int i; /* We shouldn't collect exit stats without initializing them. */ rep_hist_note_exit_stream_opened(80); @@ -1103,6 +1104,22 @@ test_stats(void) "exit-streams-opened 80=4,443=4,other=0\n", s); tor_free(s); + /* Add a few bytes on 10 more ports and ensure that only the top 10 + * ports are contained in the history string. */ + for (i = 50; i < 60; i++) { + rep_hist_note_exit_bytes(i, i, i); + rep_hist_note_exit_stream_opened(i); + } + s = rep_hist_format_exit_stats(now + 86400); + test_streq("exit-stats-end 2010-08-12 13:27:30 (86400 s)\n" + "exit-kibibytes-written 52=1,53=1,54=1,55=1,56=1,57=1,58=1," + "59=1,80=1,443=1,other=1\n" + "exit-kibibytes-read 52=1,53=1,54=1,55=1,56=1,57=1,58=1," + "59=1,80=10,443=20,other=1\n" + "exit-streams-opened 52=4,53=4,54=4,55=4,56=4,57=4,58=4," + "59=4,80=4,443=4,other=4\n", s); + tor_free(s); + /* Stop collecting stats, add some bytes, and ensure we don't generate * a history string. */ rep_hist_exit_stats_term(); |