aboutsummaryrefslogtreecommitdiff
path: root/src/test/test.c
diff options
context:
space:
mode:
authornils <nils@shkoo.com>2012-02-24 13:21:48 -0800
committerLinus Nordberg <linus@torproject.org>2012-10-17 10:54:52 +0200
commit31e224173bda6feb2e9894ba7b820affc3f44a9c (patch)
tree574cb7ad44c0e0d6cb5f2e1441149cf655683f4f /src/test/test.c
parentabb886014e1ee35909e8876fe3361cbfd26cc27c (diff)
downloadtor-31e224173bda6feb2e9894ba7b820affc3f44a9c.tar.gz
tor-31e224173bda6feb2e9894ba7b820affc3f44a9c.zip
Include statistics as to how many connections are IPv4 versus IPv6
Diffstat (limited to 'src/test/test.c')
-rw-r--r--src/test/test.c26
1 files changed, 21 insertions, 5 deletions
diff --git a/src/test/test.c b/src/test/test.c
index 04c35274a7..df0eddac75 100644
--- a/src/test/test.c
+++ b/src/test/test.c
@@ -1391,11 +1391,14 @@ test_geoip(void)
char *s = NULL;
const char *bridge_stats_1 =
"bridge-stats-end 2010-08-12 13:27:30 (86400 s)\n"
- "bridge-ips zz=24,xy=8\n",
+ "bridge-ips zz=24,xy=8\n"
+ "bridge-ip-versions v4=11,v6=9\n",
*dirreq_stats_1 =
"dirreq-stats-end 2010-08-12 13:27:30 (86400 s)\n"
"dirreq-v3-ips ab=8\n"
"dirreq-v2-ips \n"
+ "dirreq-v3-ip-versions v4=1,v6=0\n"
+ "dirreq-v2-ip-versions v4=0,v6=0\n"
"dirreq-v3-reqs ab=8\n"
"dirreq-v2-reqs \n"
"dirreq-v3-resp ok=0,not-enough-sigs=0,unavailable=0,not-found=0,"
@@ -1410,6 +1413,8 @@ test_geoip(void)
"dirreq-stats-end 2010-08-12 13:27:30 (86400 s)\n"
"dirreq-v3-ips \n"
"dirreq-v2-ips \n"
+ "dirreq-v3-ip-versions v4=0,v6=0\n"
+ "dirreq-v2-ip-versions v4=0,v6=0\n"
"dirreq-v3-reqs \n"
"dirreq-v2-reqs \n"
"dirreq-v3-resp ok=0,not-enough-sigs=0,unavailable=0,not-found=0,"
@@ -1424,6 +1429,8 @@ test_geoip(void)
"dirreq-stats-end 2010-08-12 13:27:30 (86400 s)\n"
"dirreq-v3-ips \n"
"dirreq-v2-ips \n"
+ "dirreq-v3-ip-versions v4=0,v6=0\n"
+ "dirreq-v2-ip-versions v4=0,v6=0\n"
"dirreq-v3-reqs \n"
"dirreq-v2-reqs \n"
"dirreq-v3-resp ok=8,not-enough-sigs=0,unavailable=0,not-found=0,"
@@ -1438,6 +1445,8 @@ test_geoip(void)
"dirreq-stats-end 2010-08-12 13:27:30 (86400 s)\n"
"dirreq-v3-ips \n"
"dirreq-v2-ips \n"
+ "dirreq-v3-ip-versions v4=0,v6=0\n"
+ "dirreq-v2-ip-versions v4=0,v6=0\n"
"dirreq-v3-reqs \n"
"dirreq-v2-reqs \n"
"dirreq-v3-resp ok=8,not-enough-sigs=0,unavailable=0,not-found=0,"
@@ -1450,12 +1459,15 @@ test_geoip(void)
"dirreq-v2-tunneled-dl complete=0,timeout=0,running=0\n",
*entry_stats_1 =
"entry-stats-end 2010-08-12 13:27:30 (86400 s)\n"
- "entry-ips ab=8\n",
+ "entry-ips ab=8\n"
+ "entry-ip-versions v4=1,v6=0\n",
*entry_stats_2 =
"entry-stats-end 2010-08-12 13:27:30 (86400 s)\n"
- "entry-ips \n";
+ "entry-ips \n"
+ "entry-ip-versions v4=0,v6=0\n";
tor_addr_t addr;
struct in6_addr in6;
+ int total_ipv4, total_ipv6;
/* Populate the DB a bit. Add these in order, since we can't do the final
* 'sort' step. These aren't very good IP addresses, but they're perfectly
@@ -1536,16 +1548,20 @@ test_geoip(void)
SET_TEST_ADDRESS(i);
geoip_note_client_seen(GEOIP_CLIENT_CONNECT, &addr, now);
}
- s = geoip_get_client_history(GEOIP_CLIENT_CONNECT);
+ s = geoip_get_client_history(GEOIP_CLIENT_CONNECT, &total_ipv4, &total_ipv6);
test_assert(s);
test_streq("zz=24,ab=16,xy=8", s);
+ test_eq(total_ipv4, 16);
+ test_eq(total_ipv6, 13);
tor_free(s);
/* Now clear out all the AB observations. */
geoip_remove_old_clients(now-6000);
- s = geoip_get_client_history(GEOIP_CLIENT_CONNECT);
+ s = geoip_get_client_history(GEOIP_CLIENT_CONNECT, &total_ipv4, &total_ipv6);
test_assert(s);
test_streq("zz=24,xy=8", s);
+ test_eq(total_ipv4, 11);
+ test_eq(total_ipv6, 9);
/* Start testing bridge statistics by making sure that we don't output
* bridge stats without initializing them. */