From e6c14dfc24921e12ef9954216d0f3f3bf9e239a1 Mon Sep 17 00:00:00 2001 From: Tyler Yahn Date: Thu, 24 Oct 2024 11:43:29 -0700 Subject: [PATCH] Update Makefile test target --- .github/workflows/build.yaml | 2 +- Makefile | 27 ++++++++++----------------- 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 8a3fcaf83..5323df81a 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -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 diff --git a/Makefile b/Makefile index 37428a57a..2925821df 100644 --- a/Makefile +++ b/Makefile @@ -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 @@ -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): @@ -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)