github.com/AbhinandanKurakure/podman/v3@v3.4.10/libpod/network/cni/cni_suite_test.go (about) 1 // +build linux 2 3 package cni_test 4 5 import ( 6 "os" 7 "path/filepath" 8 "testing" 9 10 "github.com/containers/podman/v3/libpod/network/cni" 11 "github.com/containers/podman/v3/libpod/network/types" 12 "github.com/containers/podman/v3/test/utils" 13 . "github.com/onsi/ginkgo" 14 . "github.com/onsi/gomega" 15 ) 16 17 var cniPluginDirs = []string{ 18 "/usr/libexec/cni", 19 "/usr/lib/cni", 20 "/usr/local/lib/cni", 21 "/opt/cni/bin", 22 } 23 24 func TestCni(t *testing.T) { 25 RegisterFailHandler(Fail) 26 RunSpecs(t, "CNI Suite") 27 } 28 29 func getNetworkInterface(cniConfDir string, machine bool) (types.ContainerNetwork, error) { 30 return cni.NewCNINetworkInterface(cni.InitConfig{ 31 CNIConfigDir: cniConfDir, 32 CNIPluginDirs: cniPluginDirs, 33 IsMachine: machine, 34 LockFile: filepath.Join(cniConfDir, "cni.lock"), 35 }) 36 } 37 38 func SkipIfNoDnsname() { 39 for _, path := range cniPluginDirs { 40 f, err := os.Stat(filepath.Join(path, "dnsname")) 41 if err == nil && f.Mode().IsRegular() { 42 return 43 } 44 } 45 Skip("dnsname cni plugin needs to be installed for this test") 46 } 47 48 func SkipIfNotFedora(msg string) { 49 info := utils.GetHostDistributionInfo() 50 if info.Distribution != "fedora" { 51 Skip("Test can only run on Fedora: " + msg) 52 } 53 }