3 # Midnight Commander Test Suite
5 # (c) 2005 Roland Illig <roland.illig@gmx.de>
7 # Licensed under the GPL 2.0
11 ### initialize environment ###
13 LC_CTYPE
="C"; export LC_ALL
14 LC_COLLATE
="C"; export LC_COLLATE
15 LC_MONETARY
="C"; export LC_MONETARY
16 LC_NUMERIC
="C"; export LC_NUMERIC
17 LC_TIME
="C"; export LC_TIME
18 LC_MESSAGES
="C"; export LC_MESSAGES
19 LC_ALL
="C"; export LC_ALL
21 ### set default configuration ###
26 mc_basedir
="/tmp/mc-current-build"
27 mc_srcdir
="" # default: ${mc_basedir}/src
28 mc_builddir
="" # default: ${mc_basedir}/build
29 mc_prefixdir
="" # default: ${mc_basedir}/installed
30 mc_logdir
="" # default: ${mc_basedir}/logs
33 mc_cvs_repository
=":pserver:anonymous:@cvs.savannah.gnu.org:/sources/mc"
37 mc_configure_args_pre
="--enable-maintainer-mode"
38 mc_configure_args_post
=""
43 mc_cpp
="" # default: ${mc_cc} -E
51 mc_tests
="plain glib12 charset no_charset vfs no_vfs mcfs no_mcfs samba "\
52 "no_samba ext2undel no_ext2undel slang ncurses maintainer "\
53 "no_maintainer i18n no_i18n no_features all_features"
65 ### command line parsing ###
69 usage: `basename $0` [options ...] [var=value...] [<testname ...>]
71 -config <file> load the configuration from <file>
72 -basedir <dir> set the base directory
73 -srcdir <dir> select the directory where the source code is
74 read from or will be downloaded to from CVS
76 -[dont-]download checkout or update from CVS (default: ${do_download})
77 -[dont-]autoconf generate the configure script (default: ${do_autoconf})
78 -[dont-]cleanwork recreate the build directory (default: ${do_clean_workdir})
79 -[dont-]configure run configure (default: ${do_configure})
80 -[dont-]clean make clean (default: ${do_make_clean})
81 -[dont-]build make all (default: ${do_make_all})
82 -[dont-]check make check (default: ${do_make_check})
83 -[dont-]install make install (default: ${do_make_install})
85 -fast only do what's necessary
86 -nice <n> set the nice(1) value (default: ${mc_nice_value})
87 -maxlines <n> the maximum number of lines for each phase (default: ${mc_maxlines})
88 -quiet disable most status messages (default: ${quiet:-"no"}${quiet+"yes"})
94 _shquote_var
=`echo x"$1" | sed -e '1s,^x\([^=]*\)=.*,\1,' -e '1q'`
95 _shquote_val
=`echo x"$1" | sed '1s,^x[^=]*=\(.*\),\1,'`
96 _shquote_qval
=`echo x"${_shquote_val}" | sed -e '1s,.,,' -e s,\',\'\\\\\\\\\'\',g`
97 eval "${_shquote_var}='${_shquote_qval}'"
100 while test $# -ne 0; do
102 -config) shift; case "$1" in /*) .
"$1";; *) .
"./$1";; esac; shift;;
103 -basedir) shift; mc_basedir
="$1"; shift;;
104 -cvs-repository) shift; mc_cvs_repository
="$1"; shift;;
105 -cvs-module) shift; mc_cvs_module
="$1"; shift;;
106 -srcdir) shift; mc_srcdir
="$1"; shift;;
108 -cleanup) shift; do_clean_basedir
=yes;;
110 -download) shift; do_download
=yes;;
111 -dont-download) shift; do_download
=no
;;
112 -autoconf) shift; do_autoconf
=yes;;
113 -dont-autoconf) shift; do_autoconf
=no
;;
114 -cleanwork) shift; do_clean_workdir
=yes;;
115 -dont-cleanwork) shift; do_clean_workdir
=no
;;
116 -configure) shift; do_configure
=yes;;
117 -dont-configure) shift; do_configure
=no
;;
118 -clean) shift; do_make_clean
=yes;;
119 -dont-clean) shift; do_make_clean
=no
;;
120 -build) shift; do_make_all
=yes;;
121 -dont-build) shift; do_make_all
=no
;;
122 -check) shift; do_make_check
=yes;;
123 -dont-check) shift; do_make_check
=no
;;
124 -install) shift; do_make_install
=yes;;
125 -dont-install) shift; do_make_install
=no
;;
127 -fast) shift; do_clean_workdir
=no
132 -nice) shift; mc_nice_value
="$1"; shift;;
133 -maxlines) shift; mc_maxlines
="$1"; shift;;
134 -quiet) shift; quiet
="yes";;
135 mc_
*=*) eval_arg
"$1"; shift;;
145 ### Initialization ###
147 renice
${mc_nice_value} $$
1>/dev
/null
2>&1 || true
151 configure_args_enable_all
="--enable-largefile --enable-nls "\
152 "--enable-netcode --enable-background --enable-charset "\
153 "--with-mmap --with-included-gettext --with-x "\
154 "--with-vfs --with-mcfs --with-samba --with-ext2undel "\
155 "--with-gpm-mouse --with-subshell --with-edit"
156 configure_args_disable_all
="--disable-largefile --disable-nls "\
157 "--disable-netcode --disable-background --disable-charset "\
158 "--without-mmap --without-included-gettext --without-x "\
159 "--without-vfs --without-mcfs --without-samba --without-ext2undel "\
160 "--without-gpm-mouse --without-subshell --without-edit"
166 if test x
"`echo -n`" = x
"-n"; then
168 echo_cont
=" " # a tab character
176 if test -f "$1"; then
178 sed -e "${mc_maxlines}s,.*,(more lines follow ...)," -e "${mc_maxlines}q" "$1"
185 ${echo_n} "[`date`] $1"
190 echo "${echo_cont}ok"
195 echo "${echo_cont}WARNINGS"
196 warnings
=`expr $warnings + 1`
197 if test $# -gt 0; then show_file
"$1"; fi
201 phase_ok_or_warnings
() {
204 { test -n "${fsize}" && test ${fsize} -eq 0
205 } && phase_ok || phase_warnings
"$1"
210 echo "${echo_cont}FAILED"
212 errors
=`expr $errors + 1`
213 if test $# -gt 0; then show_file
"$1"; fi
218 "out=\"\${mc_logdir}/\${test_phase}.out\";"\
219 "err=\"\${mc_logdir}/\${test_phase}.err\";"
222 test_phase
="download"
223 eval "${setup_preconf_env}"
225 if test ${do_download} = no
&& test -d "${mc_srcdir}/CVS"; then
229 mkdir
-p "${mc_logdir}"
231 if test -d "${mc_srcdir}/CVS"; then
232 phase_start
"updating CVS copy ..."
233 ( cd "${mc_srcdir}" \
234 && env CVS_RSH
=${mc_cvs_rsh} cvs update
-r "${mc_cvs_tag}" -dP
235 ) 1>"${out}" 2>"${err}" && phase_ok_or_warnings "${err}" || phase_failed "${err}"
237 phase_start
"getting fresh CVS copy ..."
238 ( mkdir
-p "${mc_srcdir}" \
239 && cd "${mc_srcdir}/.." \
240 && env CVS_RSH
=${mc_cvs_rsh} cvs -d "${mc_cvs_repository}" checkout -P -r "${mc_cvs_tag}" -d "`basename "${mc_srcdir}"`" "${mc_cvs_module}"
241 ) 1>"${out}" 2>"${err}" && phase_ok_or_warnings "${err}" || phase_failed "${err}"
246 test_phase="autoconf
"
247 eval "${setup_preconf_env}"
249 if test ${do_autoconf} != yes && test -f "${mc_srcdir}/configure
"; then
253 mkdir -p "${mc_logdir}"
255 phase_start "creating .
/configure
script ...
"
256 { cd "${mc_srcdir}" \
257 && echo "#!/bin/sh" > ./configure.mc \
258 && chmod +x .
/configure.mc \
259 && ${SHELL-"/bin/sh"} .
/autogen.sh
260 } 1>"${out}" 2>"${err}" && phase_ok_or_warnings "${err}" || phase_failed "${err}"
264 "test_srcdir=\"\${mc_srcdir}\";"\
265 "test_workdir=\"\${mc_builddir}/\${testname}\";"\
266 "test_prefix=\"\${mc_prefixdir}/\${testname}\";"\
267 "test_logdir=\"\${mc_logdir}/\${testname}\";"\
268 "out=\"\${test_logdir}/\${test_phase}.out\";"\
269 "err=\"\${test_logdir}/\${test_phase}.err\";"
271 confbuild_cleanwork
() {
272 test_phase
="cleanwork"
273 eval "${setup_testenv}"
275 if test ${do_clean_workdir} = no ||
test ! -d "${test_workdir}"; then
279 mkdir
-p "${test_logdir}"
281 phase_start
"cleaning directory for ${testname} ..."
282 { rm -rf "${test_workdir}"
283 } 1>"${out}" 2>"${err}" && phase_ok_or_warnings "${err}" || phase_failed "${err}"
286 confbuild_configure
() {
287 test_phase
="configure"
288 eval "${setup_testenv}"
290 if test ${do_configure} != yes && test -f "${test_workdir}/Makefile"; then
294 mkdir
-p "${test_logdir}"
296 phase_start
"configuring for ${testname} ..."
298 mkdir
-p "${test_workdir}"
300 cmd
="${test_srcdir}/configure"
301 cmd
="${cmd} --prefix=\"${test_prefix}\""
302 cmd
="${cmd} MAKE=\"${mc_make}\""
303 cmd
="${cmd} CPP=\"${mc_cpp}\""
304 cmd
="${cmd} CPPFLAGS=\"${mc_cppflags}\""
305 cmd
="${cmd} CC=\"${mc_cc}\""
306 cmd
="${cmd} CFLAGS=\"${mc_cflags}\""
307 cmd
="${cmd} LDFLAGS=\"${mc_ldflags}\""
308 cmd
="${cmd} ${mc_configure_args_pre}"
309 cmd
="${cmd} ${configure_args}"
310 cmd
="${cmd} ${mc_configure_args_post}"
313 ) 1>"${out}" 2>"${err}" && phase_ok_or_warnings "${err}" || phase_failed "${err}"
318 test_phase
="make_${make_target}"
319 eval "${setup_testenv}"
321 if eval "test \${do_make_${make_target}} = no"; then
325 mkdir
-p "${test_logdir}"
327 phase_start
"running \"make ${make_target}\" for ${testname} ..."
328 ( cd "${test_workdir}" \
329 && eval "${mc_make} ${mc_make_flags} ${make_target}"
330 ) 1>"${out}" 2>"${err}" && phase_ok_or_warnings "${err}" || phase_failed "${err}"
337 if test ${failed} = yes; then return 0; fi
340 if test ${failed} = yes; then return 0; fi
342 confbuild_make
"clean"
343 if test ${failed} = yes; then return 0; fi
346 if test ${failed} = yes; then return 0; fi
348 confbuild_make
"check"
349 if test ${failed} = yes; then return 0; fi
351 confbuild_make
"install"
352 if test ${failed} = yes; then return 0; fi
364 configure_args
="--with-glib12"
370 configure_args
="--enable-charset"
375 testname
="no_charset"
376 configure_args
="--disable-charset"
382 configure_args
="--with-x"
388 configure_args
="--without-x"
394 configure_args
="--with-vfs"
400 configure_args
="--without-vfs"
406 configure_args
="--with-mcfs"
412 configure_args
="--without-mcfs"
418 configure_args
="--with-samba"
424 configure_args
="--without-samba"
430 configure_args
="--with-ext2undel"
434 test_no_ext2undel
() {
435 testname
="no_ext2undel"
436 configure_args
="--without-ext2undel"
442 configure_args
="--with-screen=slang"
448 configure_args
="--with-screen=ncurses"
453 testname
="maintainer"
454 configure_args
="--enable-maintainer-mode"
458 test_no_maintainer
() {
459 testname
="no_maintainer"
460 configure_args
="--disable-maintainer-mode"
466 configure_args
="--enable-nls"
472 configure_args
="--disable-nls"
477 testname
="no_features"
478 configure_args
="${configure_args_disable_all}"
482 test_all_features
() {
483 testname
="all_features"
484 configure_args
="${configure_args_enable_all}"
492 if test ${failed} = yes; then return 0; fi
495 if test ${failed} = yes; then return 0; fi
498 if type test_
"${i}" 2>/dev
/null \
499 |
grep "function" 1>/dev
/null
2>&1; then
502 echo "[`date`] test \"$i\" not found." 1>&2
503 errors
=`expr $errors + 1`
508 if test -z "${mc_srcdir}"; then mc_srcdir
="${mc_basedir}/src"; fi
509 if test -z "${mc_prefixdir}"; then mc_prefixdir
="${mc_basedir}/installed"; fi
510 if test -z "${mc_builddir}"; then mc_builddir
="${mc_basedir}/build"; fi
511 if test -z "${mc_logdir}"; then mc_logdir
="${mc_basedir}/logs"; fi
512 if test -z "${mc_cpp}"; then mc_cpp
="${mc_cc} -E"; fi
514 if test ${do_clean_basedir} = yes; then
515 phase_start
"cleaning up everything ..."
516 { rm -rf "${mc_basedir}"
517 } && phase_ok || phase_failed
519 if test $# -gt 0; then
525 if test ${errors} -ne 0 ||
test ${warnings} -ne 0; then
526 echo "[`date`] finished with ${errors} errors and ${warnings} warnings."
528 echo "[`date`] finished successfully."