1#!/bin/sh 2# This file is in the public domain 3# $FreeBSD$ 4 5set -ex 6 7OPLIST=`sh listallopts.sh` 8 9MDUNIT=47 10export MDUNIT 11 12ODIR=/usr/obj/`pwd` 13FDIR=${ODIR}/files 14MNT=${ODIR}/_.mnt 15RDIR=${ODIR}/_.result 16: ${MAKE_JOBS:="-j$(sysctl -n hw.ncpu)"} 17 18export ODIR MNT RDIR FDIR 19 20bw ( ) ( 21 cd ../../.. 22 make showconfig \ 23 SRCCONF=${ODIR}/src.conf __MAKE_CONF=/dev/null \ 24 > ${FDIR}/_.sc 2>&1 25 a=$? 26 echo retval $a 27 if [ $a -ne 0 ] ; then 28 exit 1 29 fi 30 make ${MAKE_JOBS} buildworld \ 31 SRCCONF=${ODIR}/src.conf __MAKE_CONF=/dev/null \ 32 > ${FDIR}/_.bw 2>&1 33 a=$? 34 echo retval $a 35 if [ $a -ne 0 ] ; then 36 exit 1 37 fi 38 make ${MAKE_JOBS} buildkernel \ 39 KERNCONF=GENERIC \ 40 SRCCONF=${ODIR}/src.conf __MAKE_CONF=/dev/null \ 41 > ${FDIR}/_.bk 2>&1 42 a=$? 43 echo retval $a 44 if [ $a -ne 0 ] ; then 45 exit 1 46 fi 47 exit 0 48) 49 50iw ( ) ( 51 trap "umount ${MNT} || true" 1 2 15 EXIT 52 newfs -O1 -U -b 4096 -f 512 /dev/md$MDUNIT 53 mkdir -p ${MNT} 54 mount /dev/md${MDUNIT} ${MNT} 55 56 cd ../../.. 57 make ${MAKE_JOBS} installworld \ 58 SRCCONF=${ODIR}/src.conf __MAKE_CONF=/dev/null \ 59 DESTDIR=${MNT} \ 60 > ${FDIR}/_.iw 2>&1 61 a=$? 62 echo retval $a 63 if [ $a -ne 0 ] ; then 64 exit 1 65 fi 66 cd etc 67 make distribution \ 68 SRCCONF=${ODIR}/src.conf __MAKE_CONF=/dev/null \ 69 DESTDIR=${MNT} \ 70 > ${FDIR}/_.etc 2>&1 71 a=$? 72 echo retval $a 73 if [ $a -ne 0 ] ; then 74 exit 1 75 fi 76 cd .. 77 make ${MAKE_JOBS} installkernel \ 78 KERNCONF=GENERIC \ 79 DESTDIR=${MNT} \ 80 SRCCONF=${ODIR}/src.conf __MAKE_CONF=/dev/null \ 81 > ${FDIR}/_.ik 2>&1 82 a=$? 83 echo retval $a 84 if [ $a -ne 0 ] ; then 85 exit 1 86 fi 87 88 sync ${MNT} 89 ( cd ${MNT} && mtree -c ) > ${FDIR}/_.mtree 90 ( cd ${MNT} && du ) > ${FDIR}/_.du 91 ( df -i ${MNT} ) > ${FDIR}/_.df 92 echo success > ${FDIR}/_.success 93 sync 94 sleep 1 95 sync 96 sleep 1 97 trap "" 1 2 15 EXIT 98 umount ${MNT} 99 echo "iw done" 100) 101 102 103# Clean and recreate the ODIR 104 105if true ; then 106 echo "=== Clean and recreate ${ODIR}" 107 if rm -rf ${ODIR} ; then 108 true 109 else 110 chflags -R noschg ${ODIR} 111 rm -rf ${ODIR} 112 fi 113 mkdir -p ${ODIR} ${FDIR} ${MNT} 114 115fi 116 117trap "umount ${MNT} || true; mdconfig -d -u $MDUNIT" 1 2 15 EXIT 118 119umount $MNT || true 120mdconfig -d -u $MDUNIT || true 121dd if=/dev/zero of=${ODIR}/imgfile bs=1m count=4096 122mdconfig -a -t vnode -f ${ODIR}/imgfile -u $MDUNIT 123 124# Build & install the reference world 125 126if true ; then 127 echo "=== Build reference world" 128 echo '' > ${ODIR}/src.conf 129 MAKEOBJDIRPREFIX=$ODIR/_.ref 130 export MAKEOBJDIRPREFIX 131 bw 132 echo "=== Install reference world" 133 mkdir -p ${RDIR}/Ref 134 iw 135 mv ${FDIR}/_.* ${RDIR}/Ref 136fi 137 138# Parse option list into subdirectories with src.conf files. 139 140if true ; then 141 rm -rf ${RDIR}/[0-9a-f]* 142 for o in $OPLIST 143 do 144 echo "${o}=foo" > ${FDIR}/_src.conf 145 m=`md5 < ${FDIR}/_src.conf` 146 mkdir -p ${RDIR}/$m 147 mv ${FDIR}/_src.conf ${RDIR}/$m/src.conf 148 done 149fi 150 151# Run through each testtarget in turn 152 153if true ; then 154 for d in ${RDIR}/[0-9a-z]* 155 do 156 if [ ! -d $d ] ; then 157 continue; 158 fi 159 echo '------------------------------------------------' 160 cat $d/src.conf 161 echo '------------------------------------------------' 162 cp $d/src.conf ${ODIR}/src.conf 163 164 if [ ! -f $d/iw/done ] ; then 165 MAKEOBJDIRPREFIX=$ODIR/_.ref 166 export MAKEOBJDIRPREFIX 167 echo "# BW(ref)+IW(ref) `cat $d/src.conf`" 168 rm -rf $d/iw 169 mkdir -p $d/iw 170 iw || true 171 mv ${FDIR}/_.* $d/iw || true 172 touch $d/iw/done 173 fi 174 if [ ! -f $d/bw/done ] ; then 175 MAKEOBJDIRPREFIX=$ODIR/_.tst 176 export MAKEOBJDIRPREFIX 177 echo "# BW(opt) `cat $d/src.conf`" 178 rm -rf $d/w $d/bw 179 mkdir -p $d/w $d/bw 180 if bw ; then 181 mv ${FDIR}/_.* $d/bw || true 182 183 echo "# BW(opt)+IW(opt) `cat $d/src.conf`" 184 iw || true 185 mv ${FDIR}/_.* $d/w || true 186 touch $d/w/done 187 188 echo "# BW(opt)+IW(ref) `cat $d/src.conf`" 189 echo '' > ${ODIR}/src.conf 190 iw || true 191 mv ${FDIR}/_.* $d/bw || true 192 touch $d/bw/done 193 else 194 mv ${FDIR}/_.* $d/bw || true 195 touch $d/bw/done $d/w/done 196 fi 197 fi 198 done 199fi 200