config_unix_test.go 907 B

1234567891011121314151617181920212223242526272829303132
  1. // +build linux,!solaris freebsd,!solaris
  2. package main
  3. import (
  4. "runtime"
  5. "testing"
  6. "github.com/docker/docker/daemon/config"
  7. "github.com/docker/docker/pkg/testutil/assert"
  8. "github.com/spf13/pflag"
  9. )
  10. func TestDaemonParseShmSize(t *testing.T) {
  11. if runtime.GOOS == "solaris" {
  12. t.Skip("ShmSize not supported on Solaris\n")
  13. }
  14. flags := pflag.NewFlagSet("test", pflag.ContinueOnError)
  15. conf := &config.Config{}
  16. installConfigFlags(conf, flags)
  17. // By default `--default-shm-size=64M`
  18. expectedValue := 64 * 1024 * 1024
  19. if conf.ShmSize.Value() != int64(expectedValue) {
  20. t.Fatalf("expected default shm size %d, got %d", expectedValue, conf.ShmSize.Value())
  21. }
  22. assert.NilError(t, flags.Set("default-shm-size", "128M"))
  23. expectedValue = 128 * 1024 * 1024
  24. if conf.ShmSize.Value() != int64(expectedValue) {
  25. t.Fatalf("expected default shm size %d, got %d", expectedValue, conf.ShmSize.Value())
  26. }
  27. }