tzwrapper.cc: fixed use of iterator after erase
[barry.git] / test / buildtest.sh
blob7a162889658bb2f008fd69dfbf42196699853891
1 #!/bin/bash
4 # Edit these settings to reflect your system
6 MAKEOPTS=-j2
7 export CC="ccache gcc"
8 export CXX="ccache g++"
10 # Make sure any errors stop the test
11 set -e
13 Usage() {
14 echo "Main Barry build test script. Tests the master branch by default."
15 echo
16 echo "Usage:"
17 echo " ./buildtest.sh [commit] [/path/to/libopensync-0.22.tar.bz2]"
18 echo
19 echo "Or, write a ~/.barrytest2 file that contains shell commands"
20 echo "setting OSYNCROOTDIR to the directory you used as a --prefix"
21 echo "when building your own libopensync."
22 echo
23 echo "Note that this directory must be writable by the user that"
24 echo "runs the test, as the plugin will be installed during the"
25 echo "build test."
26 echo
27 echo "You can also set OSYNCROOTDIR_0_40 to the 0.4x opensync directory."
28 echo
31 if [ "$1" = "-h" ] ; then
32 Usage
33 exit 1
37 # Check whether the desktop 0.22/0.4x optional build tests can be done
39 DESKTOP_OPTIONAL_BUILD_TEST=1
40 if pkg-config --list-all |grep opensync ; then
41 DESKTOP_OPTIONAL_BUILD_TEST=0
42 echo
43 echo "A version of opensync is already installed on your"
44 echo "system in default directories. Therefore the"
45 echo "tests of the optional desktop builds cannot be done,"
46 echo "and will therefore be skipped."
47 echo
48 echo "Press enter to continue..."
49 read
52 LIBUSB_0_1_OPTIONAL_BUILD_TEST=1
53 if ! pkg-config --list-all | grep "libusb " ; then
54 LIBUSB_0_1_OPTIONAL_BUILD_TEST=0
55 echo
56 echo "No libusb 0.1 library found in pkgconfig, will"
57 echo "not perform libusb 0.1 based tests."
58 echo
59 echo "Press enter to continue..."
60 read
63 LIBUSB_1_0_OPTIONAL_BUILD_TEST=1
64 if ! pkg-config --list-all | grep "libusb-1.0 " ; then
65 LIBUSB_1_0_OPTIONAL_BUILD_TEST=0
66 echo
67 echo "No libusb 1.0 library found in pkgconfig, will"
68 echo "not perform libusb 1.0 based tests."
69 echo
70 echo "Press enter to continue..."
71 read
76 # Jump to directory that script is located, if necessary
79 if [ "$(dirname $0)" != "." ] ; then
80 cd "$(pwd)/$(dirname $0)"
81 echo "You ran the script outside the directory it is in."
82 echo "Changing directory to: $(pwd)"
83 echo "If this is not desired, abort now..."
84 sleep 1s
87 if [ -d "build" ] ; then
88 echo "'build' directory already exists, exiting..."
89 exit 1
92 BASEPATH=$(pwd)
93 COMMIT="$1"
94 OSYNCSOURCE="$2"
96 if [ -z "$COMMIT" ] ; then
97 COMMIT="master"
100 mkdir -p build
103 # Do we have a ~/.barrytest2 config?
105 if [ -f ~/.barrytest2 ] ; then
106 . ~/.barrytest2
111 # First, build opensync in a local directory
114 if [ -n "$OSYNCROOTDIR" ] ; then
115 echo "Using opensync rootdir: $OSYNCROOTDIR"
116 elif [ -z "$OSYNCROOTDIR" -a -n "$OSYNCSOURCE" ] ; then
117 echo "Extracting opensync sources and building..."
118 (cd build && tar xjf "$OSYNCSOURCE" && \
119 cd libopensync-0.22 && \
120 ./configure -prefix="$BASEPATH/build/osyncrootdir" && \
121 make $MAKEOPTS install)
122 OSYNCROOTDIR="$BASEPATH/build/osyncrootdir"
123 else
124 Usage
125 exit 1
128 if [ -n "$OSYNCROOTDIR_0_40" ] ; then
129 echo "Using opensync-0.4x rootdir: $OSYNCROOTDIR_0_40"
135 # Move .. barry into its own buildable directory
137 echo "Moving barry [$COMMIT] into it's own directory..."
138 sleep 2s
139 mkdir -p build/barry
140 (cd "./$(git rev-parse --show-cdup)" && git archive --prefix="" "$COMMIT") | \
141 tar -C build/barry -xf -
142 cp -a build/barry build/barry-orig
147 # Prepare for Barry building
149 cd build/barry
150 export PKG_CONFIG_PATH="$BASEPATH/build/rootdir/lib/pkgconfig:$OSYNCROOTDIR/lib/pkgconfig:$OSYNCROOTDIR_0_40/lib/pkgconfig"
154 # Create configure script
156 ./buildgen.sh
160 # Build and test as individual packages
162 echo "Individual package build test..."
164 rm -rf "$BASEPATH/build/rootdir"
166 export CXXFLAGS="-Wall -Werror -O0 -g"
167 ./configure --prefix="$BASEPATH/build/rootdir" --disable-boost
168 make $MAKEOPTS
169 make distclean
170 ./configure --prefix="$BASEPATH/build/rootdir" --disable-sync
171 make $MAKEOPTS
172 make distclean
173 ./configure --prefix="$BASEPATH/build/rootdir" --enable-boost --with-zlib
174 make $MAKEOPTS
175 make install
176 make distclean
178 cd gui
179 export CXXFLAGS="-Wall -Werror -ansi -pedantic -O0 -g"
180 ./configure --prefix="$BASEPATH/build/rootdir"
181 make $MAKEOPTS
182 make install
183 make distclean
184 cd ..
186 cd opensync-plugin
187 export CXXFLAGS="-Wall -Werror -O0 -g"
188 ./configure --prefix="$BASEPATH/build/rootdir"
189 make $MAKEOPTS
190 make install
191 make distclean
192 cd ..
194 cd opensync-plugin-0.4x
195 export CXXFLAGS="-Wall -Werror -O0 -g"
196 ./configure --prefix="$BASEPATH/build/rootdir"
197 make $MAKEOPTS
198 make install
199 make distclean
200 cd ..
202 cd desktop
203 export CXXFLAGS="-Wall -Werror -O0 -g"
204 ./configure --prefix="$BASEPATH/build/rootdir"
205 make $MAKEOPTS
206 make install
207 make distclean
208 cd ..
210 if [ "$DESKTOP_OPTIONAL_BUILD_TEST" = "1" ] ; then
211 BACKUP_PKG_CONFIG_PATH="$PKG_CONFIG_PATH"
213 echo "\aTesting optional desktop builds in 10 seconds..."
214 sleep 10s
216 cd desktop
218 # Test only 0.22
219 export PKG_CONFIG_PATH="$BASEPATH/build/rootdir/lib/pkgconfig:$OSYNCROOTDIR/lib/pkgconfig"
221 export CXXFLAGS="-Wall -Werror -O0 -g"
222 ./configure --prefix="$BASEPATH/build/rootdir"
223 make $MAKEOPTS
224 make install
225 make distclean
227 # Test only 0.4x
228 export PKG_CONFIG_PATH="$BASEPATH/build/rootdir/lib/pkgconfig:$OSYNCROOTDIR_0_40/lib/pkgconfig"
230 export CXXFLAGS="-Wall -Werror -O0 -g"
231 ./configure --prefix="$BASEPATH/build/rootdir"
232 make $MAKEOPTS
233 make install
234 make distclean
236 # Restore path
237 export PKG_CONFIG_PATH="$BACKUP_PKG_CONFIG_PATH"
239 # Test without evolution (EvoSources.cc dummy code)
240 export CXXFLAGS="-Wall -Werror -O0 -g"
241 ./configure --prefix="$BASEPATH/build/rootdir" --without-evolution
242 make $MAKEOPTS
243 make install
244 make distclean
246 cd ..
251 # Build and test as one package
254 echo "Single build test..."
256 rm -rf "$BASEPATH/build/rootdir"
258 export CXXFLAGS="-Wall -Werror -O0 -g"
259 ./configure --prefix="$BASEPATH/build/rootdir" \
260 --enable-boost \
261 --enable-gui \
262 --enable-opensync-plugin \
263 --enable-opensync-plugin-4x \
264 --enable-desktop
265 make $MAKEOPTS install
266 make distclean
267 ./configure --prefix="$BASEPATH/build/rootdir" \
268 --enable-gui \
269 --enable-opensync-plugin \
270 --enable-opensync-plugin-4x \
271 --enable-desktop
272 make $MAKEOPTS
273 make distclean
276 # Test libusb selection from configure
277 # using with and without selection
279 if [ "$LIBUSB_0_1_OPTIONAL_BUILD_TEST" = "1" -a "$LIBUSB_1_0_OPTIONAL_BUILD_TEST" = "1" ] ; then
280 echo "Testing choosing libusb options..."
281 # Test that libusb 1.0 is chosen by default
282 ./configure --prefix="$BASEPATH/build/rootdir"
283 make $MAKEOPTS install
284 ldd $BASEPATH/build/rootdir/lib/libbarry.so | grep libusb-1.0.so
285 rm -rf "$BASEPATH/build/rootdir"
286 make distclean
288 # Test that libusb 0.1 is chosen if not libusb 1.0
289 ./configure --prefix="$BASEPATH/build/rootdir" \
290 --without-libusb1_0
291 make $MAKEOPTS install
292 ldd $BASEPATH/build/rootdir/lib/libbarry.so | grep libusb-0.1.so
293 rm -rf "$BASEPATH/build/rootdir"
294 make distclean
296 # Test that libusb 0.1 is chosen if explicitly asked for
297 ./configure --prefix="$BASEPATH/build/rootdir" \
298 --with-libusb
299 make $MAKEOPTS install
300 ldd $BASEPATH/build/rootdir/lib/libbarry.so | grep libusb-0.1.so
301 rm -rf "$BASEPATH/build/rootdir"
302 make distclean
307 # Test that cleanall cleans up all traces
309 echo "Testing buildgen cleanall..."
310 ./buildgen.sh cleanall
311 cd "$BASEPATH"
312 diff -ruN build/barry-orig build/barry
313 cd build/barry
318 # Test 'make dist' (the dist family of targets leaves build evidence
319 # behind, so do this after the cleanall check)
321 echo "Testing 'make dist'..."
323 rm -rf "$BASEPATH/build/rootdir"
325 ./buildgen.sh
326 ./configure \
327 --enable-gui \
328 --enable-opensync-plugin \
329 --enable-opensync-plugin-4x \
330 --enable-desktop
331 make dist
332 mkdir ../disttree
333 tar -C ../disttree -xjf barry-*.*.*.tar.bz2
334 make distcheck
335 make distclean
336 # remove the dist tarballs
337 rm -f barry-*.*.*.tar.{bz2,gz}
338 # compare our tree with the disttree
339 cd ..
340 # skip:
341 # autom4te.cache - autogenerated stuff we don't care about
342 # debian - dist tarball shouldn't have to care about that
343 # m4/ - more autogenerated stuff we dont' care about
344 # po/ - unsure
346 diff -ruN \
347 --exclude=autom4te.cache \
348 --exclude=debian \
349 --exclude='*.m4' \
350 --exclude=po \
351 --exclude=po-osyncwrap \
352 barry disttree/barry-*.*.*
355 # Success
357 cd "$BASEPATH"
358 rm -rf "$BASEPATH/build"
359 echo "All tests passed."