mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
integration-cli: avoid allocations with (*os.File).WriteString (mirror)
integration-cli/docker_cli_attach_unix_test.go:107:3: avoid allocations with (*os.File).WriteString (mirror)
cpty.Write([]byte("\n"))
^
integration-cli/docker_cli_attach_unix_test.go:144:11: avoid allocations with (*os.File).WriteString (mirror)
_, err = cpty.Write([]byte("hello\n"))
^
integration-cli/docker_cli_exec_test.go:422:16: avoid allocations with (*os.File).WriteString (mirror)
if _, err := f.Write([]byte("success2\n")); err != nil {
^
integration-cli/docker_cli_exec_unix_test.go:57:11: avoid allocations with (*os.File).WriteString (mirror)
_, err = p.Write([]byte("cat /foo && exit\n"))
^
integration-cli/docker_cli_run_test.go:4092:15: avoid allocations with (*os.File).WriteString (mirror)
if _, err := tmpFile.Write([]byte(data)); err != nil {
^
integration-cli/docker_cli_run_unix_test.go:110:11: avoid allocations with (*os.File).WriteString (mirror)
_, err = cpty.Write([]byte("hello\n"))
^
integration-cli/docker_cli_run_unix_test.go:169:15: avoid allocations with (*os.File).WriteString (mirror)
if _, err := cpty.Write([]byte("hello\n")); err != nil {
^
integration-cli/docker_cli_run_unix_test.go:283:15: avoid allocations with (*os.File).WriteString (mirror)
if _, err := cpty.Write([]byte("hello\n")); err != nil {
^
integration-cli/docker_cli_run_unix_test.go:364:15: avoid allocations with (*os.File).WriteString (mirror)
if _, err := cpty.Write([]byte("hello\n")); err != nil {
^
integration-cli/docker_cli_run_unix_test.go:438:15: avoid allocations with (*os.File).WriteString (mirror)
if _, err := cpty.Write([]byte("\n")); err != nil {
^
integration-cli/docker_cli_run_unix_test.go:880:15: avoid allocations with (*os.File).WriteString (mirror)
if _, err := tmpFile.Write([]byte(jsonData)); err != nil {
^
integration-cli/docker_cli_run_unix_test.go:915:15: avoid allocations with (*os.File).WriteString (mirror)
if _, err := tmpFile.Write([]byte(jsonData)); err != nil {
^
integration-cli/docker_cli_run_unix_test.go:952:15: avoid allocations with (*os.File).WriteString (mirror)
if _, err := tmpFile.Write([]byte(jsonData)); err != nil {
^
integration-cli/docker_cli_run_unix_test.go:1418:11: avoid allocations with (*os.File).WriteString (mirror)
_, err = tmpFile.Write([]byte(jsonData))
^
integration-cli/docker_cli_run_unix_test.go:1445:11: avoid allocations with (*os.File).WriteString (mirror)
_, err = tmpFile.Write([]byte(jsonData))
^
integration-cli/docker_cli_run_unix_test.go:1483:11: avoid allocations with (*os.File).WriteString (mirror)
_, err = tmpFile.Write([]byte(jsonData))
^
integration-cli/docker_cli_run_unix_test.go:1517:11: avoid allocations with (*os.File).WriteString (mirror)
_, err = tmpFile.Write([]byte(jsonData))
^
integration-cli/docker_cli_update_unix_test.go:235:11: avoid allocations with (*os.File).WriteString (mirror)
_, err = cpty.Write([]byte("exit\n"))
^
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@@ -107,7 +107,7 @@ func (s *DockerCLIRunSuite) TestRunAttachDetach(c *testing.T) {
|
||||
assert.NilError(c, cmd.Start())
|
||||
cli.WaitRun(c, name)
|
||||
|
||||
_, err = cpty.Write([]byte("hello\n"))
|
||||
_, err = cpty.WriteString("hello\n")
|
||||
assert.NilError(c, err)
|
||||
|
||||
out, err := bufio.NewReader(stdout).ReadString('\n')
|
||||
@@ -166,7 +166,7 @@ func (s *DockerCLIRunSuite) TestRunAttachDetachFromFlag(c *testing.T) {
|
||||
}
|
||||
cli.WaitRun(c, name)
|
||||
|
||||
if _, err := cpty.Write([]byte("hello\n")); err != nil {
|
||||
if _, err := cpty.WriteString("hello\n"); err != nil {
|
||||
c.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -280,7 +280,7 @@ func (s *DockerCLIRunSuite) TestRunAttachDetachFromConfig(c *testing.T) {
|
||||
}
|
||||
cli.WaitRun(c, name)
|
||||
|
||||
if _, err := cpty.Write([]byte("hello\n")); err != nil {
|
||||
if _, err := cpty.WriteString("hello\n"); err != nil {
|
||||
c.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -361,7 +361,7 @@ func (s *DockerCLIRunSuite) TestRunAttachDetachKeysOverrideConfig(c *testing.T)
|
||||
}
|
||||
cli.WaitRun(c, name)
|
||||
|
||||
if _, err := cpty.Write([]byte("hello\n")); err != nil {
|
||||
if _, err := cpty.WriteString("hello\n"); err != nil {
|
||||
c.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -400,8 +400,8 @@ func (s *DockerCLIRunSuite) TestRunAttachDetachKeysOverrideConfig(c *testing.T)
|
||||
|
||||
func (s *DockerCLIRunSuite) TestRunAttachInvalidDetachKeySequencePreserved(c *testing.T) {
|
||||
const name = "attach-detach"
|
||||
keyA := []byte{97}
|
||||
keyB := []byte{98}
|
||||
const keyA = "a"
|
||||
const keyB = "b"
|
||||
|
||||
cli.DockerCmd(c, "run", "--name", name, "-itd", "busybox", "cat")
|
||||
|
||||
@@ -423,19 +423,19 @@ func (s *DockerCLIRunSuite) TestRunAttachInvalidDetachKeySequencePreserved(c *te
|
||||
cli.WaitRun(c, name)
|
||||
|
||||
// Invalid escape sequence aba, should print aba in output
|
||||
if _, err := cpty.Write(keyA); err != nil {
|
||||
if _, err := cpty.WriteString(keyA); err != nil {
|
||||
c.Fatal(err)
|
||||
}
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
if _, err := cpty.Write(keyB); err != nil {
|
||||
if _, err := cpty.WriteString(keyB); err != nil {
|
||||
c.Fatal(err)
|
||||
}
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
if _, err := cpty.Write(keyA); err != nil {
|
||||
if _, err := cpty.WriteString(keyA); err != nil {
|
||||
c.Fatal(err)
|
||||
}
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
if _, err := cpty.Write([]byte("\n")); err != nil {
|
||||
if _, err := cpty.WriteString("\n"); err != nil {
|
||||
c.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -443,8 +443,10 @@ func (s *DockerCLIRunSuite) TestRunAttachInvalidDetachKeySequencePreserved(c *te
|
||||
if err != nil {
|
||||
c.Fatal(err)
|
||||
}
|
||||
if strings.TrimSpace(out) != "aba" {
|
||||
c.Fatalf("expected 'aba', got %q", out)
|
||||
|
||||
expected := keyA + keyB + keyA
|
||||
if strings.TrimSpace(out) != expected {
|
||||
c.Fatalf("expected '%s', got %q", expected, out)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -877,7 +879,7 @@ func (s *DockerCLIRunSuite) TestRunSeccompProfileDenyUnshare(c *testing.T) {
|
||||
}
|
||||
defer tmpFile.Close()
|
||||
|
||||
if _, err := tmpFile.Write([]byte(jsonData)); err != nil {
|
||||
if _, err := tmpFile.WriteString(jsonData); err != nil {
|
||||
c.Fatal(err)
|
||||
}
|
||||
icmd.RunCommand(dockerBinary, "run", "--security-opt", "apparmor=unconfined",
|
||||
@@ -912,7 +914,7 @@ func (s *DockerCLIRunSuite) TestRunSeccompProfileDenyChmod(c *testing.T) {
|
||||
assert.NilError(c, err)
|
||||
defer tmpFile.Close()
|
||||
|
||||
if _, err := tmpFile.Write([]byte(jsonData)); err != nil {
|
||||
if _, err := tmpFile.WriteString(jsonData); err != nil {
|
||||
c.Fatal(err)
|
||||
}
|
||||
icmd.RunCommand(dockerBinary, "run", "--security-opt", "seccomp="+tmpFile.Name(),
|
||||
@@ -949,7 +951,7 @@ func (s *DockerCLIRunSuite) TestRunSeccompProfileDenyUnshareUserns(c *testing.T)
|
||||
}
|
||||
defer tmpFile.Close()
|
||||
|
||||
if _, err := tmpFile.Write([]byte(jsonData)); err != nil {
|
||||
if _, err := tmpFile.WriteString(jsonData); err != nil {
|
||||
c.Fatal(err)
|
||||
}
|
||||
icmd.RunCommand(dockerBinary, "run",
|
||||
@@ -1415,7 +1417,7 @@ func (s *DockerDaemonSuite) TestRunSeccompJSONNewFormat(c *testing.T) {
|
||||
tmpFile, err := os.CreateTemp("", "profile.json")
|
||||
assert.NilError(c, err)
|
||||
defer tmpFile.Close()
|
||||
_, err = tmpFile.Write([]byte(jsonData))
|
||||
_, err = tmpFile.WriteString(jsonData)
|
||||
assert.NilError(c, err)
|
||||
|
||||
out, err := s.d.Cmd("run", "--security-opt", "seccomp="+tmpFile.Name(), "busybox", "chmod", "777", ".")
|
||||
@@ -1442,7 +1444,7 @@ func (s *DockerDaemonSuite) TestRunSeccompJSONNoNameAndNames(c *testing.T) {
|
||||
tmpFile, err := os.CreateTemp("", "profile.json")
|
||||
assert.NilError(c, err)
|
||||
defer tmpFile.Close()
|
||||
_, err = tmpFile.Write([]byte(jsonData))
|
||||
_, err = tmpFile.WriteString(jsonData)
|
||||
assert.NilError(c, err)
|
||||
|
||||
out, err := s.d.Cmd("run", "--security-opt", "seccomp="+tmpFile.Name(), "busybox", "chmod", "777", ".")
|
||||
@@ -1480,7 +1482,7 @@ func (s *DockerDaemonSuite) TestRunSeccompJSONNoArchAndArchMap(c *testing.T) {
|
||||
tmpFile, err := os.CreateTemp("", "profile.json")
|
||||
assert.NilError(c, err)
|
||||
defer tmpFile.Close()
|
||||
_, err = tmpFile.Write([]byte(jsonData))
|
||||
_, err = tmpFile.WriteString(jsonData)
|
||||
assert.NilError(c, err)
|
||||
|
||||
out, err := s.d.Cmd("run", "--security-opt", "seccomp="+tmpFile.Name(), "busybox", "chmod", "777", ".")
|
||||
@@ -1514,7 +1516,7 @@ func (s *DockerDaemonSuite) TestRunWithDaemonDefaultSeccompProfile(c *testing.T)
|
||||
tmpFile, err := os.CreateTemp("", "profile.json")
|
||||
assert.NilError(c, err)
|
||||
defer tmpFile.Close()
|
||||
_, err = tmpFile.Write([]byte(jsonData))
|
||||
_, err = tmpFile.WriteString(jsonData)
|
||||
assert.NilError(c, err)
|
||||
|
||||
// 2) restart the daemon and add a custom seccomp profile in which we deny chmod
|
||||
|
||||
Reference in New Issue
Block a user