Skip to content

test(md): consolidate source_md unit tests and restore serial coverage - #8322

Open
19hello wants to merge 14 commits into
deepmodeling:developfrom
19hello:refactor/source-md-tests
Open

19hello wants to merge 14 commits into
deepmodeling:developfrom
19hello:refactor/source-md-tests

Conversation

@19hello

@19hello 19hello commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

Reminder

  • I have read AGENTS.md and docs/developers_guide/agent_governance.md.
  • I have linked an issue or explained why this PR does not need one.
  • I have added adequate unit tests and/or case tests, or explained why not.
  • I have listed the exact verification commands run and their results.
  • I have described user-visible behavior changes, including INPUT parameter changes.
  • I have explained core-module impact for ESolver, HSolver, ElecState, Hamilt, Operator, Psi, or other source/ changes.
  • I have requested any needed governance exception below.

Linked Issue

Fixes #8298

Unit Tests and/or Case Tests for my changes

  • Commands run:
    • ctest --test-dir /tmp/abacus-md-serial --output-on-failure -R '^MODULE_MD|^MODULE_ESOLVER_forcefields$|^MODULE_CELL_NEIGHBOR_domain_decomposition_serial$' — 18/18 passed.
    • env OMP_NUM_THREADS=1 LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu/openblas-pthread:$LD_LIBRARY_PATH ctest --test-dir build_parallel_md1_current --output-on-failure -R '^MODULE_MD|^MODULE_ESOLVER_forcefields$|^MODULE_CELL_NEIGHBOR_(domain_decomposition|mdcell_migrate_mpi)' — 28/28 passed (run outside the restricted sandbox).
    • `ctest --test-dir /tmp/abacus-md-serial --output-on-failure -R '^MODULE_CELL_NEIGHBOR_domain_decomposition_serial
    • git diff --check origin/develop...HEAD — passed.
  • Result summary: Serial and MPI MD/Cell/ESolver unit tests pass. The MPI production executable was also built and reports ABACUS version v3.11.0-beta13.
  • Checks not run, with reason: The optional NEP backend was not enabled in these local builds, so its enabled code path was not exercised.

What's changed?

  • Consolidate MD unit tests in source/source_md/unittests/ with one owning test file per source, including merged md_base and md_func suites and a dedicated MODULE_MD_base target.
  • Enable serial-compatible MD tests without ENABLE_MPI; retain MPI-specific test targets.
  • Consolidate all module_neighlist tests from test/ into unittests/, including domain decomposition; preserve the existing serial, MPI, and CUDA target conditions.
  • Move the LJ solver pressure-correction assertions to an ESolver-owned test, while retaining MD LJ potential and MDCell/UnitCell coverage in MD.
  • Rename NEP/SNAP implementation and test filenames to nep/snap, updating build lists and includes; class names and runtime behavior are unchanged.
  • Remove the unused md_statistics.h and obsolete test directories/files.

Governance Notes

  • INPUT/docs changes: None. This reorganizes internal tests and source filenames without changing user-facing INPUT parameters or behavior; documentation updates are not needed.
  • Core module impact: ESolver gains a focused force-field pressure-correction test and updated NEP/SNAP includes; Cell owns domain decomposition tests. No production ESolver algorithm changes.
  • Existing global dependencies: The moved tests retain their existing production-facing global access; the refactor does not add cross-layer global dependencies.
  • Exceptions requested: None.
    ` — 1/1 passed after the Cell directory consolidation.
    • `env OMP_NUM_THREADS=1 LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu/openblas-pthread:$LD_LIBRARY_PATH ctest --test-dir build_parallel_md1_current --output-on-failure -R '^MODULE_CELL_NEIGHBOR_(neighbor_search|bin_manager|allocator_and_list|page_allocator|mdcell_migrate_mpi|domain_decomposition_np[14]|mdcell_reader_np4)
    • git diff --check origin/develop...HEAD — passed.
  • Result summary: Serial and MPI MD/Cell/ESolver unit tests pass. The MPI production executable was also built and reports ABACUS version v3.11.0-beta13.
  • Checks not run, with reason: The optional NEP backend was not enabled in these local builds, so its enabled code path was not exercised.

What's changed?

  • Consolidate MD unit tests in source/source_md/unittests/ with one owning test file per source, including merged md_base and md_func suites and a dedicated MODULE_MD_base target.
  • Enable serial-compatible MD tests without ENABLE_MPI; retain MPI-specific test targets.
  • Consolidate all module_neighlist tests from test/ into unittests/, including domain decomposition; preserve the existing serial, MPI, and CUDA target conditions.
  • Move the LJ solver pressure-correction assertions to an ESolver-owned test, while retaining MD LJ potential and MDCell/UnitCell coverage in MD.
  • Rename NEP/SNAP implementation and test filenames to nep/snap, updating build lists and includes; class names and runtime behavior are unchanged.
  • Remove the unused md_statistics.h and obsolete test directories/files.

Governance Notes

  • INPUT/docs changes: None. This reorganizes internal tests and source filenames without changing user-facing INPUT parameters or behavior; documentation updates are not needed.
  • Core module impact: ESolver gains a focused force-field pressure-correction test and updated NEP/SNAP includes; Cell owns domain decomposition tests. No production ESolver algorithm changes.
  • Existing global dependencies: The moved tests retain their existing production-facing global access; the refactor does not add cross-layer global dependencies.
  • Exceptions requested: None.
    ` — 8/8 passed after the Cell directory consolidation (outside the restricted sandbox).
    • python3 tools/03_code_analysis/agent_governance_check.py --base origin/develop --head HEAD --format text — exit 0; documentation-sync review warning addressed below.
    • git diff --check origin/develop...HEAD — passed.
  • Result summary: Serial and MPI MD/Cell/ESolver unit tests pass. The MPI production executable was also built and reports ABACUS version v3.11.0-beta13.
  • Checks not run, with reason: The optional NEP backend was not enabled in these local builds, so its enabled code path was not exercised.

What's changed?

  • Consolidate MD unit tests in source/source_md/unittests/ with one owning test file per source, including merged md_base and md_func suites and a dedicated MODULE_MD_base target.
  • Enable serial-compatible MD tests without ENABLE_MPI; retain MPI-specific test targets.
  • Consolidate all module_neighlist tests from test/ into unittests/, including domain decomposition; preserve the existing serial, MPI, and CUDA target conditions.
  • Move the LJ solver pressure-correction assertions to an ESolver-owned test, while retaining MD LJ potential and MDCell/UnitCell coverage in MD.
  • Rename NEP/SNAP implementation and test filenames to nep/snap, updating build lists and includes; class names and runtime behavior are unchanged.
  • Remove the unused md_statistics.h and obsolete test directories/files.

Governance Notes

  • INPUT/docs changes: None. This reorganizes internal tests and source filenames without changing user-facing INPUT parameters or behavior; documentation updates are not needed.
  • Core module impact: ESolver gains a focused force-field pressure-correction test and updated NEP/SNAP includes; Cell owns domain decomposition tests. No production ESolver algorithm changes.
  • Existing global dependencies: The moved tests retain their existing production-facing global access; the refactor does not add cross-layer global dependencies.
  • Exceptions requested: None.

@ABACUS-PR-BOT ABACUS-PR-BOT left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two issues remain: the NEP header rename breaks the enabled-backend include path, and the moved missing-restart test shares a directory with restart writers. Static review only; no build or runtime tests were executed, and author-reported results were not independently verified.

Non-blocking: Please consolidate the repeated verification/change sections and restore the two truncated Cell CTest commands. Their regex quotes and code spans currently run into later sections, so the selections cannot be copied or checked against the reported pass counts.

* @date 2025-10-10
*/
#include "nep_potential.h"
#include "nep.h"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With NEP enabled, the conditional #include "nep.h" below now resolves to this newly renamed wrapper again. Its include guard suppresses the second include, leaving ::NEP incomplete, so the allocation, member calls, and unique_ptr destruction cannot compile. Please make the wrapper/backend includes unambiguous and verify a build with NEP_DIR configured.

initialize_mdcell_from_ucell(mdcell, ucell, decomp);
int istep = 0;
double temperature = 0.0;
EXPECT_EXIT(MD_func::current_md_info(mdcell, "./", istep, temperature), ::testing::ExitedWithCode(1), "");

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This missing-file assertion now shares its working directory with restart writers such as FIREtest.WriteRestart. A parallel run or a leftover ./Restart_md.txt can make current_md_info return normally and fail the death test. Please pass a unique empty directory under testing::TempDir().

This branch has not been deployed

No deployments
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.

Title: test(md): consolidate source _md unit tests into a one-file-per-source layout

2 participants