cp2k/tools/docker/scripts/test_misc.sh
xysun a0df33dd6a
Add MACE support interface (#5580)
Co-authored-by: Ole Schütt <ole@schuett.name>
2026-07-20 23:42:41 +02:00

99 lines
4.1 KiB
Bash
Executable file

#!/bin/bash -e
# author: Ole Schuett
function run_test {
TEST_COMMAND=("$@")
echo -en "Running \"${TEST_COMMAND[*]}\"... "
if "${TEST_COMMAND[@]}" &> test.out; then
echo "done."
else
echo -e "failed.\n\n"
tail -n 100 test.out
mkdir -p /workspace/artifacts/
cp test.out /workspace/artifacts/
echo -e "\nSummary: Test \"${TEST_COMMAND[*]}\" failed."
echo -e "Status: FAILED\n"
exit 0
fi
}
#===============================================================================
cd /opt/cp2k
echo "Using $(python3 --version) and the following packages:"
pip3 freeze
echo ""
# prepare inputs for minimax_to_fortran_source.py
unzip -q -d ./tools/minimax_tools/1_xData 1_xData.zip
run_test ./tools/precommit/format_fortran_test.py
run_test ./tools/minimax_tools/minimax_to_fortran_source.py --check
run_test ./tools/docker/generate_dockerfiles.py --check
# Test pao-ml training.
# Passing example.pao twice to have enough samples to split off 20% for validation.
run_test ./tools/pao-ml/pao-train.py --kind=H --epochs=200 ./tools/pao-ml/example.pao ./tools/pao-ml/example.pao
run_test ./tools/pao-ml/pao-retrain.py --model="DZVP-MOLOPT-GTH-PAO4-H.pt" --epochs=200 ./tools/pao-ml/example.pao ./tools/pao-ml/example.pao
run_test ./tools/pao-ml/pao-validate.py --threshold=1e-1 --model="DZVP-MOLOPT-GTH-PAO4-H.pt" ./tools/pao-ml/example.pao
run_test ./tools/pao-ml/pao-validate.py --threshold=1e-6 --model="tests/QS/regtest-pao-5/DZVP-MOLOPT-GTH-PAO4-H.pt" ./tools/pao-ml/example.pao
run_test ./tools/pao-ml/pao-validate.py --threshold=1e-5 --model="tests/QS/regtest-pao-5/DZVP-MOLOPT-GTH-PAO4-O.pt" ./tools/pao-ml/example.pao
# Test vibronic_spec
run_test ./tools/vibronic_spec/main.py ./tools/vibronic_spec/example/example_config.toml
run_test mypy --strict ./tools/pao-ml/
run_test mypy --strict ./tools/mace/create_cp2k_model.py
run_test mypy --strict ./tools/minimax_tools/minimax_to_fortran_source.py
run_test mypy --strict ./tools/dashboard/generate_dashboard.py
run_test mypy --strict ./tools/regtesting/optimize_test_dirs.py
run_test mypy --strict ./tools/regtesting/compare_wannier90_mmn.py
run_test mypy --strict ./tools/regtesting/validate_wannier90_export.py
run_test mypy --strict ./tools/precommit/precommit.py
run_test mypy --strict ./tools/precommit/check_file_properties.py
run_test mypy --strict ./tools/precommit/format_makefile.py
run_test mypy --strict ./tools/precommit/format_input_file.py
run_test mypy --strict ./tools/docker/generate_dockerfiles.py
run_test mypy --strict ./tools/docker/scripts/plot_performance.py
run_test mypy --strict ./tools/conventions/redirect_gfortran_output.py
run_test mypy --strict ./tools/conventions/analyze_gfortran_ast.py
run_test mypy --strict ./tests/do_regtest.py
run_test mypy --strict ./docs/generate_input_reference.py
run_test mypy --strict ./docs/fix_github_links.py
run_test mypy --strict ./tools/vibronic_spec/
# Test Wannier90 .wout parsing without requiring an external wannier90.x binary.
W90_TEST_DIR=$(mktemp -d)
cat > "${W90_TEST_DIR}/test.wout" << EOF
Final State
WF centre and spread 1 ( 1.000000, 2.000000, 3.000000 ) 1.25000000
Sum of centres and spreads ( 1.000000, 2.000000, 3.000000 ) 1.25000000
Spreads (Bohr^2) Omega I = 1.250000000
================ Omega D = 0.000000000
Omega OD = 0.000000000
Final Spread (Bohr^2) Omega Total = 1.250000000
All done: wannier90 exiting
EOF
run_test ./tools/regtesting/validate_wannier90_export.py run test \
--workdir "${W90_TEST_DIR}" --require-all-done --max-omega-total 2.0
# TODO: Find a way to test generate_dashboard.py without git repository.
#
# # Test generate_dashboard.py. Running it twice to also execute its caching.
# mkdir -p /workspace/artifacts/dashboard
# for _ in {1..2}; do
# run_test ./tools/dashboard/generate_dashboard.py \
# ./tools/dashboard/dashboard.conf \
# /workspace/artifacts/dashboard/status.pickle \
# /workspace/artifacts/dashboard/
# done
run_test cmake -S . -B build -DCP2K_ENABLE_CONSISTENCY_CHECKS=ON
echo ""
echo "Summary: Miscellaneous tests passed"
echo "Status: OK"
#EOF