소스 검색

Fix some review comments and make Binutils mutex private. (#238)

Sanjay Ghemawat 7 년 전
부모
커밋
dc51073c52
2개의 변경된 파일11개의 추가작업 그리고 11개의 파일을 삭제
  1. 5
    5
      internal/binutils/binutils.go
  2. 6
    6
      internal/report/source_test.go

+ 5
- 5
internal/binutils/binutils.go 파일 보기

@@ -32,7 +32,7 @@ import (
32 32
 
33 33
 // A Binutils implements plugin.ObjTool by invoking the GNU binutils.
34 34
 type Binutils struct {
35
-	sync.Mutex
35
+	mu  sync.Mutex
36 36
 	rep *binrep
37 37
 }
38 38
 
@@ -56,22 +56,22 @@ type binrep struct {
56 56
 
57 57
 // get returns the current representation for bu, initializing it if necessary.
58 58
 func (bu *Binutils) get() *binrep {
59
-	bu.Mutex.Lock()
59
+	bu.mu.Lock()
60 60
 	r := bu.rep
61 61
 	if r == nil {
62 62
 		r = &binrep{}
63 63
 		initTools(r, "")
64 64
 		bu.rep = r
65 65
 	}
66
-	bu.Mutex.Unlock()
66
+	bu.mu.Unlock()
67 67
 	return r
68 68
 }
69 69
 
70 70
 // update modifies the rep for bu via the supplied function.
71 71
 func (bu *Binutils) update(fn func(r *binrep)) {
72 72
 	r := &binrep{}
73
-	bu.Mutex.Lock()
74
-	defer bu.Mutex.Unlock()
73
+	bu.mu.Lock()
74
+	defer bu.mu.Unlock()
75 75
 	if bu.rep == nil {
76 76
 		initTools(r, "")
77 77
 	} else {

+ 6
- 6
internal/report/source_test.go 파일 보기

@@ -14,8 +14,8 @@ import (
14 14
 )
15 15
 
16 16
 func TestWebList(t *testing.T) {
17
-	if runtime.GOOS != "linux" {
18
-		t.Skip("weblist only tested on linux")
17
+	if runtime.GOOS != "linux" || runtime.GOARCH != "amd64" {
18
+		t.Skip("weblist only tested on x86-64 linux")
19 19
 	}
20 20
 
21 21
 	cpu := readProfile(filepath.Join("testdata", "sample.cpu"), t)
@@ -40,8 +40,8 @@ func TestWebList(t *testing.T) {
40 40
 
41 41
 func TestIndentation(t *testing.T) {
42 42
 	for _, c := range []struct {
43
-		str    string
44
-		indent int
43
+		str        string
44
+		wantIndent int
45 45
 	}{
46 46
 		{"", 0},
47 47
 		{"foobar", 0},
@@ -52,8 +52,8 @@ func TestIndentation(t *testing.T) {
52 52
 		{"       \tfoo", 8},
53 53
 		{"        \tfoo", 16},
54 54
 	} {
55
-		if n := indentation(c.str); n != c.indent {
56
-			t.Errorf("indentation for %v: expect %d, got %d\n", c.str, c.indent, n)
55
+		if n := indentation(c.str); n != c.wantIndent {
56
+			t.Errorf("indentation(%v): got %d, want %d", c.str, n, c.wantIndent)
57 57
 		}
58 58
 	}
59 59
 }