diff --git a/testing/file_sharing_integration_test.go b/testing/file_sharing_integration_test.go index 2bc704c..de91c95 100644 --- a/testing/file_sharing_integration_test.go +++ b/testing/file_sharing_integration_test.go @@ -18,12 +18,16 @@ import ( "os" "os/user" "path" + "runtime" + "runtime/pprof" "testing" "time" ) func TestFileSharing(t *testing.T) { + numGoRoutinesStart := runtime.NumGoroutine() + os.RemoveAll("cwtch.out.png") os.RemoveAll("cwtch.out.png.manifest") @@ -96,6 +100,7 @@ func TestFileSharing(t *testing.T) { t.Fatalf("Error!") } + // Wait for the messages to arrive... time.Sleep(time.Second * 10) for _, message := range bob.GetContact(alice.GetOnion()).Timeline.GetMessages() { @@ -126,7 +131,18 @@ func TestFileSharing(t *testing.T) { t.Fatalf("file hash does not match expected %x: ", manifest.RootHash) } + queueOracle.Shutdown() app.Shutdown() acn.Close() + numGoRoutinesPostACN := runtime.NumGoroutine() + + // Printing out the current goroutines + // Very useful if we are leaking any. + pprof.Lookup("goroutine").WriteTo(os.Stdout, 1) + + 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) + } + }