Skip to content

Commit

Permalink
use same build tags for KMT test package expansion (#29502)
Browse files Browse the repository at this point in the history
  • Loading branch information
brycekahle committed Sep 24, 2024
1 parent ccbcf54 commit ec036f7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
24 changes: 12 additions & 12 deletions tasks/kmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -873,12 +873,12 @@ def build_run_config(run: str | None, packages: list[str]):
return c


def build_target_packages(filter_packages):
all_packages = go_package_dirs(TEST_PACKAGES_LIST, [NPM_TAG, BPF_TAG])
if filter_packages == []:
def build_target_packages(filter_packages: list[str], build_tags: list[str]):
all_packages = go_package_dirs(TEST_PACKAGES_LIST, build_tags)
if not filter_packages:
return all_packages

filter_packages = [os.path.relpath(p) for p in go_package_dirs(filter_packages, [NPM_TAG, BPF_TAG])]
filter_packages = [os.path.relpath(p) for p in go_package_dirs(filter_packages, build_tags)]
return [pkg for pkg in all_packages if os.path.relpath(pkg) in filter_packages]


Expand All @@ -888,9 +888,8 @@ def build_object_files(ctx, fp, arch: Arch):
ctx.run(f"ninja -d explain -f {fp}")


def compute_package_dependencies(ctx: Context, packages: list[str]) -> dict[str, set[str]]:
def compute_package_dependencies(ctx: Context, packages: list[str], build_tags: list[str]) -> dict[str, set[str]]:
dd_pkg_name = "github.com/DataDog/datadog-agent/"
build_tags = get_sysprobe_buildtags(False, False)
pkg_deps: dict[str, set[str]] = defaultdict(set)

packages_list = " ".join(packages)
Expand Down Expand Up @@ -924,7 +923,6 @@ def kmt_sysprobe_prepare(
ctx: Context,
arch: str | Arch,
stack: str | None = None,
kernel_release: str | None = None,
packages=None,
extra_arguments: str | None = None,
ci: bool = False,
Expand Down Expand Up @@ -957,8 +955,9 @@ def kmt_sysprobe_prepare(
build_object_files(ctx, f"{kmt_paths.arch_dir}/kmt-object-files.ninja", arch)

info("[+] Computing Go dependencies for test packages...")
target_packages = build_target_packages(filter_pkgs)
pkg_deps = compute_package_dependencies(ctx, target_packages)
build_tags = get_sysprobe_buildtags(False, False)
target_packages = build_target_packages(filter_pkgs, build_tags)
pkg_deps = compute_package_dependencies(ctx, target_packages, build_tags)

info("[+] Generating build instructions..")
with open(nf_path, 'w') as ninja_file:
Expand All @@ -977,14 +976,15 @@ def kmt_sysprobe_prepare(
ninja_build_dependencies(ctx, nw, kmt_paths, go_path, arch)
ninja_copy_ebpf_files(nw, "system-probe", kmt_paths, arch)

build_tags = get_sysprobe_buildtags(False, False)
for pkg in target_packages:
pkg_name = os.path.relpath(pkg, os.getcwd())
target_path = os.path.join(kmt_paths.sysprobe_tests, pkg_name)
output_path = os.path.join(target_path, "testsuite")
variables = {
"env": env_str,
"go": go_path,
"build_tags": get_sysprobe_buildtags(False, False),
"build_tags": build_tags,
}
timeout = get_test_timeout(os.path.relpath(pkg, os.getcwd()))
if timeout:
Expand Down Expand Up @@ -1016,9 +1016,9 @@ def kmt_sysprobe_prepare(
rule="copyfiles",
)

# handle testutils and testdata seperately since they are
# handle testutils and testdata separately since they are
# shared across packages
target_pkgs = build_target_packages([])
target_pkgs = build_target_packages([], build_tags)
for pkg in target_pkgs:
target_path = os.path.join(kmt_paths.sysprobe_tests, os.path.relpath(pkg, os.getcwd()))

Expand Down
1 change: 0 additions & 1 deletion tasks/system_probe.py
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,6 @@ def go_package_dirs(packages, build_tags):
This handles the ellipsis notation (eg. ./pkg/ebpf/...)
"""

target_packages = []
format_arg = '{{ .Dir }}'
buildtags_arg = ",".join(build_tags)
packages_arg = " ".join(packages)
Expand Down

0 comments on commit ec036f7

Please sign in to comment.