github.com/datadog/cilium@v1.6.12/daemon/main_test.go (about) 1 // Copyright 2017 Authors of Cilium 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 // +build !privileged_tests 16 17 package main 18 19 import ( 20 go_version "github.com/hashicorp/go-version" 21 22 . "gopkg.in/check.v1" 23 ) 24 25 func (ds *DaemonSuite) TestParseKernelVersion(c *C) { 26 mustHaveVersion := func(v string) *go_version.Version { 27 ver, err := go_version.NewVersion(v) 28 c.Assert(err, IsNil) 29 return ver 30 } 31 32 var flagtests = []struct { 33 in string 34 out *go_version.Version 35 }{ 36 {"4.10.0", mustHaveVersion("4.10.0")}, 37 {"4.10", mustHaveVersion("4.10.0")}, 38 {"4.12.0+", mustHaveVersion("4.12.0")}, 39 {"4.12.8", mustHaveVersion("4.12.8")}, 40 {"4.14.0-rc7+", mustHaveVersion("4.14.0")}, 41 {"4.9.17-040917-generic", mustHaveVersion("4.9.17")}, 42 {"4.9.generic", mustHaveVersion("4.9.0")}, 43 } 44 for _, tt := range flagtests { 45 s, err := parseKernelVersion(tt.in) 46 c.Assert(err, IsNil) 47 c.Assert(tt.out.Equal(s), Equals, true) 48 } 49 }