mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-11 06:03:57 +08:00
Merge pull request #2799 from kolyshkin/race1
Fix data races, enable testing with -race
This commit is contained in:
@@ -21,6 +21,7 @@ jobs:
|
||||
matrix:
|
||||
go-version: [1.14.x, 1.15.x, 1.16.x]
|
||||
rootless: ["rootless", ""]
|
||||
race: ["-race", ""]
|
||||
|
||||
steps:
|
||||
|
||||
@@ -41,7 +42,7 @@ jobs:
|
||||
go-version: ${{ matrix.go-version }}
|
||||
|
||||
- name: build
|
||||
run: sudo -E PATH="$PATH" make all
|
||||
run: sudo -E PATH="$PATH" make EXTRA_FLAGS="${{ matrix.race }}" all
|
||||
|
||||
- name: install bats
|
||||
uses: mig4/setup-bats@v1
|
||||
@@ -50,7 +51,7 @@ jobs:
|
||||
|
||||
- name: unit test
|
||||
if: matrix.rootless != 'rootless'
|
||||
run: sudo -E PATH="$PATH" -- make localunittest
|
||||
run: sudo -E PATH="$PATH" -- make TESTFLAGS="${{ matrix.race }}" localunittest
|
||||
|
||||
- name: add rootless user
|
||||
if: matrix.rootless == 'rootless'
|
||||
|
||||
@@ -20,7 +20,9 @@ ifneq ($(GO111MODULE),off)
|
||||
endif
|
||||
ifeq ($(shell $(GO) env GOOS),linux)
|
||||
ifeq (,$(filter $(shell $(GO) env GOARCH),mips mipsle mips64 mips64le ppc64))
|
||||
GO_BUILDMODE := "-buildmode=pie"
|
||||
ifeq (,$(findstring -race,$(EXTRA_FLAGS)))
|
||||
GO_BUILDMODE := "-buildmode=pie"
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
GO_BUILD := $(GO) build -trimpath $(MOD_VENDOR) $(GO_BUILDMODE) $(EXTRA_FLAGS) -tags "$(BUILDTAGS)" \
|
||||
|
||||
@@ -387,7 +387,7 @@ func (c Command) Run(s *specs.State) error {
|
||||
return err
|
||||
case <-timerCh:
|
||||
cmd.Process.Kill()
|
||||
cmd.Wait()
|
||||
<-errC
|
||||
return fmt.Errorf("hook ran past specified timeout of %.1fs", c.Timeout.Seconds())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,10 +194,11 @@ func testCheckpoint(t *testing.T, userns bool) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
var restoreStdout bytes.Buffer
|
||||
restoreProcessConfig := &libcontainer.Process{
|
||||
Cwd: "/",
|
||||
Stdin: restoreStdinR,
|
||||
Stdout: &stdout,
|
||||
Stdout: &restoreStdout,
|
||||
Init: true,
|
||||
}
|
||||
|
||||
@@ -242,7 +243,7 @@ func testCheckpoint(t *testing.T, userns bool) {
|
||||
t.Fatal(s.String(), pid)
|
||||
}
|
||||
|
||||
output := stdout.String()
|
||||
output := restoreStdout.String()
|
||||
if !strings.Contains(output, "Hello!") {
|
||||
t.Fatal("Did not restore the pipe correctly:", output)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user