소스 검색

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

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

14
 )
14
 )
15
 
15
 
16
 func TestWebList(t *testing.T) {
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
 	cpu := readProfile(filepath.Join("testdata", "sample.cpu"), t)
21
 	cpu := readProfile(filepath.Join("testdata", "sample.cpu"), t)
40
 
40
 
41
 func TestIndentation(t *testing.T) {
41
 func TestIndentation(t *testing.T) {
42
 	for _, c := range []struct {
42
 	for _, c := range []struct {
43
-		str    string
44
-		indent int
43
+		str        string
44
+		wantIndent int
45
 	}{
45
 	}{
46
 		{"", 0},
46
 		{"", 0},
47
 		{"foobar", 0},
47
 		{"foobar", 0},
52
 		{"       \tfoo", 8},
52
 		{"       \tfoo", 8},
53
 		{"        \tfoo", 16},
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
 }