]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Fix TestUnmountWedged test on OSX
authorMatt Joiner <anacrolix@gmail.com>
Sun, 11 Jan 2015 02:21:14 +0000 (13:21 +1100)
committerMatt Joiner <anacrolix@gmail.com>
Sun, 11 Jan 2015 02:21:14 +0000 (13:21 +1100)
fs/torrentfs_test.go

index a3297455627b3ed54923c48a13843357cd691948..369071e98c21355efe3bc5d03a082bdbfdd3424f 100644 (file)
@@ -4,7 +4,6 @@ import (
        "bytes"
        "fmt"
        "io/ioutil"
-       "log"
        "net"
        "net/http"
        _ "net/http/pprof"
@@ -13,6 +12,7 @@ import (
        "strconv"
        "strings"
        "testing"
+       "time"
 
        "bitbucket.org/anacrolix/go.torrent"
        "bitbucket.org/anacrolix/go.torrent/testutil"
@@ -73,7 +73,6 @@ func newGreetingLayout() (tl testLayout, err error) {
        metaInfoBuf := &bytes.Buffer{}
        testutil.CreateMetaInfo(name, metaInfoBuf)
        tl.Metainfo, err = metainfo.Load(metaInfoBuf)
-       log.Printf("%x", tl.Metainfo.Info.Pieces)
        return
 }
 
@@ -98,7 +97,6 @@ func TestUnmountWedged(t *testing.T) {
                NoDefaultBlocklist: true,
        })
        defer client.Stop()
-       t.Logf("%+v", *layout.Metainfo)
        client.AddTorrent(layout.Metainfo)
        fs := New(client)
        fuseConn, err := fuse.Mount(layout.MountDir)
@@ -108,10 +106,6 @@ func TestUnmountWedged(t *testing.T) {
                }
                t.Fatal(err)
        }
-       <-fuseConn.Ready
-       if err := fuseConn.MountError; err != nil {
-               t.Fatal(err)
-       }
        go func() {
                server := fusefs.Server{
                        FS: fs,
@@ -121,6 +115,10 @@ func TestUnmountWedged(t *testing.T) {
                }
                server.Serve(fuseConn)
        }()
+       <-fuseConn.Ready
+       if err := fuseConn.MountError; err != nil {
+               t.Fatal(err)
+       }
        // Read the greeting file, though it will never be available. This should
        // "wedge" FUSE, requiring the fs object to be forcibly destroyed. The
        // read call will return with a FS error.
@@ -144,6 +142,7 @@ func TestUnmountWedged(t *testing.T) {
                err = fuse.Unmount(layout.MountDir)
                if err != nil {
                        t.Logf("error unmounting: %s", err)
+                       time.Sleep(time.Millisecond)
                } else {
                        break
                }