run_regression_tests 3.36 KB
Newer Older
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
#!/bin/bash

# for Macports
# :FIXME: do we need this?
#         YES:	as long as readlink(1) shipped with Mac OS X does not
#	 	support the option '-f'
PATH+=":/opt/local/bin:/usr/local/bin"

# for Mac OS 
declare -rx MACOSX_DEPLOYMENT_TARGET=10.9

#exec 1> $0.stdout
#exec 2> $0.stderr

declare -r abs_scriptname=$(readlink -f "$0")
declare -r bindir="${abs_scriptname%/*}"
declare -r basedir="${bindir%/*/*}"

declare -r builddir="${basedir}/build"
declare -r opalbin="${builddir}/src/opal"

declare -r srcdir="${basedir}/src"
declare -r testsdir="${basedir}/tests"


gsell's avatar
gsell committed
26
declare -r keytab="${HOME}/.keytab"
27 28 29 30

# read configuration and tests to run
source "${bindir}/regression_tests.conf"

gsell's avatar
gsell committed
31
# these shell variable must be set for the tests
32 33 34 35 36 37 38
declare -rx OPAL_EXE_PATH="${basedir}/build/src"

declare -r run_tests="${basedir}/tests/RegressionTests/run/run-reg-tests.py"

# 
declare	force_run='no'
declare	new_opal_binary='no'
39
declare	use_afs='yes'
gsell's avatar
gsell committed
40 41
declare do_publish='yes'
declare	opts=''
42 43 44

while (( $# > 0 )); do
	case $1 in
gsell's avatar
gsell committed
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
		--do-publish )
			do_publish=='yes'
			;;
		--dont-publish )
			publish=='no'
			;;
		--publish-dir )
			REGTEST_WWW="$2"
			shift 1
			;;
		--publish-dir=* )
			REGTEST_WWW="${1#*=}"
			;;
		--use-afs )
			use_afs='yes'
			;;
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
		-f | --force )
			force_run='yes'
			;;
		-* )
			echo "Unknown option: $1" 1>&2
			exit
			;;
		* )
			echo "No arguments allowed" 1>&2
			exit 1
			;;
	esac
	shift 1
done

gsell's avatar
gsell committed
76 77
[[ ${do_publish} == 'yes' ]] && opts+=" --do-publish"

78 79 80 81 82 83


load_modules() {
	source /opt/psi/config/profile.bash
	module purge
	module use unstable
gsell's avatar
gsell committed
84
	source "${bindir}/modules.conf"
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
}

update_repo() {
	local -r repodir="$1"
	if [[ -z "${repodir}" ]]; then
		echo "$0: Missing argument!" 1>&2
		exit 1
	fi

	if [[ ! -d "${repodir}" ]]; then
		echo "${repodir}: does not exist or is not a directory!" 1>&2
		exit 1
	fi

	cd "${repodir}"

	if ! git rev-parse --is-inside-work-tree 1>/dev/null 2>&1 ; then
		echo "${repodir}: is not a Git working directory!" 1>&2
		exit 1
	fi

	local -r branch=$(git rev-parse --abbrev-ref HEAD)
	git fetch || { echo "git fetch failed!" 1>&2; exit 10; }
	local -i num_changed_files=$(git diff --name-only  "origin/${branch}"  | wc -l | awk '{print $1}')
	if (( $num_changed_files == 0 )); then
		echo "Working directory '${repodir}' is up to date!"
		return 1
	fi
	git merge || { echo "git merge failed!" 1>&2; exit 11; };
	return 0
}

compile_opal() {
	cd "${basedir}" 	|| exit 1
	rm -rf "${builddir}"	|| exit 1
	mkdir "${builddir}"	|| exit 1
	cd "${builddir}"	|| exit 1
	cmake -DCMAKE_BUILD_TYPE=RELEASE -DENABLE_SAAMG_SOLVER=TRUE "${srcdir}"
	make -j10 || exit 1
}

run_regressiontests() {
gsell's avatar
gsell committed
127 128 129 130 131
	if [[ ${use_afs} == 'yes' ]]; then
		declare -rx KRB5CCNAME=$(mktemp /tmp/krb5cc_$(id -u)_XXXXXX)
		/usr/bin/kinit -t "${keytab}" -k "${PRINCIPAL_NAME}"	|| exit 2
		/usr/bin/aklog						|| exit 2
	fi
132 133 134

	"${run_tests}" --user --run-local --tests="${tests}"

gsell's avatar
gsell committed
135 136 137 138
	if [[ ${use_afs} == 'yes' ]]; then
		/usr/bin/unlog
		/usr/bin/kdestroy
	fi
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
}

main() {
	echo "Updating OPAL source repository..."
	update_repo "${srcdir}"
	if [[ $? == 0 ]] || [[ ! -e "${opalbin}" ]]; then
		echo "Compiling OPAL ..."
		compile_opal	|| exit 1
		new_opal_binary='yes'
	fi

	echo "Updating test repository..."
	update_repo "${testsdir}"
	if [[ $? == 0 ]] || [[ ${new_opal_binary} == 'yes' ]] || [[ ${force_run} == 'yes' ]] ; then
		echo "Running regression tests..."
		run_regressiontests || exit 1
	fi
}

load_modules
main