Skip to content

Set up Unit Testing #49

@kvrigor

Description

@kvrigor

(migrated from internal issue tracker)

Here are some of my thoughts on how to start with automated tests in eCLM. For now only unit testing is covered; system testing is a different matter and I will post about it on another thread below.

Phase 1: Set up unit test infrastructure

CLM5 uses the parallel Fortran Unit testing library (a.k.a. pFUnit) to run unit tests. We need to integrate this into eCLM and test if it works.

1. Build pFUnit standalone

The goal of this step is to learn the correct cmake parameters to build pFUnit, which will be important for the next step.

  • Successfully build pFUnit on JSC systems
  • Successfully build pFUnit on Ubuntu (necessary for GitHub CI)

2. Build pFUnit within eCLM

3. Add dummy unit tests in eCLM and run them

  • Get familiar with writing and running unit tests. Check out pFUnit_demos for examples.
  • Add some dummy unit tests inside eCLM (e.g., one test that always passes and another test that always fails)
  • Run the tests. The workflow for running tests should look something like this:
# Configure eCLM
cmake -S src -B "$BUILD_DIR" \
      -DCMAKE_INSTALL_PREFIX="$INSTALL_DIR" \
      -DCMAKE_C_COMPILER=mpicc \
      -DCMAKE_Fortran_COMPILER=mpifort

# Build eCLM
cmake --build "$BUILD_DIR"

# Run tests
cd "$BUILD_DIR"
ctest

Phase 2: Port unit tests from CLM5 to eCLM

Once the test infrastructure is set up, we can start copying the unit tests under CTSM/src and test if they work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions