Skip to content

Commit

Permalink
Update Makefile test target (#1216)
Browse files Browse the repository at this point in the history
  • Loading branch information
MrAlias authored Oct 24, 2024
1 parent 3a6c066 commit 21f4f30
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
uname -p;
clang --version;
- run: make test
- run: sudo make test_ebpf
- run: sudo make test-ebpf
- run: make check-clean-work-tree
generate-and-test-arm64:
runs-on: macos-latest
Expand Down
27 changes: 10 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ TOOLS_MOD_DIR := ./internal/tools
TOOLS = $(CURDIR)/.tools

ALL_GO_MOD_DIRS := $(shell find . -type f -name 'go.mod' ! -path './LICENSES/*' -exec dirname {} \; | sort)
ALL_GO_MODS := $(shell find . -type f -name 'go.mod' ! -path '$(TOOLS_MOD_DIR)/*' ! -path './LICENSES/*' | sort)

# Build the list of include directories to compile the bpf program
BPF_INCLUDE += -I${REPODIR}/internal/include/libbpf
Expand All @@ -19,7 +20,7 @@ CGO_ENABLED=0
.DEFAULT_GOAL := precommit

.PHONY: precommit
precommit: license-header-check dependabot-generate go-mod-tidy golangci-lint-fix codespell
precommit: license-header-check dependabot-generate golangci-lint-fix test codespell

# Tools
$(TOOLS):
Expand Down Expand Up @@ -49,22 +50,14 @@ $(TOOLS)/offsetgen: PACKAGE=go.opentelemetry.io/auto/$(TOOLS_MOD_DIR)/inspect/cm
.PHONY: tools
tools: $(GOLICENSES) $(MULTIMOD) $(GOLANGCI_LINT) $(DBOTCONF) $(OFFSETGEN)

ALL_GO_MODS := $(shell find . -type f -name 'go.mod' ! -path '$(TOOLS_MOD_DIR)/*' ! -path './LICENSES/*' | sort)
GO_MODS_TO_TEST := $(ALL_GO_MODS:%=test/%)
GO_MODS_TO_EBPF_TEST := $(ALL_GO_MODS:%=test_ebpf/%)

.PHONY: test
test: generate $(GO_MODS_TO_TEST)
test/%: GO_MOD=$*
test/%:
cd $(shell dirname $(GO_MOD)) && $(GOCMD) test -v ./...

# These tests need to be run as privileged user/with sudo
.PHONY: test_ebpf
test_ebpf: generate $(GO_MODS_TO_EBPF_TEST)
test_ebpf/%: GO_MOD=$*
test_ebpf/%:
cd $(shell dirname $(GO_MOD)) && $(GOCMD) test -v -tags=ebpf_test -run ^TestEBPF ./...
TEST_TARGETS := test-verbose test-ebpf
.PHONY: $(TEST_TARGETS) test
test-ebpf: ARGS = -tags=ebpf_test -run ^TestEBPF # These need to be run with sudo.
test-verbose: ARGS = -v
$(TEST_TARGETS): test
test: generate $(ALL_GO_MODS:%=test/%)
test/%/go.mod:
@cd $* && $(GOCMD) test $(ARGS) ./...

.PHONY: generate
generate: export CFLAGS := $(BPF_INCLUDE)
Expand Down

0 comments on commit 21f4f30

Please sign in to comment.