]> Sergey Matveev's repositories - btrtrc.git/blob - main_test.go
Fix TestSetMaxEstablishedConn and allow it to be run with -count > 1
[btrtrc.git] / main_test.go
1 package torrent
2
3 import (
4         "io/ioutil"
5         "log"
6         "os"
7         "testing"
8 )
9
10 // A top-level temp dir that lasts for the duration of the package tests, and
11 // is removed at completion.
12 var pkgTempDir string
13
14 func init() {
15         log.SetFlags(log.LstdFlags | log.Lshortfile)
16         var err error
17         pkgTempDir, err = ioutil.TempDir("", "torrent.test")
18         if err != nil {
19                 panic(err)
20         }
21 }
22
23 func tempDir() string {
24         ret, err := ioutil.TempDir(pkgTempDir, "")
25         if err != nil {
26                 panic(err)
27         }
28         return ret
29 }
30
31 func TestMain(m *testing.M) {
32         code := m.Run()
33         os.RemoveAll(pkgTempDir)
34         // select {}
35         os.Exit(code)
36 }