mirror of
https://github.com/aljazceru/kata-containers.git
synced 2026-01-01 13:34:20 +01:00
- Mostly blank lines after `+build` -- see https://pkg.go.dev/go/build@go1.14.15 -- this is, to date, enforced by `gofmt`. - 1.17-style go:build directives are also added. - Spaces in govmm/vmm_s390x.go Fixes: #3769 Signed-off-by: Jakob Naucke <jakob.naucke@ibm.com>
50 lines
1.1 KiB
Go
50 lines
1.1 KiB
Go
//go:build linux
|
|
// +build linux
|
|
|
|
// Copyright (c) 2018 Intel Corporation
|
|
//
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
//
|
|
|
|
package virtcontainers
|
|
|
|
import (
|
|
"net"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestCreateMacvlanEndpoint(t *testing.T) {
|
|
macAddr := net.HardwareAddr{0x02, 0x00, 0xCA, 0xFE, 0x00, 0x04}
|
|
|
|
expected := &MacvlanEndpoint{
|
|
NetPair: NetworkInterfacePair{
|
|
TapInterface: TapInterface{
|
|
ID: "uniqueTestID-4",
|
|
Name: "br4_kata",
|
|
TAPIface: NetworkInterface{
|
|
Name: "tap4_kata",
|
|
},
|
|
},
|
|
VirtIface: NetworkInterface{
|
|
Name: "eth4",
|
|
HardAddr: macAddr.String(),
|
|
},
|
|
NetInterworkingModel: DefaultNetInterworkingModel,
|
|
},
|
|
EndpointType: MacvlanEndpointType,
|
|
}
|
|
|
|
result, err := createMacvlanNetworkEndpoint(4, "", DefaultNetInterworkingModel)
|
|
assert.NoError(t, err)
|
|
|
|
// the resulting ID will be random - so let's overwrite to test the rest of the flow
|
|
result.NetPair.ID = "uniqueTestID-4"
|
|
|
|
// the resulting mac address will be random - so lets overwrite it
|
|
result.NetPair.VirtIface.HardAddr = macAddr.String()
|
|
|
|
assert.Exactly(t, result, expected)
|
|
}
|