github.com/fabiokung/docker@v0.11.2-0.20170222101415-4534dcd49497/cmd/dockerd/config_unix_test.go (about)

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