|
|
@@ -8,6 +8,7 @@ import ( |
|
|
|
cwtchserver "cwtch.im/cwtch/server" |
|
|
|
"fmt" |
|
|
|
"git.openprivacy.ca/openprivacy/libricochet-go/connectivity" |
|
|
|
"git.openprivacy.ca/openprivacy/libricochet-go/log" |
|
|
|
"golang.org/x/net/proxy" |
|
|
|
"os" |
|
|
|
"runtime" |
|
|
@@ -100,6 +101,7 @@ func TestCwtchPeerIntegration(t *testing.T) { |
|
|
|
// Hide logging "noise" |
|
|
|
numGoRoutinesStart := runtime.NumGoroutine() |
|
|
|
|
|
|
|
log.AddEverythingFromPattern("connectivity") |
|
|
|
acn, err := connectivity.StartTor(".", "") |
|
|
|
if err != nil { |
|
|
|
t.Fatalf("Could not start Tor: %v", err) |
|
|
@@ -395,17 +397,22 @@ func TestCwtchPeerIntegration(t *testing.T) { |
|
|
|
time.Sleep(time.Second * 3) |
|
|
|
numGoRoutinesPostCarol := runtime.NumGoroutine() |
|
|
|
|
|
|
|
fmt.Println("Shutting down ACN...") |
|
|
|
acn.Close() |
|
|
|
time.Sleep(time.Second * 2) // Server ^^ has a 5 second loop attempting reconnect before exiting |
|
|
|
numGoRoutinesPostACN := runtime.NumGoroutine() |
|
|
|
|
|
|
|
// Printing out the current goroutines |
|
|
|
// Very useful if we are leaking any. |
|
|
|
pprof.Lookup("goroutine").WriteTo(os.Stdout, 1) |
|
|
|
|
|
|
|
fmt.Printf("numGoRoutinesStart: %v\nnumGoRoutinesPostServer: %v\nnumGoRoutinesPostPeerStart: %v\nnumGoRoutinesPostPeerAndServerConnect: %v\n"+ |
|
|
|
"numGoRoutinesPostAlice: %v\nnumGoRotinesPostCarolConnect: %v\nnumGoRoutinesPostBob: %v\nnumGoRoutinesPostServerShutdown: %v\nnumGoRoutinesPostCarol: %v\n", |
|
|
|
"numGoRoutinesPostAlice: %v\nnumGoRotinesPostCarolConnect: %v\nnumGoRoutinesPostBob: %v\nnumGoRoutinesPostServerShutdown: %v\nnumGoRoutinesPostCarol: %v\nnumGoRoutinesPostACN: %v\n", |
|
|
|
numGoRoutinesStart, numGoRoutinesPostServer, numGoRoutinesPostPeerStart, numGoRoutinesPostServerConnect, |
|
|
|
numGoRoutinesPostAlice, numGoRotinesPostCarolConnect, numGoRoutinesPostBob, numGoRoutinesPostServerShutdown, numGoRoutinesPostCarol) |
|
|
|
numGoRoutinesPostAlice, numGoRotinesPostCarolConnect, numGoRoutinesPostBob, numGoRoutinesPostServerShutdown, numGoRoutinesPostCarol, numGoRoutinesPostACN) |
|
|
|
|
|
|
|
if numGoRoutinesStart != numGoRoutinesPostCarol { |
|
|
|
t.Logf("Number of GoRoutines at start (%v) does not match number of goRoutines after cleanup of peers and servers (%v), clean up failed, leak detected!", numGoRoutinesStart, numGoRoutinesPostCarol) |
|
|
|
if numGoRoutinesStart != numGoRoutinesPostACN { |
|
|
|
t.Errorf("Number of GoRoutines at start (%v) does not match number of goRoutines after cleanup of peers and servers (%v), clean up failed, leak detected!", numGoRoutinesStart, numGoRoutinesPostACN) |
|
|
|
} |
|
|
|
|
|
|
|
} |