|
| 1 | +#!/bin/sh -l |
| 2 | +# List of arguments to this script |
| 3 | +# $1 : Tag/SHA of su2code/SU2 |
| 4 | +# $2 : Tag/SHA of su2code/TestCases |
| 5 | +# $3 : Tag/SHA of su2code/Tutorials |
| 6 | +# $4 : Path of the installation directory |
| 7 | +# $5 : Test script to execute |
| 8 | + |
| 9 | +usage="$(basename "$0") [-h] [-t tutorial_branch] [-b su2_branch] [-c testcases_branch] [-s test_script] |
| 10 | +where: |
| 11 | + -h show this help text |
| 12 | + -t branch of su2code/su2code.github.io repo |
| 13 | + (if not provided, it is assumed that it is mounted at /src/SU2) |
| 14 | + -b branch of su2code/SU2 repo. |
| 15 | + (if not provided, it is assumed that it is mounted at /src/Tutorials) |
| 16 | + -c branch of su2code/TestCases repo. |
| 17 | + (if not provided, it is assumed that it is mounted at /src/TestData) |
| 18 | + -s name of the test script to execute (default: parallel_regression.py). |
| 19 | +
|
| 20 | +Compiled binaries must be mounted at /install/ ! |
| 21 | +
|
| 22 | +Note: If you specify a working directory using the --workdir option for docker, |
| 23 | + append this directory to all paths above (e.g. use --workdir=/tmp if running in user mode)." |
| 24 | + |
| 25 | +su2branch="" |
| 26 | +testbranch="" |
| 27 | +tutorialbranch="" |
| 28 | +script="parallel_regression.py" |
| 29 | + |
| 30 | +while [ "`echo $1 | cut -c1`" = "-" ] |
| 31 | +do |
| 32 | + case "$1" in |
| 33 | + -t) |
| 34 | + tutorialbranch=$2 |
| 35 | + shift 2 |
| 36 | + ;; |
| 37 | + -b) |
| 38 | + su2branch=$2 |
| 39 | + shift 2 |
| 40 | + ;; |
| 41 | + -c) |
| 42 | + testbranch=$2 |
| 43 | + shift 2 |
| 44 | + ;; |
| 45 | + -s) |
| 46 | + script=$2 |
| 47 | + shift 2 |
| 48 | + ;; |
| 49 | + *) |
| 50 | + echo "$usage" >&2 |
| 51 | + exit 1 |
| 52 | + ;; |
| 53 | +esac |
| 54 | +done |
| 55 | + |
| 56 | + |
| 57 | +if [ ! -d "tests" ]; then |
| 58 | + mkdir tests |
| 59 | +fi |
| 60 | +if [ ! -d "src" ]; then |
| 61 | + mkdir "src" |
| 62 | +fi |
| 63 | + |
| 64 | +if [ ! -z "$su2branch" ]; then |
| 65 | + name="SU2_$(echo $su2branch | sed 's/\//_/g')" |
| 66 | + echo "Branch provided. Cloning to $PWD/src/$name" |
| 67 | + cd "src" |
| 68 | + |
| 69 | + # Clone su2code/SU2, su2code/TestCases and su2code/Tutorials |
| 70 | + git clone -b master https://github.com/su2code/SU2 $name |
| 71 | + cd $name |
| 72 | + git config --add remote.origin.fetch '+refs/pull/*/merge:refs/remotes/origin/refs/pull/*/merge' |
| 73 | + git config --add remote.origin.fetch '+refs/heads/*:refs/remotes/origin/refs/heads/*' |
| 74 | + git fetch origin |
| 75 | + git checkout $su2branch |
| 76 | + git submodule update |
| 77 | + cd .. |
| 78 | + cd .. |
| 79 | + cp -r src/$name/TestCases tests/. |
| 80 | +else |
| 81 | + if [ ! -d "src/SU2" ]; then |
| 82 | + echo "SU2 source directory not found. Make sure to mount existing SU2 at directory at /src/SU2. Otherwise use -b to provide a branch." |
| 83 | + exit 1 |
| 84 | + fi |
| 85 | + cp -r src/SU2/TestCases tests/. |
| 86 | +fi |
| 87 | +if [ ! -z "$testbranch" ]; then |
| 88 | + git clone --depth=1 -b $testbranch https://github.com/su2code/TestCases.git ./TestData |
| 89 | +else |
| 90 | + if [ ! -d "src/TestData" ]; then |
| 91 | + echo "$PWD/src/TestData not found. Make sure to mount existing su2code/TestCases repo or use -c to provide a branch to clone." |
| 92 | + exit 1 |
| 93 | + fi |
| 94 | +fi |
| 95 | +cp -R ./TestData/* tests/TestCases/ |
| 96 | +if [ ! -z "$tutorialbranch" ]; then |
| 97 | + git clone --depth=1 -b $tutorialbranch https://github.com/su2code/su2code.github.io ./Tutorials |
| 98 | +else |
| 99 | + if [ ! -d "src/Tutorials" ]; then |
| 100 | + echo "$PWD/src/Tutorials not found. Make sure to mount existing su2code/su2code.github.io repo or use -t to provide a branch to clone." |
| 101 | + exit 1 |
| 102 | + fi |
| 103 | +fi |
| 104 | +cp -R ./Tutorials/ tests/. |
| 105 | + |
| 106 | +# Set the environment variables |
| 107 | +export SU2_RUN=$PWD/install/bin |
| 108 | +export PATH=$SU2_RUN:$PATH |
| 109 | +export PYTHONPATH=$SU2_RUN:$PYTHONPATH |
| 110 | +export OMPI_MCA_btl_vader_single_copy_mechanism=none |
| 111 | +export SU2_MPI_COMMAND='mpirun --allow-run-as-root -n %i %s' |
| 112 | +alias mpirun='mpirun --allow-run-as-root' |
| 113 | + |
| 114 | +# Run Test Script |
| 115 | +cd tests/TestCases |
| 116 | +python $script |
| 117 | + |
| 118 | +if [ $? -eq 0 ]; then |
| 119 | + echo "Tests passed" |
| 120 | + exit 0 |
| 121 | +else |
| 122 | + echo "Tests failed" |
| 123 | + exit 1 |
| 124 | +fi |
| 125 | + |
0 commit comments