Opened 10 years ago

Last modified 7 years ago

#991 closed defect (Fixed)

Unit tests broken in Tor master

Reported by: Sebastian Owned by:
Priority: Low Milestone:
Component: Core Tor/Tor Version: 0.2.1.15-rc
Severity: Keywords:
Cc: Sebastian Actual Points:
Parent ID: Points:
Reviewer: Sponsor:

Description

<sebastian> unit tests in master are broken
<sebastian> 5f03d6c547629af73dea2cfdaf888bc3a7caab5d is first bad commit
<sebastian> commit 5f03d6c547629af73dea2cfdaf888bc3a7caab5d
<sebastian> Author: Karsten Loesing <karsten.loesing@…>
<sebastian> Date: Tue May 26 21:41:42 2009 +0200
<sebastian> I'll look into fixing that tomorrow night if no-one else gets around to it
unit test output:

============================== geoip
..............
File test.c: line 4630 (test_geoip): Assertion failed: ("zz=24,ab=16,xy=8"==s)

("zz=24,ab=16,xy=8" != "ab=16")

make: * [test] Error 1

[Automatically added by flyspray2trac: Operating System: All]

Child Tickets

Change History (3)

comment:1 Changed 10 years ago by karsten

Closing this bug. See patch below (and in public branch fix991).

commit 732e7569e4e6da6f951c7402919f789d5d931e33
Author: Karsten Loesing <karsten.loesing@…>
Date: Wed May 27 23:47:59 2009 +0200

Fix unit tests that were broken after last fix of #932.


With the last fix of task 932 (5f03d6c), client requests are only added to
the history when they happen after the start of the current history. This
conflicts with the unit tests that insert current requests first (defining
the start of the client request history) followed by requests in the past.
The fix is to insert requests in chronological order in the unit tests.

diff --git a/src/or/test.c b/src/or/test.c
index 6ce0aae..6fbd3bf 100644
--- a/src/or/test.c
+++ b/src/or/test.c
@@ -4616,25 +4616,25 @@ test_geoip(void)

get_options()->BridgeRecordUsageByCountry = 1;
/* Put 9 observations in AB... */
for (i=32; i < 40; ++i)

  • geoip_note_client_seen(GEOIP_CLIENT_CONNECT, i, now);
  • geoip_note_client_seen(GEOIP_CLIENT_CONNECT, 225, now);

+ geoip_note_client_seen(GEOIP_CLIENT_CONNECT, i, now-7200);
+ geoip_note_client_seen(GEOIP_CLIENT_CONNECT, 225, now-7200);

/* and 3 observations in XY, several times. */
for (j=0; j < 10; ++j)

for (i=52; i < 55; ++i)

geoip_note_client_seen(GEOIP_CLIENT_CONNECT, i, now-3600);

/* and 17 observations in ZZ... */
for (i=110; i < 127; ++i)

  • geoip_note_client_seen(GEOIP_CLIENT_CONNECT, i, now-7200);

+ geoip_note_client_seen(GEOIP_CLIENT_CONNECT, i, now);

s = geoip_get_client_history(now+5*24*60*60, GEOIP_CLIENT_CONNECT);
test_assert(s);
test_streq("zz=24,ab=16,xy=8", s);
tor_free(s);


  • /* Now clear out all the zz observations. */

+ /* Now clear out all the AB observations. */

geoip_remove_old_clients(now-6000);
s = geoip_get_client_history(now+5*24*60*60, GEOIP_CLIENT_CONNECT);
test_assert(s);

  • test_streq("ab=16,xy=8", s);

+ test_streq("zz=24,xy=8", s);

done:

tor_free(s);

comment:2 Changed 10 years ago by karsten

flyspray2trac: bug closed.
Soon to be fixed.

comment:3 Changed 7 years ago by nickm

Component: Tor ClientTor
Note: See TracTickets for help on using tickets.