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