Skip to content

Commit

Permalink
Docker: Add input check for benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
oschuett committed Mar 12, 2020
1 parent d4fd0e2 commit 815b46f
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 1 deletion.
25 changes: 24 additions & 1 deletion tools/docker/scripts/test_regtest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,32 @@ if which ompi_info &> /dev/null ; then
export OMPI_MCA_plm_rsh_agent=/bin/false
fi

echo -e "\n========== Running Regtests =========="
echo -en "\nCompiling cp2k... "
cd /workspace/cp2k
if make -j ARCH="${ARCH}" VERSION="${VERSION}" &> make.out ; then
echo "done."
else
echo "failed."
cat make.out
echo -e "\nSummary: Compilation failed."
echo -e "Status: FAILED\n"
exit 0
fi


if [[ "${ARCH}" == "local" ]] ; then
echo -en "\nChecking benchmarks... "
if ! ./tools/regtesting/check_inputs.py "./exe/${ARCH}/cp2k.${VERSION}" "./benchmarks/" ; then
echo -e "\nSummary: Some benchmark inputs could not be parsed."
echo -e "Status: FAILED\n"
exit 0
fi
fi


echo -e "\n========== Running Regtests =========="
make ARCH="${ARCH}" VERSION="${VERSION}" TESTOPTS="${TESTOPTS}" test

exit 0 # Prevent CI from overwriting do_regtest's summary message.

#EOF
47 changes: 47 additions & 0 deletions tools/regtesting/check_inputs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/python3

# author: Ole Schuett

# Runs "cp2k.x --check" on all input files below given path.

import os
import sys
import subprocess
from subprocess import PIPE, DEVNULL


def main():
if len(sys.argv) != 3:
print("Usage: check_inputs.py <cp2k-binary> <path-to-inputs>")
sys.exit(1)

orig_cwd = os.getcwd()
cp2k_binary, path_to_check = sys.argv[1:]
n_files, n_errors = 0, 0

for root, dirs, files in os.walk(path_to_check):
# Unpack bzip2 files.
bz2_files = [fn for fn in files if fn.endswith(".bz2")]
for fn in bz2_files:
cmd = ["bzip2", "--decompress", "--keep", "--force", fn]
subprocess.run(cmd, cwd=root, check=True)

# Check input files within root directory.
inp_files = [fn for fn in files if fn.endswith(".inp")]
for fn in inp_files:
cmd = [os.path.join(orig_cwd, cp2k_binary), "--check", fn]
p = subprocess.run(cmd, cwd=root, stdout=PIPE, stderr=DEVNULL)
n_files += 1
if p.returncode != 0:
n_errors += 1
fn_full = os.path.join(root, fn)
print(f"\n\nError in {fn_full}:")
print(p.stdout.decode("utf8"))

print(f"Found {n_files} input files and {n_errors} errors.")
sys.exit(n_errors)


main()

# EOF

0 comments on commit 815b46f

Please sign in to comment.