NEWS/Changelog for previous commit.
[fvwm.git] / tests / test_options
blobfa97de4344ec09d842e5da6e4c4fddb6e797a9b4
1 #!/bin/sh
2 # Hell, this is really difficult with /bin/sh. I want my zsh back!
4 testdir=tests
5 fvwmdir=..
6 myname=`basename $0`
7 log=$testdir/$myname.log
9 typeset -i c1
10 typeset -i c2
11 typeset -i c3
12 typeset -i i1
13 typeset -i i2
14 typeset -i nopts
15 typeset -i copts
17 usage ()
19 echo "usage: $myname [-0] [-1] [-2] [-a] [make options]"
20 echo " -0: run tests with all options defined and disabled (2 builds)"
21 echo " -1: run tests with one option defined and disabled"
22 echo " -2: run tests with two options defined and disabled"
23 echo " -a: run all possible tests"
24 echo " default is: myname -0 -1"
25 echo " logging output goes to $log and $log.*"
29 #parse command line
31 run_depth_0=""
32 run_depth_1=""
33 run_depth_2=""
34 run_all=""
35 custom=""
36 while [ -n "$1" ] ; do
37 if [ "$1" = "-h" ] ; then
38 usage
39 exit
40 elif [ "$1" = "-?" ] ; then
41 usage
42 exit
43 elif [ "$1" = "-0" ] ; then
44 run_depth_0=1
45 run_all=""
46 custom=1
47 elif [ "$1" = "-1" ] ; then
48 run_depth_1=1
49 run_all=""
50 custom=1
51 elif [ "$1" = "-2" ] ; then
52 run_depth_2=1
53 run_all=""
54 custom=1
55 elif [ "$1" = "-a" ] ; then
56 run_depth_0=""
57 run_depth_1=""
58 run_depth_2=""
59 run_all=1
60 custom=1
61 else
62 break;
64 shift
65 done
67 MAKE_OPTS="$*"
69 # set default if nothing was selected
70 if [ -z "$custom" ]; then
71 run_depth_0="1"
72 run_depth_1="1"
75 if [ ! -x ./$myname ] ; then
76 echo please run $myname from $testdir
77 exit 1
79 cd $fvwmdir
80 rm -f "$log"* > /dev/null 2>&1
83 ##################
84 # some functions #
85 ##################
87 # clean up before next build
88 clean_up ()
90 make clean > /dev/null 2>&1
91 make distclean > /dev/null 2>&1
92 rm -f config.cache > /dev/null 2>&1
93 for i in `find . -name .deps -type d` ; do rm -rf $i; done > /dev/null 2>&1
94 for i in `find . -name Makefile` ; do rm -f $i; done > /dev/null 2>&1
95 for i in `find . -name "*.o"` ; do rm -f $i; done > /dev/null 2>&1
98 # generate parameter list for configure
99 disable_options ()
101 CONFIGURE_OPTS=""
102 while [ ! "$1" = "" ]; do
103 CONFIGURE_OPTS="$CONFIGURE_OPTS --disable-${BUILD_OPTIONS[$1]}"
104 shift
105 done
106 c3=0
107 while [ ! "${BUILD_OPTIONS[$c3]}" = "" ]; do
108 echo $CONFIGURE_OPTS | grep -q -- "--disable-${BUILD_OPTIONS[$c3]}" ||
109 CONFIGURE_OPTS="$CONFIGURE_OPTS --enable-${BUILD_OPTIONS[$c3]}"
110 c3=$c3+1
111 done
114 # disable all enabled options and vice versa
115 reverse_options ()
117 CONFIGURE_OPTS=`echo $CONFIGURE_OPTS |
118 sed -e 's/--enable-/--xyz-/g' |
119 sed -e 's/--disable-/--enable-/g' |
120 sed -e 's/--xyz-/--disable-/g'`
123 # call configure and make (with logging)
124 build ()
126 echo "+++ testing (logfile $1): $CONFIGURE_OPTS" >> $log
127 # clean up
128 echo "cleaning up..." >> $log
129 clean_up
130 # configure
131 echo "configuring..." >> $log
132 echo "./configure $CONFIGURE_OPTS" > $log.$1
133 if nice ./configure --enable-extras $CONFIGURE_OPTS >> $log.$1 2>&1; then
134 echo ok >> $log
135 else
136 echo FAILED >> $log
138 # make
139 echo "building..." >> $log
140 if nice make $MAKE_OPTS > $log.$1 2>&1; then
141 echo ok >> $log
142 else
143 echo FAILED >> $log
145 echo >> $log
148 ############################
149 # end of functions section #
150 ############################
153 # get the list of possible options
155 c1=0
156 nopts=0
157 copts=1
158 for i in `
159 grep "^\(dnl dummy: \)\?smr_SWITCH" configure.in |
160 grep -v debug-msgs |
161 sed -e 's/^.*smr_SWITCH.//g' |
162 cut -f 1 -d ","`; do
163 BUILD_OPTIONS[$c1]="$i"
164 OPTIONS="$OPTIONS $i"
165 c1=$c1+1;
166 nopts=$nopts+1;
167 copts=$copts+$copts
168 done
171 # now do the tests
173 if [ "$run_depth_1" = "1" ] ; then
174 i1=$nopts+$nopts
175 echo
176 echo " +++ running $i1 tests for depth 1 +++"
177 echo
178 c1=0
179 while [ ! "${BUILD_OPTIONS[$c1]}" = "" ]; do
180 disable_options $c1
181 echo build ${BUILD_OPTIONS[$c1]}_off
182 build ${BUILD_OPTIONS[$c1]}_off
183 reverse_options
184 echo build ${BUILD_OPTIONS[$c1]}_on
185 build ${BUILD_OPTIONS[$c1]}_on
186 c1=$c1+1
187 done
190 if [ "$run_depth_2" = "1" ] ; then
191 i1="$nopts * $nopts + $nopts"
192 echo
193 echo " +++ running $i1 tests for depth 2 +++"
194 echo
195 c1=0
196 while [ -n "${BUILD_OPTIONS[$c1]}" ]; do
197 c2=$c1+1
198 while [ -n "${BUILD_OPTIONS[$c2]}" ]; do
199 disable_options $c1 $c2
200 echo build ${BUILD_OPTIONS[$c1]}_off,${BUILD_OPTIONS[$c2]}_off
201 build ${BUILD_OPTIONS[$c1]}_off
202 reverse_options
203 echo build ${BUILD_OPTIONS[$c1]}_on,${BUILD_OPTIONS[$c2]}_on
204 build ${BUILD_OPTIONS[$c1]}_on
205 c2=$c2+1
206 done
207 c1=$c1+1
208 done
211 if [ "$run_depth_0" = "1" ] ; then
212 echo
213 echo " +++ running 2 tests for depth 0 +++"
214 echo
215 disable_options
216 reverse_options
217 echo build all_disabled
218 build all_disabled
219 disable_options
220 echo build all_enabled
221 build all_enabled
224 if [ "$run_all" = "1" ] ; then
225 i1=$copts+1
226 echo
227 echo " +++ running $i1 tests for all combination of options +++"
228 echo
229 c1=0
230 while [ ! "$c1" = "$copts" ]; do
231 c2=$c1
232 i1=0
233 opts_off=""
234 while [ ! "$i1" = "$nopts" ]; do
235 i2="$c2/2"
236 i2="$i2*2"
237 if [ "$i2" = "$c2" ]; then
238 opts_off="$opts_off $i1"
240 i1=$i1+1
241 c2=$c2/2
242 done
243 disable_options $opts_off
244 echo "test $c1 of $copts (logfile: `basename $log.$c1`):"
245 echo "$CONFIGURE_OPTS"
246 build $c1
247 c1=$c1+1
248 done