github.com/hanks177/podman/v4@v4.1.3-0.20220613032544-16d90015bc83/test/e2e/create_staticmac_test.go (about) 1 package integration 2 3 import ( 4 "os" 5 6 "github.com/hanks177/podman/v4/pkg/rootless" 7 . "github.com/hanks177/podman/v4/test/utils" 8 "github.com/containers/storage/pkg/stringid" 9 . "github.com/onsi/ginkgo" 10 . "github.com/onsi/gomega" 11 . "github.com/onsi/gomega/gexec" 12 ) 13 14 var _ = Describe("Podman run with --mac-address flag", func() { 15 var ( 16 tempdir string 17 err error 18 podmanTest *PodmanTestIntegration 19 ) 20 21 BeforeEach(func() { 22 tempdir, err = CreateTempDirInTempDir() 23 if err != nil { 24 os.Exit(1) 25 } 26 podmanTest = PodmanTestCreate(tempdir) 27 podmanTest.Setup() 28 // Cleanup the CNI networks used by the tests 29 os.RemoveAll("/var/lib/cni/networks/podman") 30 }) 31 32 AfterEach(func() { 33 podmanTest.Cleanup() 34 f := CurrentGinkgoTestDescription() 35 processTestResult(f) 36 37 }) 38 39 It("Podman run --mac-address", func() { 40 result := podmanTest.Podman([]string{"run", "--mac-address", "92:d0:c6:0a:29:34", ALPINE, "ip", "addr"}) 41 result.WaitWithDefaultTimeout() 42 if rootless.IsRootless() { 43 Expect(result).Should(Exit(125)) 44 } else { 45 Expect(result).Should(Exit(0)) 46 Expect(result.OutputToString()).To(ContainSubstring("92:d0:c6:0a:29:34")) 47 } 48 }) 49 50 It("Podman run --mac-address with custom network", func() { 51 net := "n1" + stringid.GenerateNonCryptoID() 52 session := podmanTest.Podman([]string{"network", "create", net}) 53 session.WaitWithDefaultTimeout() 54 defer podmanTest.removeNetwork(net) 55 Expect(session).Should(Exit(0)) 56 57 result := podmanTest.Podman([]string{"run", "--network", net, "--mac-address", "92:d0:c6:00:29:34", ALPINE, "ip", "addr"}) 58 result.WaitWithDefaultTimeout() 59 Expect(result).Should(Exit(0)) 60 Expect(result.OutputToString()).To(ContainSubstring("92:d0:c6:00:29:34")) 61 }) 62 })