mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Fix race in remote_test.go
PiperOrigin-RevId: 447505504
This commit is contained in:
committed by
gVisor bot
parent
d5002c6adc
commit
b3609b7167
@@ -21,6 +21,7 @@ import (
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -46,10 +47,28 @@ func waitForFile(path string) error {
|
||||
}, 5*time.Second)
|
||||
}
|
||||
|
||||
type syncBuffer struct {
|
||||
mu sync.Mutex
|
||||
// +checklocks:mu
|
||||
buf bytes.Buffer
|
||||
}
|
||||
|
||||
func (s *syncBuffer) Write(p []byte) (n int, err error) {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
return s.buf.Write(p)
|
||||
}
|
||||
|
||||
func (s *syncBuffer) String() string {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
return s.buf.String()
|
||||
}
|
||||
|
||||
type exampleServer struct {
|
||||
path string
|
||||
cmd *exec.Cmd
|
||||
out bytes.Buffer
|
||||
out syncBuffer
|
||||
}
|
||||
|
||||
func newExampleServer(quiet bool) (*exampleServer, error) {
|
||||
|
||||
Reference in New Issue
Block a user