Skip to content

Commit 5c4ccc2

Browse files
author
Mrunal Patel
authored
Merge pull request #2938 from kolyshkin/libct-int-nts
libcontainer/integration: nits
2 parents 5fe1e98 + 0fabed7 commit 5c4ccc2

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

libcontainer/integration/checkpoint_test.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ import (
1111
"testing"
1212

1313
"github.com/opencontainers/runc/libcontainer"
14+
"golang.org/x/sys/unix"
1415
)
1516

1617
func showFile(t *testing.T, fname string) error {
18+
t.Helper()
1719
t.Logf("=== %s ===\n", fname)
1820

1921
f, err := os.Open(fname)
@@ -188,19 +190,14 @@ func testCheckpoint(t *testing.T, userns bool) {
188190
pid, err = restoreProcessConfig.Pid()
189191
ok(t, err)
190192

191-
_, err = os.FindProcess(pid)
193+
err = unix.Kill(pid, 0)
192194
ok(t, err)
193195

194196
_, err = restoreStdinW.WriteString("Hello!")
195197
ok(t, err)
196198

197199
restoreStdinW.Close()
198-
s, err := restoreProcessConfig.Wait()
199-
ok(t, err)
200-
201-
if !s.Success() {
202-
t.Fatal(s.String(), pid)
203-
}
200+
waitProcess(restoreProcessConfig, t)
204201

205202
output := restoreStdout.String()
206203
if !strings.Contains(output, "Hello!") {

libcontainer/integration/utils_test.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,22 +80,21 @@ func (b *stdBuffers) String() string {
8080

8181
// ok fails the test if an err is not nil.
8282
func ok(t testing.TB, err error) {
83+
t.Helper()
8384
if err != nil {
84-
_, file, line, _ := runtime.Caller(1)
85-
t.Fatalf("%s:%d: unexpected error: %s\n\n", filepath.Base(file), line, err.Error())
85+
t.Fatalf("unexpected error: %v", err)
8686
}
8787
}
8888

8989
func waitProcess(p *libcontainer.Process, t *testing.T) {
90-
_, file, line, _ := runtime.Caller(1)
90+
t.Helper()
9191
status, err := p.Wait()
92-
9392
if err != nil {
94-
t.Fatalf("%s:%d: unexpected error: %s\n\n", filepath.Base(file), line, err.Error())
93+
t.Fatalf("unexpected error: %v", err)
9594
}
9695

9796
if !status.Success() {
98-
t.Fatalf("%s:%d: unexpected status: %s\n\n", filepath.Base(file), line, status.String())
97+
t.Fatalf("unexpected status: %v", status)
9998
}
10099
}
101100

0 commit comments

Comments
 (0)