#!/bin/bash # Profile format: # p profile name (uClibc arch) # arch arch (if profile != uClibc arch) # tc toolchain # e endian # sltp skip ltp tests # n target is native, can do runtime tests # wn native wrapper (set to "linux32" to test i386 on amd64) # path extra path to insert into PATH # h_c extra host cflags # h_l extra host ldflags # ltp_state reason ltp tests should be failing # sc config options to enable # uc config options to disable [[ ${SVCNAME} == "dcron" ]] \ && crontab=1 \ || crontab=0 source /etc/profile [[ ${HOSTNAME} == "vapier" ]] \ && official=${crontab} \ || official=0 usage() { cat <<-EOF Usage: $0 [options] Options: -d D use D for uClibc src dir -u only compile uClibc -ur only compile and run uClibc tests -a ask -r real run: send results to uClibc list -m M options to pass to make (default: ${MAKEOPTS}) -v verbose -x Run shell with -x mode (debug) -h help EOF } d=/usr/local/src/uclibc/trunk/catalyst UCLIBC_DIR=${d}/uClibc UCLIBC_CXX_DIR=/usr/local/src/uclibc/trunk/uClibc++ MAKEOPTS="-j4" ASK=0 profiles="" COMPILE_UCLIBC_ONLY=0 COMPILE_AND_RUN_UCLIBC_ONLY=0 VERBOSE=0 DEBUG=0 while [[ -n $1 ]] ; do case $1 in -d) UCLIBC_DIR=$2;shift;; -a) ASK=1;; -u) COMPILE_UCLIBC_ONLY=1;; -ur) COMPILE_AND_RUN_UCLIBC_ONLY=1;; -r) crontab=1;; -v) VERBOSE=1;; -x) DEBUG=1;; -m) MAKEOPTS=$2;shift;; -h) usage; exit 0;; -*) echo "Unknown option $1"; exit 1;; *) profiles="${profiles} $1";; esac shift done [[ ${DEBUG} == "1" ]] && set -x distdir=/usr/portage/distfiles ltpd=/usr/local/src/ltp cd $d || exit 1 rm -fr logs* && mkdir logs logs.ltp logs.open_posix || exit 1 rm -fr configs* && mkdir configs || exit 1 rm -fr bins.* && mkdir bins.{ltp,open_posix} || exit 1 rm -f email* .*.lock svnrev_old=$(cat .last.svn.rev 2>/dev/null) [[ ${crontab} -eq 1 ]] && exec >& $d/cron.log if [[ ${crontab} -eq 1 ]] ; then rm -f ${distdir}/uClibc-snapshot.tar.bz2 wget -q http://uclibc.org/downloads/snapshots/uClibc-snapshot.tar.bz2 -P ${distdir} || exit 1 rm -rf uClibc fi if [[ ! -d uClibc ]] ; then tar xf ${distdir}/uClibc-snapshot.tar.bz2 || exit 1 fi ud=${UCLIBC_DIR} cd ${ud} || exit 1 svnrev=$(svn st Makefile -v | awk '{print $1}') [[ ${crontab} -eq 1 && ${svnrev_old} == ${svnrev} ]] && exit 0 echo ${svnrev} > ${d}/.last.svn.rev logline() { echo -en "$*" | tee -a $l | tee -a $summary ; } SAVED_PATH=${PATH} start=$(date +%s) summary=$d/logs/.summary def_suffix=gentoo-linux-uclibc for p in ${d}/profiles/* ; do # # profile prep stuff # if [[ ${ASK} == "1" ]] ; then echo "Run $p ?" read in [[ ${in} == "n" ]] && continue elif [[ -n ${profiles} && " ${profiles} " != " "*${p##*/}*" " ]] ; then echo "Skipping $p ..." continue fi export PATH=${SAVED_PATH} unset arch tc e n sltp ltp_state wn path h_c h_l kern_headers sc uc lbase=$d/logs/${p##*/} l=${lbase} source $p sltp=${sltp:-0} [[ ${p} == */* ]] && p=${p##*/} [[ -z $arch ]] && arch=$p [[ -z $tc ]] && tc=$arch-$def_suffix [[ $tc != *-* ]] && tc=$tc-$def_suffix [[ -n $e ]] && ne=$([[ $e == little ]] && echo BIG || echo LITTLE) [[ -n $path ]] && export PATH=${path}:${PATH} [[ -z ${kern_headers} ]] && kern_headers=/usr/${tc}/usr/include # # uClibc build # echo "STAMP: snapshot $(date +"%Y%m%d") svn r${svnrev}" >> $l echo "STAMP: toolchain used '${tc}'" >> $l if type -p qlist > /dev/null ; then qlist -C -I -v cross-${tc} | sed 's|^|STAMP: |' >> $l else echo "STAMP: $(${tc}-gcc --version | head -n1)" >> $l echo "STAMP: binutils $(${tc}-ld --version | head -n1)" >> $l echo "STAMP: linux-headers $(echo 'UTS_RELEASE' | ${tc}-gcc -E -include linux/version.h - | tail -n1)" >> $l fi logline "$(printf '%10s | %8s | %7s | ' $p $arch Compile)" if ! type -p ${tc}-gcc > /dev/null ; then logline "SKIP\n" continue fi e=$(echo $e | tr '[a-z]' '[A-Z]') cd ${ud} || exit 1 make -s distclean || exit 1 yes "" | make defconfig >& /dev/null set_config() { for x in "$@" ; do sed -i -e '/^# '$x'/d' .config ; echo $x=y >> .config ; done ; } set_config UCLIBC_HAS_FTW DO_C99_MATH UCLIBC_HAS_RPC UCLIBC_HAS_FULL_RPC UCLIBC_HAS_REENTRANT_RPC UCLIBC_HAS_IPV6 ${sc} unset_config() { for x in "$@" ; do sed -i -e '/^'$x'=/d' .config ; echo '# '$x' is not set' >> .config ; done ; } unset_config UCLIBC_HAS_FNMATCH_OLD UCLIBC_HAS_REGEX_OLD ${uc} sed -i \ -e '/^TARGET_/d' \ -e '/KERNEL_HEADERS/s:=.*:="'${kern_headers}'":' \ -e '/RUNTIME_PREFIX/s:=.*:="/usr/'${tc}'":' \ -e '/DEVEL_PREFIX/s:=.*:="/usr/'${tc}'":' \ -e '/CROSS_COMPILER_PREFIX/s:=.*:="'${tc}-'":' \ .config [[ -n $e ]] \ && sed -i -e '/ARCH_.*_ENDIAN/d' .config \ && echo -e 'ARCH_'$e'_ENDIAN=y\nARCH_WANTS_'$e'_ENDIAN=y' >> .config echo TARGET_$arch=y >> .config yes "" | make oldconfig >& /dev/null make headers >& /dev/null echo 'utils check: all' >> Makefile.in make ${MAKEOPTS} -s all utils check UCLIBC_ONLY=1 COMPILE_ONLY=1 >& ${l}.tmp \ && stat="PASS" \ || stat="FAIL!" logline "$stat\n" cat ${l}.tmp >> $l rm -f ${l}.tmp cp .config ${l}.uClibc.config [[ ${COMPILE_UCLIBC_ONLY} == "1" ]] && continue [[ ${stat} == "PASS" ]] || continue # # uClibc test # if [[ ${n} == "yes" ]] ; then echo -e "\t\tuClibc tests" make -s -C test clean >& /dev/null HOST_CFLAGS="${h_c}" \ HOST_LDFLAGS="${h_l}" \ ${wn} \ make check \ >& ${l}.run.tmp \ && stat="PASS" \ || stat="FAIL!" logline "$(printf '%10s | %8s | %7s | ' $p $arch Run)" logline "$stat\n" echo "Result: ${stat}" > ${l}.run cat ${l}.run.tmp >> ${l}.run rm -f ${l}.run.tmp fi [[ ${COMPILE_AND_RUN_UCLIBC_ONLY} == "1" ]] && continue # # uClibc++ tests # if [[ -d ${UCLIBC_CXX_DIR} ]] ; then cd "${UCLIBC_CXX_DIR}" l=${lbase}.uClibc++ echo "\t\tuClibc++ build" make -s distclean >& /dev/null make allyesconfig >& ${l} make \ CROSS=${tc}- \ >& ${l}.tmp \ && stat="PASS" \ || stat="FAIL!" cat ${l}.tmp >> ${l} rm -f ${l}.tmp fi [[ ${sltp} -eq 1 ]] && continue while [[ -e ${d}/.ltp.lock ]] ; do sleep 2 ; done # # LTP build # echo -e "\t\tLTP build" l=${lbase}.ltp find ${ltpd} -name '*.o' | xargs rm -f make -C ${ltpd} -s clean >& /dev/null ldso=-static cross_cflags="-I${ud}/include" cross_ldflags="-B${ud}/lib -Wl,-rpath-link,${ud}/lib" [[ ${tc} == *-uclinux ]] && cross_cflags="${cross_cflags} -DUCLINUX" LDFLAGS="${ldso} ${cross_ldflags} -s" \ CROSS_CFLAGS="${cross_cflags}" \ CROSS_COMPILER=${tc}- \ make ${MAKEOPTS} -C ${ltpd} all install \ >& ${l}.tmp \ && stat="PASS" \ || stat="FAIL!" if [[ -n ${ltp_state} ]] ; then [[ ${stat} == "FAIL!" ]] \ && stat="XFAIL: expected due to ${ltp_state}" \ || stat="XPASS: should have failed !?" fi [[ ${stat} == "PASS" ]] \ && cp -r ${ltpd}/testcases/bin ${l}.bins echo "STATE: ${stat}" > ${l} echo "STAMP: uClibc snapshot $(date +"%Y%m%d") svn r${svnrev}" >> ${l} cat <<-EOF >> ${l} tc=${tc} ltpd=${ltpd} ud=${ud} ldso=${ldso} make -C \${ltpd} \\ LDFLAGS="-B\${ud}/lib -Wl,-rpath-link,\${ud}/lib \${ldso}" \\ CROSS_CFLAGS="-I\${ud}/include" \\ CROSS_COMPILER=\${tc}- EOF cat ${l}.tmp >> ${l} rm -f ${l}.tmp # # open_posix_testsuite build # echo -e "\t\tOpen Posix Testsuite build" optd=${ltpd}/testcases/open_posix_testsuite l=${lbase}.open_posix make ${MAKEOPTS} -C ${optd} -s clean >& /dev/null make -C ${optd} build-tests \ CPPFLAGS="-D_XOPEN_SOURCE=600 -I${ud}/include -I${optd}/include" \ LDFLAGS="-lpthread -lrt -lm ${ldso} ${cross_ldflags} -s" \ CC=${tc}-gcc \ >& /dev/null mv ${optd}/logfile ${l} if mkdir ${l}.bins ; then ( cd "${optd}" find . -name '*.test' -perm +1 -type f | \ tar c -T- -O | tar x -C ${l}.bins ) fi # # open_posix_testsuite run # [[ ${n} == "yes" ]] || continue #echo -e "\t\tOpen Posix Testsuite run" #${wn} make -C ${optd} run-tests >& /dev/null #mv ${optd}/logfile ${lbase}.open_posix.run #kill -9 $(pgrep -f .*conformance/interfaces/.*) >& /dev/null # # LTP run # [[ ${n} == "yes" && ${stat} == "PASS" ]] || continue [[ $(date +%a) =~ "(Sat|Sun)" ]] && continue echo -e "\t\tLTP run" ( touch ${d}/.ltp.lock cd ${ltpd} ( # pipes - ipc runs all of these for x in dio fs ipc math nptl pty sched syscalls ; do ${wn} ./runltp -f ${PWD}/runtest/${x} -q done ) | grep -v '^INFO:' >& ${lbase}.ltp.run rm -f ${d}/.ltp.lock ) done while [[ -e ${d}/.ltp.lock ]] ; do sleep 2 ; done cd $d [[ ${crontab} -eq 1 ]] && rm -rf uClibc end=$(date +%s) skip=$(grep SKIP $summary | wc -l) fail=$(grep FAIL $summary | wc -l) pass=$(grep PASS $summary | wc -l) cnt=$((skip+fail+pass)) [[ ${official} -eq 0 ]] \ && to=vapier@gentoo.org \ || to=uclibc@uclibc.org mv logs/*.ltp.bins bins.ltp/ mv logs/*.open_posix.bins bins.open_posix/ scp -C -l 64 -q /etc/cron.daily/uclibc-tests logs/* \ vapier@uclibc.org:~/public_html/build_logs/ mv logs/*.config configs/ [[ -n $(ls logs/*.ltp* 2>/dev/null) ]] && mv logs/*.ltp* logs.ltp/ [[ -n $(ls logs/*.open_posix* 2>/dev/null) ]] && mv logs/*.open_posix* logs.open_posix/ shopt -s nullglob echo -e "\nhttp://ltp.sourceforge.net/" >> $summary echo -e "LTP Summary:" >> $summary for f in logs.ltp/*.ltp ; do arch=${f##*/} ; arch=${arch%%.ltp} reason=$(sed -n '/^STATE/s|STATE: ||p' $f) printf "%10s | %7s | ${reason}\n" $arch "Compile" >> $summary f=logs.ltp/${arch}.ltp.run if [[ -e ${f} ]] ; then ltp_pass=$(awk '{if ($3 == "PASS") ++cnt} END {print cnt}' ${f}) ltp_brok=$(awk '{if ($3 == "BROK") ++cnt} END {print cnt}' ${f}) ltp_warn=$(awk '{if ($3 == "WARN") ++cnt} END {print cnt}' ${f}) ltp_fail=$(awk '{if ($3 == "FAIL") ++cnt} END {print cnt}' ${f}) ltp_cnt=$((ltp_pass+ltp_fail)) printf "%10s | %7s | " $arch "Run" >> $summary echo "${ltp_cnt} tests: ${ltp_pass:-0} pass / ${ltp_fail:-0} fail / ${ltp_brok:-0} broken / ${ltp_warn:-0} warnings" >> $summary fi done echo -e "\nhttp://posixtest.sourceforge.net/" >> $summary echo -e "Open Posix Testsuite Summary:" >> $summary for f in logs.open_posix/*.open_posix ; do arch=${f##*/} ; arch=${arch%%.open_posix} printf "%10s | %7s | " ${arch} "Compile" >> $summary opt_pass=$(grep "PASS" ${f} | wc -l) opt_fail=$(grep "FAIL" ${f} | wc -l) opt_cnt=$((opt_pass+opt_fail)) echo "${opt_cnt} tests: ${opt_pass} pass / ${opt_fail} fail" >> $summary f=${f}.run [[ -e ${f} ]] || continue printf "%10s | %7s | " ${arch} "Run" >> $summary # only check log lines from the build system itself egrep '^(conformance|functional|stress)/' ${f} \ | egrep -v -e'\.(c|h|o):' -e '\.o[(].*[)]: ' \ | awk '{ if ($3 == "PASS") { pass++; } else if ($3 ~ /FAIL/) { fail++; } else if ($3 == "SKIP") { skip++; } else { unk++; } } END { total = pass + fail + skip + unk; print total " tests: " \ pass " pass / " \ fail " fail / " \ skip " skip / " \ unk " unknown" }' >> $summary done mv ${summary} ${summary}.tmp cat << EOF > $summary Snapshot tested: $(date +"%Y%m%d") svn r${svnrev} Number of tests: ${cnt} (pass: ${pass} / fail: ${fail} / skip: ${skip}) Time spent: $((($end-$start)/60)) minutes $((($end-$start)%60)) seconds uClibc Summary: $(<${summary}.tmp) EOF [[ ${official} -eq 1 ]] && \ scp -C -q $summary vapier@uclibc.org:~/public_html/build_logs/00-summary email=$d/email cat << EOF > $email To: uClibc <${to}> From: Mike Frysinger Subject: uClibc buildlog for $(date +"%Y%m%d") snapshot (svn r${svnrev}) Date: $(date +"%d %h %Y %H:%M:%S %Z") All logs may be found here: http://www.uclibc.org/~vapier/ $(<$summary) EOF case ${HOSTNAME} in vapier) serv=home;; *) serv="";; esac [[ -n ${serv} ]] && serv="-r ${serv}" smtpblast -f vapier@gentoo.org -t ${to} ${serv} -i $email