unit-test: add nolint comment to avoid unused warning

since all generic* could bring unused linter warnings, which lead to
CI crash, we add nolint comment to avoid them.

Fixes: #1200

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Signed-off-by: Penny Zheng <penny.zheng@arm.com>
This commit is contained in:
Penny Zheng 2019-02-13 13:20:01 +08:00
parent 3ec56eaf9f
commit 1b967a4a6a
5 changed files with 15 additions and 8 deletions

View File

@ -52,9 +52,9 @@ const (
kernelPropertyCorrect = "Kernel property value correct" kernelPropertyCorrect = "Kernel property value correct"
// these refer to fields in the procCPUINFO file // these refer to fields in the procCPUINFO file
genericCPUFlagsTag = "flags" genericCPUFlagsTag = "flags" // nolint: varcheck, unused
genericCPUVendorField = "vendor_id" genericCPUVendorField = "vendor_id" // nolint: varcheck, unused
genericCPUModelField = "model name" genericCPUModelField = "model name" // nolint: varcheck, unused
) )
// variables rather than consts to allow tests to modify them // variables rather than consts to allow tests to modify them

View File

@ -121,12 +121,12 @@ func normalizeArmModel(model string) string {
return model return model
} }
func getCPUDetails() (vendor, model string, err error) { func getCPUDetails() (string, string, error) {
if vendor, model, err := genericGetCPUDetails(); err == nil { vendor, model, err := genericGetCPUDetails()
if err == nil {
vendor = normalizeArmVendor(vendor) vendor = normalizeArmVendor(vendor)
model = normalizeArmModel(model) model = normalizeArmModel(model)
return vendor, model, err }
} else {
return vendor, model, err return vendor, model, err
} }
}

View File

@ -27,12 +27,14 @@ type testModuleData struct {
contents string contents string
} }
// nolint: structcheck, unused
type testCPUData struct { type testCPUData struct {
vendorID string vendorID string
flags string flags string
expectError bool expectError bool
} }
// nolint: structcheck, unused
type testCPUDetail struct { type testCPUDetail struct {
contents string contents string
expectedVendor string expectedVendor string
@ -145,6 +147,7 @@ func makeCPUInfoFile(path, vendorID, flags string) error {
return ioutil.WriteFile(path, contents.Bytes(), testFileMode) return ioutil.WriteFile(path, contents.Bytes(), testFileMode)
} }
// nolint: unused
func genericTestGetCPUDetails(t *testing.T, validVendor string, validModel string, validContents string, data []testCPUDetail) { func genericTestGetCPUDetails(t *testing.T, validVendor string, validModel string, validContents string, data []testCPUDetail) {
tmpdir, err := ioutil.TempDir("", "") tmpdir, err := ioutil.TempDir("", "")
if err != nil { if err != nil {

View File

@ -244,6 +244,7 @@ func getExpectedAgentDetails(config oci.RuntimeConfig) (AgentInfo, error) {
}, nil }, nil
} }
// nolint: unused
func genericGetExpectedHostDetails(tmpdir string, expectedVendor string, expectedModel string) (HostInfo, error) { func genericGetExpectedHostDetails(tmpdir string, expectedVendor string, expectedModel string) (HostInfo, error) {
type filesToCreate struct { type filesToCreate struct {
file string file string

View File

@ -1407,6 +1407,7 @@ func (q *qemu) resizeMemory(reqMemMB uint32, memoryBlockSizeMB uint32) (uint32,
} }
// genericAppendBridges appends to devices the given bridges // genericAppendBridges appends to devices the given bridges
// nolint: unused
func genericAppendBridges(devices []govmmQemu.Device, bridges []types.PCIBridge, machineType string) []govmmQemu.Device { func genericAppendBridges(devices []govmmQemu.Device, bridges []types.PCIBridge, machineType string) []govmmQemu.Device {
bus := defaultPCBridgeBus bus := defaultPCBridgeBus
switch machineType { switch machineType {
@ -1438,6 +1439,7 @@ func genericAppendBridges(devices []govmmQemu.Device, bridges []types.PCIBridge,
return devices return devices
} }
// nolint: unused
func genericBridges(number uint32, machineType string) []types.PCIBridge { func genericBridges(number uint32, machineType string) []types.PCIBridge {
var bridges []types.PCIBridge var bridges []types.PCIBridge
var bt types.PCIType var bt types.PCIType
@ -1470,6 +1472,7 @@ func genericBridges(number uint32, machineType string) []types.PCIBridge {
return bridges return bridges
} }
// nolint: unused
func genericMemoryTopology(memoryMb, hostMemoryMb uint64, slots uint8, memoryOffset uint32) govmmQemu.Memory { func genericMemoryTopology(memoryMb, hostMemoryMb uint64, slots uint8, memoryOffset uint32) govmmQemu.Memory {
// image NVDIMM device needs memory space 1024MB // image NVDIMM device needs memory space 1024MB
// See https://github.com/clearcontainers/runtime/issues/380 // See https://github.com/clearcontainers/runtime/issues/380