Debian Codegraph @

sampleScripts/Sandia-SEMS/run_repo_comparison_interactive

raw
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
20 TRILINOS_UPDATED_PATH=$1
21 TRILINOS_PRISTINE_PATH=$2
22 CONFIG_SCRIPT=$3
23 JOBNAME=$4
24 QUEUE=$5
25
26 export OMP_NUM_THREADS=4
27
28 rm -rf build_updated
29 mkdir build_updated
30 cd build_updated
31 export TRILINOS_PATH=${TRILINOS_UPDATED_PATH}
32
33 echo "ulimit -c 0; ctest" &> test_submitted_command
34 chmod a+x test_submitted_command
35
36 echo "${CONFIG_SCRIPT} &> config.output" &> config_command
37 echo "make -j 8 -k &> build.output" &> build_command
38 echo "./test_submitted_command &> test.output" &> test_command
39
40 chmod a+x *_command
41 echo ""
42 echo ""
43 echo "Going to run these commands on updated Trilinos:"
44 cat config_command
45 cat build_command
46 cat test_command
47 echo ""
48 echo ""
49
50 ./config_command
51 echo ""
52 echo ""
53 echo "Config output:"
54 cat config.output
55
56 echo ""
57 echo ""
58
59 ./build_command || true
60 echo ""
61 echo ""
62 echo "Build output:"
63 cat build.output
64
65 ./test_command || true
66 echo ""
67 echo ""
68 echo "Test output:"
69 cat test.output
70
71 BUILD_ERRORS_UPDATED=`grep "error:" build.output | wc -l`
72 TEST_FAILED_UPDATED=`grep "(Failed)" test.output | wc -l`
73 TEST_NOTRUN_UPDATED=`grep "(Not Run)" test.output | wc -l`
74 TOTAL_PROBLEMS_UPDATED=$((${BUILD_ERRORS_UPDATED} + ${TEST_FAILED_UPDATED} + ${TEST_NOTRUN_UPDATED}))
75 echo ""
76 echo ""
77 echo "Updated Testing: BuildErrors: " ${BUILD_ERRORS_UPDATED} " Failed Tests: " ${TEST_FAILED_UPDATED} " NotRun Tests: " ${TEST_NOTRUN_UPDATED}
78 cd ../
79
80 if [ "${TOTAL_PROBLEMS_UPDATED}" -gt "0" ]; then
81 rm -rf build_pristine
82 mkdir build_pristine
83 cd build_pristine
84
85 export TRILINOS_PATH=${TRILINOS_PRISTINE_PATH}
86
87 echo "ulimit -c 0; ctest" &> test_submitted_command
88 chmod a+x test_submitted_command
89
90 echo "${CONFIG_SCRIPT} &> config.output" &> config_command
91 echo "make -j 8 -k &> build.output" &> build_command
92 echo "./test_submitted_command &> test.output" &> test_command
93
94 chmod a+x *_command
95 echo ""
96 echo ""
97 echo "Going to run these commands on pristine Trilinos:"
98 cat config_command
99 cat build_command
100 cat test_command
101 echo ""
102 echo ""
103
104 ./config_command
105 echo ""
106 echo ""
107 echo "Config output:"
108 cat config.output
109
110 echo ""
111 echo ""
112
113 ./build_command || true
114 echo ""
115 echo ""
116 echo "Build output:"
117 cat build.output
118
119 ./test_command || true
120 echo ""
121 echo ""
122 echo "Test output:"
123 cat test.output
124
125 BUILD_ERRORS_PRISTINE=`grep "error:" build.output | wc -l`
126 TEST_FAILED_PRISTINE=`grep "(Failed)" test.output | wc -l`
127 TEST_NOTRUN_PRISTINE=`grep "(Not Run)" test.output | wc -l`
128 TOTAL_PROBLEMS_PRISTINE=$((${BUILD_ERRORS_PRISTINE} + ${TEST_FAILED_PRISTINE} + ${TEST_NOTRUN_PRISTINE}))
129
130 sed -i 's|${TRILINOS_PRISTINE_PATH}|${TRILINOS_UPDATED_PATH}|g' build.output
131
132 cd ..
133
134 rm pristine_build.error updated_build.error pristine_test.failed updated_test.failed pristine_test.notrun updated_test.notrun || true
135 touch pristine_build.error updated_build.error pristine_test.failed updated_test.failed pristine_test.notrun updated_test.notrun
136 echo "Grepping for Errors:"
137 grep "error:" build_pristine/build.output | awk '{$1 = ""; print $0;}' &> pristine_build.error || true
138 grep "error:" build_updated/build.output | awk '{$1 = ""; print $0;}' &> updated_build.error || true
139 grep "(Failed)" build_pristine/test.output | cut -d " " -f 3- | sort -u &> pristine_test.failed || true
140 grep "(Failed)" build_updated/test.output | cut -d " " -f 3- | sort -u &> updated_test.failed || true
141 grep "(Not Run)" build_pristine/test.output | cut -d " " -f 3- | sort -u &> pristine_test.notrun || true
142 grep "(Not Run)" build_updated/test.output | cut -d " " -f 3- | sort -u &> updated_test.notrun || true
143
144 DIFF_ERRORS=`diff pristine_build.error updated_build.error | wc -l`
145 DIFF_FAILED=`diff pristine_test.failed updated_test.failed | wc -l`
146 DIFF_NOTRUN=`diff pristine_test.notrun updated_test.notrun | wc -l`
147 TOTAL_PROBLEMS=$((${DIFF_ERRORS} + ${DIFF_FAILED} + ${DIFF_NOTRUN}))
148
149 echo "Total Problems: " ${TOTAL_PROBLEMS}
150 if [ "${TOTAL_PROBLEMS}" -gt "0" ]; then
151 echo ""
152 echo ""
153 echo "FAILED COMPARISON TEST"
154 echo ""
155 echo ""
156 echo "Diff Build Errors:"
157 diff pristine_build.error updated_build.error || true
158
159 echo ""
160 echo ""
161 echo "Diff Failed Tests"
162 diff pristine_test.failed updated_test.failed || true
163
164 echo ""
165 echo ""
166 echo "Diff NotRun Tests"
167 diff pristine_test.notrun updated_test.notrun || true
168 exit 1
169 fi
170 fi