Skip to content

[ISSUE] simplify Makefile also for tests and host based tests #266

Done

Description

@marcobuschini

Problem

Makefile and kernel/kernel.mk currently maintain large, manually synchronized file lists and duplicated build rules for both kernel shell tests and host (snitch) unit tests:

  1. Manual HOST_ONLY_TEST_SRCS enumeration (Makefile lines 70–104)
    • Every tests/host/*.cpp file must be listed by hand. Omitting a file silently excludes it from test-host and lint-report (e.g. tests/host/virtio_blk_test.cpp was previously left out of HOST_ONLY_TEST_SRCS even though TEST_FORMAT_SRCS discovered it via find).
  2. Duplicated HOST_KERNEL_SRCS list (Makefile lines 106–147 vs. kernel/kernel.mk)
    • HOST_KERNEL_SRCS manually duplicates 40+ kernel .cpp paths already listed in kernel/kernel.mk, creating drift whenever kernel modules are added or moved.
  3. Manual kernel/shell/tests/*.cpp list (kernel/kernel.mk lines 18–64)
    • 47 shell test source files are listed explicitly instead of being discovered or grouped cleanly.
  4. Duplicated host compiler flags & pattern rules (Makefile lines 58–68, 199–215)
    • HOST_CXXFLAGS and HOST_COV_CXXFLAGS repeat the same C++20, warning, -DHOST_TEST, and -MMD -MP flags.

Proposed Simplification

  • Auto-discover host tests in Makefile (or a dedicated tests/host/host.mk):
    HOST_ONLY_TEST_SRCS := $(sort $(wildcard tests/host/*.cpp) $(wildcard tests/host/mocks/*.cpp)) $(DRIVER_SRCS)
    (keeping TEST_FORMAT_SRCS and lint-report's --host-srcs derived from the exact same source of truth).
  • Derive HOST_KERNEL_SRCS from kernel/kernel.mk instead of duplicating it in Makefile — e.g. split kernel/kernel.mk into host-testable KERNEL_CORE_SRCS vs. bare-metal-only KERNEL_TARGET_SRCS (or compute $(filter-out ..., $(SRCS_CXX))), so HOST_KERNEL_SRCS stays automatically in sync.
  • Auto-discover shell tests in kernel/kernel.mk:
    SRCS_CXX += $(sort $(wildcard kernel/shell/tests/*.cpp))
  • Factor shared host flags (HOST_COMMON_CXXFLAGS) between HOST_CXXFLAGS and HOST_COV_CXXFLAGS.

Acceptance Criteria

  • HOST_ONLY_TEST_SRCS automatically discovers all tests/host/*.cpp and tests/host/mocks/*.cpp without manual per-file edits.
  • HOST_KERNEL_SRCS is derived from a single source of truth shared with kernel/kernel.mk (no duplicated file list).
  • kernel/shell/tests/*.cpp are discovered without manual per-file enumeration in kernel/kernel.mk.
  • Shared host C++ flags are factored into a common variable.
  • make clean && make -j"$(nproc)" all && make clean-tests && make -j"$(nproc)" quality passes with identical test count, coverage, formatting, and lint results.

Activity

  1. moved this from Backlog to Todo in kernelite/miloon Dec 4, 2026
  2. moved this from Todo to In progress in kernelite/miloon Dec 4, 2026
  3. self-assigned this
    on Dec 4, 2026
  4. added a commit that references this issue on Dec 4, 2026
    2501239
  5. moved this from In progress to In review in kernelite/miloon Dec 4, 2026
  6. moved this from In review to Done in kernelite/miloon Dec 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions