Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[jenkins] preliminary checks to save time when we are building a new slave
[simgrid.git] / tools / jenkins / build.sh
1 #!/bin/sh
2
3 # This script is used by various build projects on Jenkins
4
5 # See https://ci.inria.fr/simgrid/job/SimGrid-Multi/configure
6 # See https://ci.inria.fr/simgrid/job/Simgrid-Windows/configure
7
8 set -e
9
10 echo "XXXX Cleanup previous attempts"
11 rm -rf /tmp/simgrid*tmp
12 ls /tmp
13 df -h
14 echo "XXXX Let's go"
15
16 # Help older cmakes
17 if [ -e /usr/lib/jvm/java-7-openjdk-amd64 ] ; 
18 then
19   export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
20 fi
21
22 # usage: die status message...
23 die () {
24   local status=${1:-1}
25   shift
26   [ $# -gt 0 ] || set -- "Error - Halting"
27   echo "$@" >&2
28   exit $status
29 }
30
31 # Get an ON/OFF string from a command:
32 onoff() {
33   if "$@" > /dev/null ; then
34     echo ON
35   else
36     echo OFF
37   fi
38 }
39
40 # Check that we have what we need, or die quickly
41 test -e /bin/tar  || die "I need tar to compile. Please fix your slave."
42 test -e /bin/gzip || die "I need gzip to compile. Please fix your slave."
43 test -e /usr/include/libunwind.h || die "I need libunwind to compile. Please fix your slave."
44 test -e /usr/include/valgrind/valgrind.h || die "I need valgrind to compile. Please fix your slave."
45
46 build_mode="$1"
47 echo "Build mode $build_mode on $(uname -np)" >&2
48 case "$build_mode" in
49   "Debug")
50   ;;
51
52   "ModelChecker")
53   ;;
54
55   "DynamicAnalysis")
56   ;;
57
58   *)
59     die 1 "Unknown build_mode $build_mode"
60   ;;
61 esac
62
63 if test "$(uname -o)" = "Msys"; then
64   if [ -z "$NUMBER_OF_PROCESSORS" ]; then
65     NUMBER_OF_PROCESSORS=1
66   fi
67   GENERATOR="MSYS Makefiles"
68 else
69   NUMBER_OF_PROCESSORS="$(nproc)" || NUMBER_OF_PROCESSORS=1
70   GENERATOR="Unix Makefiles"
71 fi
72
73 ulimit -c 0 || true
74
75 if test "$(uname -o)" != "Msys"; then
76   echo "XX"
77   echo "XX Get out of the tree"
78   echo "XX"
79   if [ -d $WORKSPACE/build ]
80   then
81     rm -rf $WORKSPACE/build
82   fi
83   mkdir $WORKSPACE/build
84   cd $WORKSPACE/build
85
86   echo "XX"
87   echo "XX Build the archive out of the tree"
88   echo "XX   pwd: `pwd`"
89   echo "XX"
90
91   cmake -G"$GENERATOR" -Denable_documentation=OFF $WORKSPACE
92   make dist -j$NUMBER_OF_PROCESSORS
93
94   echo "XX"
95   echo "XX Open the resulting archive"
96   echo "XX"
97   tar xzf `cat VERSION`.tar.gz
98   cd `cat VERSION`
99 fi
100
101 echo "XX"
102 echo "XX Configure and build SimGrid"
103 echo "XX   pwd: `pwd`"
104 echo "XX"
105 cmake -G"$GENERATOR"\
106   -Denable_debug=ON -Denable_documentation=OFF -Denable_coverage=OFF \
107   -Denable_model-checking=$(onoff test "$build_mode" = "ModelChecker") \
108   -Denable_smpi_ISP_testsuite=$(onoff test "$build_mode" = "ModelChecker") \
109   -Denable_compile_optimizations=$(onoff test "$build_mode" = "Debug") \
110   -Denable_smpi_MPICH3_testsuite=$(onoff test "$build_mode" != "DynamicAnalysis") \
111   -Denable_mallocators=$(onoff test "$build_mode" != "DynamicAnalysis") \
112   -Denable_memcheck=$(onoff test "$build_mode" = "DynamicAnalysis") \
113   -Denable_compile_warnings=ON -Denable_smpi=ON \
114   -Denable_latency_bound_tracking=OFF -Denable_jedule=OFF \
115   -Denable_tracing=ON -Denable_java=ON -Denable_lua=OFF
116 #  -Denable_lua=$(onoff test "$build_mode" != "DynamicAnalysis") \
117
118
119 make -j$NUMBER_OF_PROCESSORS VERBOSE=1
120
121 if test "$(uname -o)" != "Msys"; then
122   cd $WORKSPACE/build
123   cd `cat VERSION`
124 fi
125
126 TRES=0
127
128 echo "XX"
129 echo "XX Run the tests"
130 echo "XX   pwd: `pwd`"
131 echo "XX"
132
133 ctest -T test --output-on-failure --no-compress-output || true
134 if [ -f Testing/TAG ] ; then
135    xsltproc $WORKSPACE/tools/jenkins/ctest2junit.xsl Testing/`head -n 1 < Testing/TAG`/Test.xml > CTestResults.xml
136    mv CTestResults.xml $WORKSPACE
137 fi
138
139 echo "XX"
140 echo "XX Done. Return the results to cmake"
141 echo "XX"
142
143 if [ "$build_mode" = "DynamicAnalysis" ]
144 then
145   ctest -D ContinuousStart
146   ctest -D ContinuousConfigure
147   ctest -D ContinuousBuild
148   ctest -D ContinuousMemCheck
149   ctest -D ContinuousSubmit
150 fi
151
152 ctest -D ContinuousStart
153 ctest -D ContinuousConfigure
154 ctest -D ContinuousBuild
155 ctest -D ContinuousTest
156 ctest -D ContinuousSubmit
157
158 rm -rf `cat VERSION`