aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichał Łyszczek <michal.lyszczek@bofc.pl>2018-05-05 19:08:55 +0200
committerMichał Łyszczek <michal.lyszczek@bofc.pl>2018-05-05 19:08:55 +0200
commit6e8227a567ea9c09d8e0640d291d830701227f29 (patch)
tree6edf97ef158867fabc8f8a79cc41f54c89fa96e7
parent08c3dfc8cf569f0a9e0a8a54df61b5dd1131b10a (diff)
downloadembedlog-6e8227a567ea9c09d8e0640d291d830701227f29.tar.gz
embedlog-6e8227a567ea9c09d8e0640d291d830701227f29.tar.bz2
embedlog-6e8227a567ea9c09d8e0640d291d830701227f29.zip
run compilation test in parallel
-rw-r--r--test-compilation-options14
-rwxr-xr-xtest-compilation.sh180
2 files changed, 143 insertions, 51 deletions
diff --git a/test-compilation-options b/test-compilation-options
new file mode 100644
index 0000000..31467be
--- /dev/null
+++ b/test-compilation-options
@@ -0,0 +1,14 @@
+--enable-binary-logs
+--disable-out-file
+--disable-out-stderr
+--disable-out-tty
+--disable-timestamp
+--disable-fractions
+--disable-realtime
+--disable-monotonic
+--disable-prefix
+--disable-clock
+--disable-finfo
+--disable-colors
+--disable-prefix
+--disable-reentrant
diff --git a/test-compilation.sh b/test-compilation.sh
index ca6093c..bdc83bb 100755
--- a/test-compilation.sh
+++ b/test-compilation.sh
@@ -1,23 +1,116 @@
#!/bin/bash
-options=(--disable-out-file \
- --disable-out-stderr \
- --disable-out-tty \
- --disable-timestamp \
- --disable-fractions \
- --disable-realtime \
- --disable-monotonic \
- --disable-finfo \
- --disable-colors \
- --disable-prefix \
- --disable-reentrant \
- --enable-binary-logs)
+## ==========================================================================
+# _ __
+# (_)____ / /_ _____
+# / // __ \ / __ \ / ___/
+# / // /_/ // /_/ /(__ )
+# __/ / \____//_.___//____/
+# /___/
+## ==========================================================================
+
+
+prepare()
+{
+ project="${1}"
+ slot="${2}"
+
+ # clone
+ if ! git clone git://kurwinet.pl/"${project}" "${project}-${slot}"
+ then
+ echo "couldn't clone, sorry"
+ exit 1
+ fi
+
+ # prepare directory for distcheck, we need to at least once call autogen
+ # and configure (doesn't matter with what parameters
+
+ cd "${project}-${slot}"
+ ./autogen.sh
+ ./configure
+}
+
+build()
+{
+ opts="${1}"
+ project="${2}"
+ slot="${3}"
+
+ cd "${project}-${slot}"
+ export AM_DISTCHECK_CONFIGURE_FLAGS="${opts}"
+ make distcheck
+ exit ${?}
+}
+
+
+## ==========================================================================
+# __ _
+# ____ _____ ___ ____ ____ _ _____ ____ _ / /_ (_)____ ____
+# / __ \ / ___// _ \ / __ \ / __ `// ___// __ `// __// // __ \ / __ \
+# / /_/ // / / __// /_/ // /_/ // / / /_/ // /_ / // /_/ // / / /
+# / .___//_/ \___// .___/ \__,_//_/ \__,_/ \__//_/ \____//_/ /_/
+# /_/ /_/
+## ==========================================================================
+
+
+workdir="/tmp/parallel-test-compilation"
+combination_file="${workdir}/combinations"
+project="embedlog"
+optfile="test-compilation-options"
+
+export -f build
+export -f prepare
+
+if [ ${#} -ne 1 ]
+then
+ echo "usage ${0} <number-of-jobs>"
+ exit 1
+fi
+
+num_jobs=${1}
+
+# some sanity checks
+
+if [ ${num_jobs} -ne ${num_jobs} ]
+then
+ echo "num jobs is garbage: ${num_jobs}"
+ exit 1
+fi
+
+if [ ! -f "${optfile}" ]
+then
+ echo "file with options doesn't exist"
+ exit 1
+fi
+
+
+## ==========================================================================
+# __ __
+# _____ / /_ ____ _ _____ / /_
+# / ___// __// __ `// ___// __/
+# (__ )/ /_ / /_/ // / / /_
+# /____/ \__/ \__,_//_/ \__/
+#
+## ==========================================================================
+
+
+mapfile -t options < "${optfile}"
+
+# distcheck (when failed) leave readonly files which cannot be deleted
+chmod u+rwx -R "${workdir}"
+rm -rf "${workdir}"
+mkdir "${workdir}"
+cd "${workdir}"
+pwd
+
+# generate all combination of build options
iterations=$((2**${#options[@]} - 1))
-for i in `seq 0 1 $iterations`
+echo -n "" > "${combination_file}"
+for i in $(seq 0 1 $iterations)
do
opts=
- flags=`echo "obase=2;$i" | bc | rev`
+ flags=`echo "obase=2;${i}" | bc | rev`
for j in `seq 1 1 ${#flags}`
do
if [ "${flags:j-1:1}" == "1" ]
@@ -25,46 +118,31 @@ do
opts+="${options[j - 1]} "
fi
done
+ echo "${opts}" >> "${combination_file}"
+ echo -ne "\rgenerating combinations ${i}/${iterations}"
+done
- echo -n "[$i/$iterations] ${opts}... "
- echo -n "clean... "
- clean_output=`make clean 2>&1`
-
- if [ $? -ne 0 ]
- then
- echo "failed"
- echo "$clean_output"
- exit 1
- fi
-
- echo -n "configure... "
- configure_output=`./configure $opts -C 2>&1`
+# remove traling spaces from our combination files
+sed -i 's/[ ]*$//' "${combination_file}"
- if [ $? -ne 0 ]
- then
- echo "failed"
- echo "$configure_output"
- exit 1
- fi
+echo ""
- echo -n "make... "
- make_output=`make -j 2>&1`
+# ok, so first we need to clone as many directories as many jobs in parallel
+# will be run, it's because of the make distcheck that has harcoded values and
+# it won't work in parallel in same directory as another distcheck
- if [ $? -ne 0 ]
- then
- echo "failed"
- echo "$make_output"
- exit 1
- fi
+slots=
+for i in $(seq 1 1 ${num_jobs})
+do
+ slots+="${i} "
+done
- echo -n "tests... "
- tests_output=`make check 2>&1`
+# run preparation
+parallel --output-as-files --bar --results "${workdir}" \
+ --halt-on-error now,fail=1 --jobs ${num_jobs} \
+ prepare ::: "${project}" ::: ${slots}
- if [ $? -ne 0 ]
- then
- echo "failed"
- echo "$tests_output"
- exit 1
- fi
- echo ""
-done
+# and run distcheck tests, will take a loooong time
+cat ${combination_file} | parallel --output-as-files --bar \
+ --results "${workdir}" --halt-on-error now,fail=1 --jobs ${num_jobs} \
+ build {} "${project}" {%}