Skip to content

test(install): add shellcheck + bats harness for prebake logic#166

Open
ganeshkumarashok wants to merge 1 commit into
mainfrom
gpu-prebake-test-harness
Open

test(install): add shellcheck + bats harness for prebake logic#166
ganeshkumarashok wants to merge 1 commit into
mainfrom
gpu-prebake-test-harness

Conversation

@ganeshkumarashok

Copy link
Copy Markdown
Collaborator

What

Adds an automated test harness for the prebake runtime logic introduced in #162. Previously the
mode dispatch (build-only / install-skip-build / install), the dkms marker write/parse/validate,
and the opportunistic fast-path fallback were only exercised by the cross-repo AgentBaker e2e — CI
here ran docker buildx build only (no script execution, no shellcheck). This addresses that gap
(xuexu6666's review comment on #162).

Changes

  • install.sh — made sourceable for unit testing, behavior-preserving:
    • moved set -euxo pipefail, the config/helper sources, and the EXIT trap into a new main()
    • guarded main() behind BASH_SOURCE (executes only when run directly; sourcing loads functions only)
    • extracted the duplicated rm -r /opt/gpu into purge_gpu_cache
    • parameterized the config/modules paths (AKSGPU_CONFIG_PATH / AKSGPU_MODULES_ROOT) for fixtures
    • Production path is unchanged (verified: executing the script still runs main).
  • test/install.bats — 15 tests: marker write/parse/validate (kernel/version/kind/missing-file
    mismatches), fast_path_ok fallback, target_build_kernel newest-selection + fallback, and all
    three dispatch modes.
  • .github/workflows/ci.yaml — new lint-and-test job: shellcheck on install.sh + entrypoint.sh,
    and bats test/.

Validation

  • shellcheck -S warning install.sh entrypoint.sh — clean
  • bats test/install.bats — 15/15 pass
  • Guard verified both ways (executing → main runs; sourcing → it does not)

The prebake mode dispatch (build-only / install-skip-build / install), the dkms
marker write/parse/validate, and the opportunistic fast-path fallback previously
had no automated guard -- CI only ran `docker buildx build` (xuexu6666 review on #162).

- make install.sh sourceable for unit tests: move set-flags + config/helper sources +
  EXIT trap into main(), guard main() behind BASH_SOURCE, extract purge_gpu_cache,
  parameterize config/modules paths. Behavior-preserving (execution still runs main()).
- test/install.bats: 15 tests (marker write/parse/validate, fast-path fallback,
  target-kernel selection, all three dispatch modes).
- ci.yaml: new lint-and-test job (shellcheck install.sh+entrypoint.sh, bats test/).

Local: shellcheck clean, bats 15/15 pass.
Signed-off-by: Ganeshkumar Ashokavardhanan <aganeshkumar@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant