1#!/bin/bash -el
2
3# This script is intended to compare two states of a repository (checked out into different directories)
4# and succefully return if the encountered errors are the same in both states.
5# This can be used to update a non-clean state (as is most often the case for Trilinos).
6
7# Input parameters are: REPO1_PATH REPO2_PATH CONFIGURE_SCRIPT JOBNAME QUEUE
8
9# REPO1_PATH is the directory to the updated state (i.e. what later is supposed to get checked in).
10# REPO2_PATH is the gold standart directory
11# CONFIGURE_SCRIPT is the script to configure Trilinos. It takes TRILINOS_PATH as the source directory.
12# JOBNAME The root-name for the jobs to be submitted the job scheduler
13# QUEUE The job queue to be used for job submission
14
15# The script will first configure, build and run based on REPO1_PATH. If no errors occur it will exit.
16# If errors occur it will configure, build and run based on REPO2_PATH and compare the output.
17# If the output is the same (actually only the errors are checked) then it exists successfully.
18# If the output differs the script will exit with return code 1.
19
20TRILINOS_UPDATED_PATH=$1
21TRILINOS_PRISTINE_PATH=$2
22CONFIG_SCRIPT=$3
23JOBNAME=$4
24QUEUE=$5
25
26export OMP_NUM_THREADS=4
27
28rm -rf build_updated
29mkdir build_updated
30cd build_updated
31export TRILINOS_PATH=${TRILINOS_UPDATED_PATH}
32
33echo "ulimit -c 0; ctest" &> test_submitted_command
34chmod a+x test_submitted_command
35
36echo "bsub -J ${JOBNAME}-Conf1 -W 01:00 -Is -n 16 -q ${QUEUE} ${CONFIG_SCRIPT} &> config.output" &> config_command
37echo "bsub -J ${JOBNAME}-Build1 -W 07:00 -Is -n 16 -q ${QUEUE} make -j 30 -k  &> build.output" &> build_command
38echo "bsub -J ${JOBNAME}-Test1 -W 06:00 -Is -n 16 -q ${QUEUE} ./test_submitted_command &> test.output" &> test_command
39
40chmod a+x *_command
41echo ""
42echo ""
43echo "Going to run these commands on updated Trilinos:"
44cat config_command
45cat build_command
46cat test_command
47echo ""
48echo ""
49
50./config_command
51echo ""
52echo ""
53echo "Config output:"
54cat config.output
55
56echo ""
57echo ""
58
59./build_command || true
60echo ""
61echo ""
62echo "Build output:"
63cat build.output
64
65./test_command || true
66echo ""
67echo ""
68echo "Test output:"
69cat test.output
70
71BUILD_ERRORS_UPDATED=`grep "error:" build.output | wc -l`
72TEST_FAILED_UPDATED=`grep "(Failed)" test.output | wc -l`
73TEST_NOTRUN_UPDATED=`grep "(Not Run)" test.output | wc -l`
74TOTAL_PROBLEMS_UPDATED=$((${BUILD_ERRORS_UPDATED} + ${TEST_FAILED_UPDATED} + ${TEST_NOTRUN_UPDATED}))
75echo ""
76echo ""
77echo "Updated Testing: BuildErrors: " ${BUILD_ERRORS_UPDATED} " Failed Tests: " ${TEST_FAILED_UPDATED} " NotRun Tests: " ${TEST_NOTRUN_UPDATED}
78cd ../
79
80if [ "${TOTAL_PROBLEMS_UPDATED}" -gt "0" ]; then
81rm -rf build_pristine
82mkdir build_pristine
83cd build_pristine
84
85export TRILINOS_PATH=${TRILINOS_PRISTINE_PATH}
86
87echo "ulimit -c 0; ctest" &> test_submitted_command
88chmod a+x test_submitted_command
89
90echo "bsub -J ${JOBNAME}-Conf2 -W 01:00 -Is -n 16 -q ${QUEUE} ${CONFIG_SCRIPT} &> config.output" &> config_command
91echo "bsub -J ${JOBNAME}-Build2 -W 07:00 -Is -n 16 -q ${QUEUE} make -j 30 -k  &> build.output" &> build_command
92echo "bsub -J ${JOBNAME}-Test2 -W 06:00 -Is -n 16 -q ${QUEUE} ./test_submitted_command &> test.output" &> test_command
93
94
95chmod a+x *_command
96echo ""
97echo ""
98echo "Going to run these commands on pristine Trilinos:"
99cat config_command
100cat build_command
101cat test_command
102echo ""
103echo ""
104
105./config_command
106echo ""
107echo ""
108echo "Config output:"
109cat config.output
110
111echo ""
112echo ""
113
114./build_command || true
115echo ""
116echo ""
117echo "Build output:"
118cat build.output
119
120./test_command || true
121echo ""
122echo ""
123echo "Test output:"
124cat test.output
125
126BUILD_ERRORS_PRISTINE=`grep "error:" build.output | wc -l`
127TEST_FAILED_PRISTINE=`grep "(Failed)" test.output | wc -l`
128TEST_NOTRUN_PRISTINE=`grep "(Not Run)" test.output | wc -l`
129TOTAL_PROBLEMS_PRISTINE=$((${BUILD_ERRORS_PRISTINE} + ${TEST_FAILED_PRISTINE} + ${TEST_NOTRUN_PRISTINE}))
130
131sed -i 's|${TRILINOS_PRISTINE_PATH}|${TRILINOS_UPDATED_PATH}|g' build.output
132
133cd ..
134
135rm pristine_build.error updated_build.error pristine_test.failed updated_test.failed pristine_test.notrun updated_test.notrun || true
136touch pristine_build.error updated_build.error pristine_test.failed updated_test.failed pristine_test.notrun updated_test.notrun
137echo "Grepping for Errors:"
138grep "error:" build_pristine/build.output | awk '{$1 = ""; print $0;}' &> pristine_build.error || true
139grep "error:" build_updated/build.output | awk '{$1 = ""; print $0;}' &> updated_build.error || true
140grep "(Failed)" build_pristine/test.output | cut -d " " -f 3- | sort -u &> pristine_test.failed || true
141grep "(Failed)" build_updated/test.output | cut -d " " -f 3- | sort -u &> updated_test.failed || true
142grep "(Not Run)" build_pristine/test.output | cut -d " " -f 3- | sort -u &> pristine_test.notrun || true
143grep "(Not Run)" build_updated/test.output | cut -d " " -f 3- | sort -u &> updated_test.notrun || true
144
145DIFF_ERRORS=`diff pristine_build.error updated_build.error | wc -l`
146DIFF_FAILED=`diff pristine_test.failed updated_test.failed | wc -l`
147DIFF_NOTRUN=`diff pristine_test.notrun updated_test.notrun | wc -l`
148TOTAL_PROBLEMS=$((${DIFF_ERRORS} + ${DIFF_FAILED} + ${DIFF_NOTRUN}))
149
150echo "Total Problems: " ${TOTAL_PROBLEMS}
151if [ "${TOTAL_PROBLEMS}" -gt "0" ]; then
152echo ""
153echo ""
154echo "FAILED COMPARISON TEST"
155echo ""
156echo ""
157echo "Diff Build Errors:"
158diff pristine_build.error updated_build.error || true
159
160echo ""
161echo ""
162echo "Diff Failed Tests"
163diff pristine_test.failed updated_test.failed || true
164
165echo ""
166echo ""
167echo "Diff NotRun Tests"
168diff pristine_test.notrun updated_test.notrun || true
169exit 1
170fi
171fi
172