Skip to content

Commit

Permalink
unit-test: add nolint comment to avoid unused warning
Browse files Browse the repository at this point in the history
since all generic* could bring unused linter warnings, which lead to
CI crash, we add nolint comment to avoid them.

Fixes: kata-containers#1200

Signed-off-by: Samuel Ortiz <[email protected]>
Signed-off-by: Penny Zheng <[email protected]>
  • Loading branch information
Pennyzct committed Feb 13, 2019
1 parent c2bdeb1 commit e670203
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 8 deletions.
6 changes: 3 additions & 3 deletions cli/kata-check.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ const (
kernelPropertyCorrect = "Kernel property value correct"

// these refer to fields in the procCPUINFO file
genericCPUFlagsTag = "flags"
genericCPUVendorField = "vendor_id"
genericCPUModelField = "model name"
genericCPUFlagsTag = "flags" // nolint: varcheck, unused
genericCPUVendorField = "vendor_id" // nolint: varcheck, unused
genericCPUModelField = "model name" // nolint: varcheck, unused
)

// variables rather than consts to allow tests to modify them
Expand Down
10 changes: 5 additions & 5 deletions cli/kata-check_arm64.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,12 @@ func normalizeArmModel(model string) string {
return model
}

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

return vendor, model, err
}
3 changes: 3 additions & 0 deletions cli/kata-check_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@ type testModuleData struct {
contents string
}

// nolint: structcheck, unused
type testCPUData struct {
vendorID string
flags string
expectError bool
}

// nolint: structcheck, unused
type testCPUDetail struct {
contents string
expectedVendor string
Expand Down Expand Up @@ -145,6 +147,7 @@ func makeCPUInfoFile(path, vendorID, flags string) error {
return ioutil.WriteFile(path, contents.Bytes(), testFileMode)
}

// nolint: unused
func genericTestGetCPUDetails(t *testing.T, validVendor string, validModel string, validContents string, data []testCPUDetail) {
tmpdir, err := ioutil.TempDir("", "")
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions cli/kata-env_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ func getExpectedAgentDetails(config oci.RuntimeConfig) (AgentInfo, error) {
}, nil
}

// nolint: unused
func genericGetExpectedHostDetails(tmpdir string, expectedVendor string, expectedModel string) (HostInfo, error) {
type filesToCreate struct {
file string
Expand Down
3 changes: 3 additions & 0 deletions virtcontainers/qemu.go
Original file line number Diff line number Diff line change
Expand Up @@ -1407,6 +1407,7 @@ func (q *qemu) resizeMemory(reqMemMB uint32, memoryBlockSizeMB uint32) (uint32,
}

// genericAppendBridges appends to devices the given bridges
// nolint: unused
func genericAppendBridges(devices []govmmQemu.Device, bridges []types.PCIBridge, machineType string) []govmmQemu.Device {
bus := defaultPCBridgeBus
switch machineType {
Expand Down Expand Up @@ -1438,6 +1439,7 @@ func genericAppendBridges(devices []govmmQemu.Device, bridges []types.PCIBridge,
return devices
}

// nolint: unused
func genericBridges(number uint32, machineType string) []types.PCIBridge {
var bridges []types.PCIBridge
var bt types.PCIType
Expand Down Expand Up @@ -1470,6 +1472,7 @@ func genericBridges(number uint32, machineType string) []types.PCIBridge {
return bridges
}

// nolint: unused
func genericMemoryTopology(memoryMb, hostMemoryMb uint64, slots uint8, memoryOffset uint32) govmmQemu.Memory {
// image NVDIMM device needs memory space 1024MB
// See https://github.com/clearcontainers/runtime/issues/380
Expand Down

0 comments on commit e670203

Please sign in to comment.