github.com/damirazo/docker@v1.9.0/pkg/sysinfo/sysinfo_test.go (about)

     1  package sysinfo
     2  
     3  import "testing"
     4  
     5  func TestIsCpusetListAvailable(t *testing.T) {
     6  	cases := []struct {
     7  		provided  string
     8  		available string
     9  		res       bool
    10  		err       bool
    11  	}{
    12  		{"1", "0-4", true, false},
    13  		{"01,3", "0-4", true, false},
    14  		{"", "0-7", true, false},
    15  		{"1--42", "0-7", false, true},
    16  		{"1-42", "00-1,8,,9", false, true},
    17  		{"1,41-42", "43,45", false, false},
    18  		{"0-3", "", false, false},
    19  	}
    20  	for _, c := range cases {
    21  		r, err := isCpusetListAvailable(c.provided, c.available)
    22  		if (c.err && err == nil) && r != c.res {
    23  			t.Fatalf("Expected pair: %v, %v for %s, %s. Got %v, %v instead", c.res, c.err, c.provided, c.available, (c.err && err == nil), r)
    24  		}
    25  	}
    26  }