Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
SchSeba committed Jan 11, 2025
2 parents d333596 + 4e22051 commit 006c401
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 5 deletions.
12 changes: 12 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ GOLANGCI_LINT_VERSION = v1.52.2
$(GOLANGCI_LINT): | $(BINDIR) ; $(info Installing golangci-lint...)
$Q GOBIN=$(BINDIR) $(GO) install github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION)

# Tools
MOCKERY = $(BINDIR)/mockery
MOCKERY_VERSION = v2.50.2
$(MOCKERY): | $(BINDIR) ; $(info Installing mockery...)
$Q GOBIN=$(BINDIR) $(GO) install github.com/vektra/mockery/v2@$(MOCKERY_VERSION)

# Tests
TEST_TARGETS := test-default test-verbose test-race
.PHONY: $(TEST_TARGETS) test
Expand All @@ -76,6 +82,12 @@ test-coverage: | $(COVERAGE_DIR) ; $(info Running coverage tests...) @ ## Run c
lint: $(GOLANGCI_LINT) ; $(info Running golangci-lint linter...) @ ## Run golangci-lint linter
$Q $(GOLANGCI_LINT) run

.PHONY: mock-generate
mock-generate: $(MOCKERY) ; $(info Running mockery...) @ ## Run golangci-lint linter
$Q $(MOCKERY) --recursive=true --name=NetlinkManager --output=./pkg/utils/mocks/ --filename=netlink_manager_mock.go --exported --dir pkg/utils
$Q $(MOCKERY) --recursive=true --name=pciUtils --output=./pkg/sriov/mocks/ --filename=pci_utils_mock.go --exported --dir pkg/sriov


.PHONY: fmt
fmt: ; $(info Running go fmt...) @ ## Run go fmt on all source files
@ $(GO) fmt ./...
Expand Down
22 changes: 21 additions & 1 deletion pkg/sriov/mocks/pci_utils_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

54 changes: 53 additions & 1 deletion pkg/utils/mocks/netlink_manager_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions pkg/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,14 @@ func GetVFLinkName(pciAddr string) (string, error) {
return "", fmt.Errorf("VF device %s sysfs path (%s) has no entries", pciAddr, vfDir)
}

names = make([]string, 0)
for _, f := range fInfos {
names = append(names, f.Name())
names = make([]string, len(fInfos))
for idx, f := range fInfos {
names[idx] = f.Name()
}

if len(names) < 1 {
return "", fmt.Errorf("VF device %s has no entries", pciAddr)
}
return names[0], nil
}

Expand Down

0 comments on commit 006c401

Please sign in to comment.