mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-11 06:03:57 +08:00
Merge pull request #2938 from kolyshkin/libct-int-nts
libcontainer/integration: nits
This commit is contained in:
@@ -11,9 +11,11 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/opencontainers/runc/libcontainer"
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
func showFile(t *testing.T, fname string) error {
|
||||
t.Helper()
|
||||
t.Logf("=== %s ===\n", fname)
|
||||
|
||||
f, err := os.Open(fname)
|
||||
@@ -188,19 +190,14 @@ func testCheckpoint(t *testing.T, userns bool) {
|
||||
pid, err = restoreProcessConfig.Pid()
|
||||
ok(t, err)
|
||||
|
||||
_, err = os.FindProcess(pid)
|
||||
err = unix.Kill(pid, 0)
|
||||
ok(t, err)
|
||||
|
||||
_, err = restoreStdinW.WriteString("Hello!")
|
||||
ok(t, err)
|
||||
|
||||
restoreStdinW.Close()
|
||||
s, err := restoreProcessConfig.Wait()
|
||||
ok(t, err)
|
||||
|
||||
if !s.Success() {
|
||||
t.Fatal(s.String(), pid)
|
||||
}
|
||||
waitProcess(restoreProcessConfig, t)
|
||||
|
||||
output := restoreStdout.String()
|
||||
if !strings.Contains(output, "Hello!") {
|
||||
|
||||
@@ -80,22 +80,21 @@ func (b *stdBuffers) String() string {
|
||||
|
||||
// ok fails the test if an err is not nil.
|
||||
func ok(t testing.TB, err error) {
|
||||
t.Helper()
|
||||
if err != nil {
|
||||
_, file, line, _ := runtime.Caller(1)
|
||||
t.Fatalf("%s:%d: unexpected error: %s\n\n", filepath.Base(file), line, err.Error())
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func waitProcess(p *libcontainer.Process, t *testing.T) {
|
||||
_, file, line, _ := runtime.Caller(1)
|
||||
t.Helper()
|
||||
status, err := p.Wait()
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf("%s:%d: unexpected error: %s\n\n", filepath.Base(file), line, err.Error())
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
|
||||
if !status.Success() {
|
||||
t.Fatalf("%s:%d: unexpected status: %s\n\n", filepath.Base(file), line, status.String())
|
||||
t.Fatalf("unexpected status: %v", status)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user