docker_cli_create_unix_test.go 949 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // +build !windows
  2. package main
  3. import (
  4. "strings"
  5. "github.com/go-check/check"
  6. )
  7. // Test case for #30166 (target was not validated)
  8. func (s *DockerSuite) TestCreateTmpfsMountsTarget(c *check.C) {
  9. testRequires(c, DaemonIsLinux)
  10. type testCase struct {
  11. target string
  12. expectedError string
  13. }
  14. cases := []testCase{
  15. {
  16. target: ".",
  17. expectedError: "mount path must be absolute",
  18. },
  19. {
  20. target: "foo",
  21. expectedError: "mount path must be absolute",
  22. },
  23. {
  24. target: "/",
  25. expectedError: "destination can't be '/'",
  26. },
  27. {
  28. target: "//",
  29. expectedError: "destination can't be '/'",
  30. },
  31. }
  32. for _, x := range cases {
  33. out, _, _ := dockerCmdWithError("create", "--tmpfs", x.target, "busybox", "sh")
  34. if x.expectedError != "" && !strings.Contains(out, x.expectedError) {
  35. c.Fatalf("mounting tmpfs over %q should fail with %q, but got %q",
  36. x.target, x.expectedError, out)
  37. }
  38. }
  39. }