3 # Midnight Commander Test Suite
5 # (c) 2005 Roland Illig <roland.illig@gmx.de>
7 # The Midnight Commander is free software: you can redistribute it
8 # and/or modify it under the terms of the GNU General Public License as
9 # published by the Free Software Foundation, either version 3 of the License,
10 # or (at your option) any later version.
12 # The Midnight Commander is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
22 ### initialize environment ###
24 LC_CTYPE
="C"; export LC_ALL
25 LC_COLLATE
="C"; export LC_COLLATE
26 LC_MONETARY
="C"; export LC_MONETARY
27 LC_NUMERIC
="C"; export LC_NUMERIC
28 LC_TIME
="C"; export LC_TIME
29 LC_MESSAGES
="C"; export LC_MESSAGES
30 LC_ALL
="C"; export LC_ALL
32 ### set default configuration ###
37 mc_basedir
="/tmp/mc-current-build"
38 mc_srcdir
="" # default: ${mc_basedir}/src
39 mc_builddir
="" # default: ${mc_basedir}/build
40 mc_prefixdir
="" # default: ${mc_basedir}/installed
41 mc_logdir
="" # default: ${mc_basedir}/logs
44 mc_cvs_repository
=":pserver:anonymous:@cvs.savannah.gnu.org:/sources/mc"
48 mc_configure_args_pre
="--enable-maintainer-mode"
49 mc_configure_args_post
=""
54 mc_cpp
="" # default: ${mc_cc} -E
62 mc_tests
="plain charset no_charset vfs no_vfs samba "\
63 "no_samba ext2undel no_ext2undel slang ncurses maintainer "\
64 "no_maintainer i18n no_i18n no_features all_features"
76 ### command line parsing ###
80 usage: `basename $0` [options ...] [var=value...] [<testname ...>]
82 -config <file> load the configuration from <file>
83 -basedir <dir> set the base directory
84 -srcdir <dir> select the directory where the source code is
85 read from or will be downloaded to from CVS
87 -[dont-]download checkout or update from CVS (default: ${do_download})
88 -[dont-]autoconf generate the configure script (default: ${do_autoconf})
89 -[dont-]cleanwork recreate the build directory (default: ${do_clean_workdir})
90 -[dont-]configure run configure (default: ${do_configure})
91 -[dont-]clean make clean (default: ${do_make_clean})
92 -[dont-]build make all (default: ${do_make_all})
93 -[dont-]check make check (default: ${do_make_check})
94 -[dont-]install make install (default: ${do_make_install})
96 -fast only do what's necessary
97 -nice <n> set the nice(1) value (default: ${mc_nice_value})
98 -maxlines <n> the maximum number of lines for each phase (default: ${mc_maxlines})
99 -quiet disable most status messages (default: ${quiet:-"no"}${quiet+"yes"})
105 _shquote_var
=`echo x"$1" | sed -e '1s,^x\([^=]*\)=.*,\1,' -e '1q'`
106 _shquote_val
=`echo x"$1" | sed '1s,^x[^=]*=\(.*\),\1,'`
107 _shquote_qval
=`echo x"${_shquote_val}" | sed -e '1s,.,,' -e s,\',\'\\\\\\\\\'\',g`
108 eval "${_shquote_var}='${_shquote_qval}'"
111 while test $# -ne 0; do
113 -config) shift; case "$1" in /*) .
"$1";; *) .
"./$1";; esac; shift;;
114 -basedir) shift; mc_basedir
="$1"; shift;;
115 -cvs-repository) shift; mc_cvs_repository
="$1"; shift;;
116 -cvs-module) shift; mc_cvs_module
="$1"; shift;;
117 -srcdir) shift; mc_srcdir
="$1"; shift;;
119 -cleanup) shift; do_clean_basedir
=yes;;
121 -download) shift; do_download
=yes;;
122 -dont-download) shift; do_download
=no
;;
123 -autoconf) shift; do_autoconf
=yes;;
124 -dont-autoconf) shift; do_autoconf
=no
;;
125 -cleanwork) shift; do_clean_workdir
=yes;;
126 -dont-cleanwork) shift; do_clean_workdir
=no
;;
127 -configure) shift; do_configure
=yes;;
128 -dont-configure) shift; do_configure
=no
;;
129 -clean) shift; do_make_clean
=yes;;
130 -dont-clean) shift; do_make_clean
=no
;;
131 -build) shift; do_make_all
=yes;;
132 -dont-build) shift; do_make_all
=no
;;
133 -check) shift; do_make_check
=yes;;
134 -dont-check) shift; do_make_check
=no
;;
135 -install) shift; do_make_install
=yes;;
136 -dont-install) shift; do_make_install
=no
;;
138 -fast) shift; do_clean_workdir
=no
143 -nice) shift; mc_nice_value
="$1"; shift;;
144 -maxlines) shift; mc_maxlines
="$1"; shift;;
145 -quiet) shift; quiet
="yes";;
146 mc_
*=*) eval_arg
"$1"; shift;;
156 ### Initialization ###
158 renice
${mc_nice_value} $$
1>/dev
/null
2>&1 || true
162 configure_args_enable_all
="--enable-largefile --enable-nls "\
163 "--enable-background --enable-charset "\
164 "--with-mmap --with-included-gettext --with-x "\
165 "--enable-vfs --enable-vfs-smb --enable-vfs-undelfs "\
166 "--with-gpm-mouse --with-subshell --with-edit"
167 configure_args_disable_all
="--disable-largefile --disable-nls "\
168 "--disable-background --disable-charset "\
169 "--without-mmap --without-included-gettext --without-x "\
170 "--disable-vfs --disable-vfs-smb --disable-vfs-undelfs "\
171 "--without-gpm-mouse --without-subshell --without-edit"
177 if test x
"`echo -n`" = x
"-n"; then
179 echo_cont
=" " # a tab character
187 if test -f "$1"; then
189 sed -e "${mc_maxlines}s,.*,(more lines follow ...)," -e "${mc_maxlines}q" "$1"
196 ${echo_n} "[`date`] $1"
201 echo "${echo_cont}ok"
206 echo "${echo_cont}WARNINGS"
207 warnings
=`expr $warnings + 1`
208 if test $# -gt 0; then show_file
"$1"; fi
212 phase_ok_or_warnings
() {
215 { test -n "${fsize}" && test ${fsize} -eq 0
216 } && phase_ok || phase_warnings
"$1"
221 echo "${echo_cont}FAILED"
223 errors
=`expr $errors + 1`
224 if test $# -gt 0; then show_file
"$1"; fi
229 "out=\"\${mc_logdir}/\${test_phase}.out\";"\
230 "err=\"\${mc_logdir}/\${test_phase}.err\";"
233 test_phase
="download"
234 eval "${setup_preconf_env}"
236 if test ${do_download} = no
&& test -d "${mc_srcdir}/CVS"; then
240 mkdir
-p "${mc_logdir}"
242 if test -d "${mc_srcdir}/CVS"; then
243 phase_start
"updating CVS copy ..."
244 ( cd "${mc_srcdir}" \
245 && env CVS_RSH
=${mc_cvs_rsh} cvs update
-r "${mc_cvs_tag}" -dP
246 ) 1>"${out}" 2>"${err}" && phase_ok_or_warnings "${err}" || phase_failed "${err}"
248 phase_start
"getting fresh CVS copy ..."
249 ( mkdir
-p "${mc_srcdir}" \
250 && cd "${mc_srcdir}/.." \
251 && env CVS_RSH
=${mc_cvs_rsh} cvs -d "${mc_cvs_repository}" checkout -P -r "${mc_cvs_tag}" -d "`basename "${mc_srcdir}"`" "${mc_cvs_module}"
252 ) 1>"${out}" 2>"${err}" && phase_ok_or_warnings "${err}" || phase_failed "${err}"
257 test_phase="autoconf
"
258 eval "${setup_preconf_env}"
260 if test ${do_autoconf} != yes && test -f "${mc_srcdir}/configure
"; then
264 mkdir -p "${mc_logdir}"
266 phase_start "creating .
/configure
script ...
"
267 { cd "${mc_srcdir}" \
268 && echo "#!/bin/sh" > ./configure.mc \
269 && chmod +x .
/configure.mc \
270 && ${SHELL-"/bin/sh"} .
/autogen.sh
271 } 1>"${out}" 2>"${err}" && phase_ok_or_warnings "${err}" || phase_failed "${err}"
275 "test_srcdir=\"\${mc_srcdir}\";"\
276 "test_workdir=\"\${mc_builddir}/\${testname}\";"\
277 "test_prefix=\"\${mc_prefixdir}/\${testname}\";"\
278 "test_logdir=\"\${mc_logdir}/\${testname}\";"\
279 "out=\"\${test_logdir}/\${test_phase}.out\";"\
280 "err=\"\${test_logdir}/\${test_phase}.err\";"
282 confbuild_cleanwork
() {
283 test_phase
="cleanwork"
284 eval "${setup_testenv}"
286 if test ${do_clean_workdir} = no ||
test ! -d "${test_workdir}"; then
290 mkdir
-p "${test_logdir}"
292 phase_start
"cleaning directory for ${testname} ..."
293 { rm -rf "${test_workdir}"
294 } 1>"${out}" 2>"${err}" && phase_ok_or_warnings "${err}" || phase_failed "${err}"
297 confbuild_configure
() {
298 test_phase
="configure"
299 eval "${setup_testenv}"
301 if test ${do_configure} != yes && test -f "${test_workdir}/Makefile"; then
305 mkdir
-p "${test_logdir}"
307 phase_start
"configuring for ${testname} ..."
309 mkdir
-p "${test_workdir}"
311 cmd
="${test_srcdir}/configure"
312 cmd
="${cmd} --prefix=\"${test_prefix}\""
313 cmd
="${cmd} MAKE=\"${mc_make}\""
314 cmd
="${cmd} CPP=\"${mc_cpp}\""
315 cmd
="${cmd} CPPFLAGS=\"${mc_cppflags}\""
316 cmd
="${cmd} CC=\"${mc_cc}\""
317 cmd
="${cmd} CFLAGS=\"${mc_cflags}\""
318 cmd
="${cmd} LDFLAGS=\"${mc_ldflags}\""
319 cmd
="${cmd} ${mc_configure_args_pre}"
320 cmd
="${cmd} ${configure_args}"
321 cmd
="${cmd} ${mc_configure_args_post}"
324 ) 1>"${out}" 2>"${err}" && phase_ok_or_warnings "${err}" || phase_failed "${err}"
329 test_phase
="make_${make_target}"
330 eval "${setup_testenv}"
332 if eval "test \${do_make_${make_target}} = no"; then
336 mkdir
-p "${test_logdir}"
338 phase_start
"running \"make ${make_target}\" for ${testname} ..."
339 ( cd "${test_workdir}" \
340 && eval "${mc_make} ${mc_make_flags} ${make_target}"
341 ) 1>"${out}" 2>"${err}" && phase_ok_or_warnings "${err}" || phase_failed "${err}"
348 if test ${failed} = yes; then return 0; fi
351 if test ${failed} = yes; then return 0; fi
353 confbuild_make
"clean"
354 if test ${failed} = yes; then return 0; fi
357 if test ${failed} = yes; then return 0; fi
359 confbuild_make
"check"
360 if test ${failed} = yes; then return 0; fi
362 confbuild_make
"install"
363 if test ${failed} = yes; then return 0; fi
375 configure_args
="--enable-charset"
380 testname
="no_charset"
381 configure_args
="--disable-charset"
387 configure_args
="--with-x"
393 configure_args
="--without-x"
399 configure_args
="--enable-vfs"
405 configure_args
="--disable-vfs"
411 configure_args
="--enable-vfs-smb"
417 configure_args
="--disable-vfs-smb"
423 configure_args
="--enable-vfs-undelfs"
427 test_no_ext2undel
() {
428 testname
="no_ext2undel"
429 configure_args
="--disable-vfs-undelfs"
435 configure_args
="--with-screen=slang"
441 configure_args
="--with-screen=ncurses"
446 testname
="maintainer"
447 configure_args
="--enable-maintainer-mode"
451 test_no_maintainer
() {
452 testname
="no_maintainer"
453 configure_args
="--disable-maintainer-mode"
459 configure_args
="--enable-nls"
465 configure_args
="--disable-nls"
470 testname
="no_features"
471 configure_args
="${configure_args_disable_all}"
475 test_all_features
() {
476 testname
="all_features"
477 configure_args
="${configure_args_enable_all}"
485 if test ${failed} = yes; then return 0; fi
488 if test ${failed} = yes; then return 0; fi
491 if type test_
"${i}" 2>/dev
/null \
492 |
grep "function" 1>/dev
/null
2>&1; then
495 echo "[`date`] test \"$i\" not found." 1>&2
496 errors
=`expr $errors + 1`
501 if test -z "${mc_srcdir}"; then mc_srcdir
="${mc_basedir}/src"; fi
502 if test -z "${mc_prefixdir}"; then mc_prefixdir
="${mc_basedir}/installed"; fi
503 if test -z "${mc_builddir}"; then mc_builddir
="${mc_basedir}/build"; fi
504 if test -z "${mc_logdir}"; then mc_logdir
="${mc_basedir}/logs"; fi
505 if test -z "${mc_cpp}"; then mc_cpp
="${mc_cc} -E"; fi
507 if test ${do_clean_basedir} = yes; then
508 phase_start
"cleaning up everything ..."
509 { rm -rf "${mc_basedir}"
510 } && phase_ok || phase_failed
512 if test $# -gt 0; then
518 if test ${errors} -ne 0 ||
test ${warnings} -ne 0; then
519 echo "[`date`] finished with ${errors} errors and ${warnings} warnings."
521 echo "[`date`] finished successfully."