-
Notifications
You must be signed in to change notification settings - Fork 78
AutoTest
An extensive set of automatic tests are provided in the /tst directory. They check that basic features (such as AMR) and all the physics modules implemented in the code are functioning correctly by running, e.g. convergence tests of linear waves, shock tube tests, or comparisons to specific known analytic solutions (e.g. Bondi flows).
These tests are useful for developers to check that any changes they make do not negatively impact the rest of the code. All tests are run for every merge request as part of the CI infrastructure. Users are encouraged to run the tests manually before making a merge request, and any new substantive module added to the code should include a new automatic test for that feature. New tests must be kept simple: to keep the full test suite manageable the total run time for all tests on any specific hardware configuration should be less than about 10 minutes.
The tests are managed by the /tst/run_test_suite.py script. It is designed to execute specific subsets of tests based on the hardware configuration (CPU, MPI-enabled CPU, or GPU). It uses pytest to run tests and provides flexibility for developers to target specific test cases.
-
--style: Runs style checks. -
--cpu: Runs tests for CPU-only configurations. -
--mpicpu: Runs tests for MPI-enabled CPU configurations. -
--gpu: Runs tests for GPU configurations. -
--test: Runs a specific test by name. The test name must include one of the following suffixes:-
_cpufor CPU tests. -
_mpicpufor MPI CPU tests. -
_gpufor GPU tests.
-
- Run style checks:
python run_test_suite.py --style
- Run CPU tests:
python run_test_suite.py --cpu <cpu_flags>
- Run MPI+CPU tests:
python run_test_suite.py --mpicpu <mpicpu_flags>
- Run GPU tests:
python run_test_suite.py --gpu <gpu_flags>
- Run a specific test:
python run_test_suite.py --test test_suite/subdirectory/test_example_cpu.py
The run_test_suite.py script performs the following actions based on the provided arguments:
-
No Target Device Specified:
- If no arguments are provided, the script prints an error message and displays the help menu using
parser.format_help(). - The script then exits with
sys.exit(1).
- If no arguments are provided, the script prints an error message and displays the help menu using
-
Style Checks:
- If the
--styleargument is provided, the script runs style checks usingpyteston thetest_suite/styledirectory.
- If the
-
CPU Tests:
- If the
--cpuargument is provided, the script:- Calls
testutils.clean_make()to clean and build the project with CPU-specific flags. - Runs all tests in the
test_suitedirectory that contain_cpuin their name usingpytest.
- Calls
- If the
-
MPI CPU Tests:
- If the
--mpicpuargument is provided, the script:- Calls
testutils.clean_make()to clean and build the project with MPI-enabled CPU flags (Athena_ENABLE_MPI=ON). - Runs all tests in the
test_suitedirectory that contain_mpicpuin their name usingpytest.
- Calls
- If the
-
GPU Tests:
- If the
--gpuargument is provided, the script:- Calls
testutils.clean_make()to clean and build the project with GPU-specific flags (Kokkos_ENABLE_CUDA=On). - Runs all tests in the
test_suitedirectory that contain_gpuin their name usingpytest.
- Calls
- If the
-
Single Test Execution:
- If the
--testargument is provided, the script:- Validates the test name to ensure it contains one of the following suffixes:
_cpu,_mpicpu, or_gpu. - If the test name is invalid, the script exits with an error message.
- If valid, the script runs the specified test using
pytest. - Note the test name must include the full path to the file, usually
test_suite/subdirectory/testname.py
- Validates the test name to ensure it contains one of the following suffixes:
- If the
-
Log File Management:
- At the beginning of the script, the log file (
test_log.txt) is removed if it exists to ensure a fresh log file is created during the script's execution.
- At the beginning of the script, the log file (
- To ensure your test is executed by the script, name your test files appropriately:
- Use
_cpuin the filename for CPU tests. - Use
_mpicpuin the filename for MPI CPU tests. - Use
_gpuin the filename for GPU tests.
- Use
-
test_example_cpu.pyfor CPU tests. -
test_example_mpicpu.pyfor MPI CPU tests. -
test_example_gpu.pyfor GPU tests.
- Place your test files in a new subdirectory inside the
/tst/test_suitedirectory. The new directory also must contain an__init__.pyfile. Any script that follows the above naming convention and is located in a subdirectory with an__init__.pywill be run automaically by therun_test_suite.pyscript.
It is best to use one of the existing test scripts as a template for writing new tests. New tests must follow pytest conventions, for example the name of the function that runs the test must begin with test_. Tests that compare to known analytic solutions, or check convergence of solutions, are preferred to regression tests that compare to pre-computed solutions.
Getting Started
Running
User Guide
Physics Modules
Other Features