source: palm/trunk/SCRIPTS/testsuite @ 2359

Last change on this file since 2359 was 2349, checked in by Giersch, 7 years ago

Add parameter ptich_rate to namelist and revise/add error messages

  • Property svn:executable set to *
File size: 5.4 KB
Line 
1#!/usr/bin/env bash
2
3#--------------------------------------------------------------------------------#
4# This file is part of PALM.
5#
6# PALM is free software: you can redistribute it and/or modify it under the terms
7# of the GNU General Public License as published by the Free Software Foundation,
8# either version 3 of the License, or (at your option) any later version.
9#
10# PALM is distributed in the hope that it will be useful, but WITHOUT ANY
11# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License along with
15# PALM. If not, see <http://www.gnu.org/licenses/>.
16#
17# Copyright 1997-2017  Leibniz Universitaet Hannover
18#--------------------------------------------------------------------------------#
19#
20# Current revisions:
21# -----------------
22#
23#
24# Former revisions:
25# -----------------
26# $Id$
27# Initial revision
28#
29# Description:
30# ------------
31# Testsuite execution script
32#------------------------------------------------------------------------------#
33
34hrule() {
35   printf "#"
36   printf -- '-%.0s' {1..72}
37   printf "#\n"
38}
39
40get_number_of_cpu_cores() {
41   {
42      n=$(sysctl -n machdep.cpu.core_count 2> /dev/null)
43   } || {
44      n=$(grep -c ^processor /proc/cpuinfo 2> /dev/null)
45   } || {
46   if ! [[ $n =~ ^-?[0-9]+$ ]]; then
47      n=1
48   fi
49   }
50   echo $n
51}
52
53
54configure() {
55   hrule
56   printf "Configuring .mrun.config ..."
57   if [[ -f ${existing_working_dir}/.mrun.config ]]; then
58      cp ${existing_working_dir}/.mrun.config ${tester_prefix}/.mrun.config
59      sed -i -e "s#%base_directory .*#%base_directory    ${tester_prefix}#g" ${tester_prefix}/.mrun.config
60      sed -i -e "s#%base_data .*#%base_data         ${tester_prefix}/JOBS#g" ${tester_prefix}/.mrun.config
61      sed -i -e "s#%tmp_user_catalog .*#%tmp_user_catalog  ${tester_prefix}/tmp#g" ${tester_prefix}/.mrun.config
62      printf " finished (adapted existing .mrun.config)\n"
63   else
64      cp ${PALM_BIN}/.mrun.config.gfortran ${tester_prefix}/.mrun.config
65      sed -i -e "s/<replace_with_your_hostname>/${HOSTNAME}/g" ${tester_prefix}/.mrun.config
66      sed -i -e "s/<replace_with_your_local_username>/${USER}/g" ${tester_prefix}/.mrun.config
67      sed -i -e "s/<hi>/lcmuk/g" ${tester_prefix}/.mrun.config
68      sed -i -e "s#%base_directory    \$HOME/palm/current_version#%base_directory    ${tester_prefix}#g" ${tester_prefix}/.mrun.config
69      sed -i -e "s#%base_data         ~/palm/current_version/JOBS#%base_data         ${tester_prefix}/JOBS#g" ${tester_prefix}/.mrun.config
70      sed -i -e "s#%tmp_user_catalog  \$HOME/palm/tmp#%tmp_user_catalog  ${tester_prefix}/tmp#g" ${tester_prefix}/.mrun.config
71      sed -i -e "s#<replace_by_netcdf_include_path>#/usr/include#g" ${tester_prefix}/.mrun.config
72      sed -i -e "s#-L:<replace_by_netcdf_library_path>:-lnetcdf#/usr/lib/x86_64-linux-gnu/libnetcdff.so#g" ${tester_prefix}/.mrun.config
73      sed -i -e "s#-j:4#-j:1#g" ${tester_prefix}/.mrun.config
74      printf " finished (created .mrun.config from template)\n"
75   fi
76}
77
78build() {
79   hrule
80   rm -rf ${tester_prefix}/JOBS
81   rm -rf ${tester_prefix}/MAKE_DEPOSITORY*
82   rm -rf ${tester_prefix}/SOURCES_FOR_RUN_*
83   bash ${trunk_dir}/SCRIPTS/mbuild -h "lcmuk" -K "parallel" -v -u
84   bash ${trunk_dir}/SCRIPTS/mbuild -h "lcmuk" -K "parallel" -v
85}
86
87palm_installer_test() {
88   hrule
89   printf "Testing with \"${1}\"... "
90   local input_dir=${tester_prefix}/JOBS/${1}/INPUT
91   local monitoring_dir=${tester_prefix}/JOBS/${1}/MONITORING
92   local test_dir=${trunk_dir}/INSTALL
93   if [[ ! -f ${test_dir}/${1}_p3d ]] || [[ ! -f ${test_dir}/${1}_rc ]]; then
94      printf " test not found\n"
95      return 1
96   fi
97   rm -rf ${monitoring_dir}
98   mkdir -p ${input_dir}
99   mkdir -p ${monitoring_dir}
100   cp ${test_dir}/${1}_p3d ${input_dir}/${1}_p3d
101   cp ${test_dir}/${1}_rc ${monitoring_dir}/${1}_rc_reference
102   [[ -f ${test_dir}/${1}_topo ]] && cp ${test_dir}/${1}_topo ${input_dir}/
103   bash ${trunk_dir}/SCRIPTS/mrun -d ${1} -r "d3#" -h "lcmuk" -K "parallel" -X "$NUM_PROC" -T "$NUM_PROC" -v -B > ${monitoring_dir}/${1}_stdout 2>&1
104   grep -A 99999 "Run-control output" ${monitoring_dir}/${1}_rc 1> ${monitoring_dir}/RC 2> /dev/null
105   grep -A 99999 "Run-control output" ${monitoring_dir}/${1}_rc_reference 1> ${monitoring_dir}/RC_REF 2> /dev/null
106   diff_output=$(diff ${monitoring_dir}/RC_REF ${monitoring_dir}/RC)
107   rm ${monitoring_dir}/RC ${monitoring_dir}/RC_REF
108   if [[ "${diff_output}" == "" ]]; then
109      printf " passed\n"
110      return 0
111   else
112      printf " failed\n"
113      test_status="failed"
114      return 1
115   fi
116}
117
118palm_installer_test_suite() {
119   for test_path in ${trunk_dir}/INSTALL/*_p3d; do
120      testname_p3d=$(basename $test_path)
121      palm_installer_test "${testname_p3d%_p3d}"
122   done
123   hrule
124   if [[ "${test_status}" == "failed" ]]; then
125      echo "Some tests failed!"
126      hrule
127      exit 1
128   else
129      echo "All found tests passed. :-)"
130      rm -rf ${tester_prefix}/tmp/*
131      hrule
132      exit 0
133   fi
134}
135
136NUM_PROC=$(get_number_of_cpu_cores)
137existing_trunk_dir=$(readlink -f "${PALM_BIN}/../")
138existing_working_dir=$(readlink -f "${PALM_BIN}/../../")
139tester_prefix=${existing_working_dir}/tests/${BUILD_NUMBER:-$(date +%Y-%m-%d_%H%M%S)}
140trunk_dir=${tester_prefix}/trunk
141
142# redirect PALM_BIN for duration of tests
143export PALM_BIN=${trunk_dir}/SCRIPTS
144
145mkdir -p ${tester_prefix}
146cd ${tester_prefix}
147
148ln -s ${existing_trunk_dir}
149
150configure
151build
152palm_installer_test_suite
Note: See TracBrowser for help on using the repository browser.