run.fractal.tree.tests.bash 9.94 KB
Newer Older
1 2
#!/bin/bash

3 4 5
function usage() {
    echo "run.fractal.tree.tests.bash - run the nightly fractal tree test suite"
    echo "[--ftcc=$ftcc] [--BDBVERSION=$BDBVERSION] [--ctest_model=$ctest_model]"
6
    echo "[--commit=$commit]"
7 8 9
    return 1
}

10
set -e
11

12 13 14 15 16 17
pushd $(dirname $0) &>/dev/null
SCRIPTDIR=$PWD
popd &>/dev/null
FULLTOKUDBDIR=$(dirname $SCRIPTDIR)
TOKUDBDIR=$(basename $FULLTOKUDBDIR)
BRANCHDIR=$(basename $(dirname $FULLTOKUDBDIR))
18 19 20 21 22

function make_tokudb_name() {
    local tokudb_dir=$1
    local tokudb=$2
    if [ $tokudb_dir = "toku" ] ; then
23
        echo $tokudb
24
    else
25
        echo $(echo $tokudb_dir-$tokudb | tr / -)
26
    fi
27
}
28 29
tokudb_name=$(make_tokudb_name $BRANCHDIR $TOKUDBDIR)
export TOKUDB_NAME=$tokudb_name
30

31
productname=$tokudb_name
32

33 34 35
ftcc=icc
BDBVERSION=5.3
ctest_model=Nightly
36
commit=1
37 38 39 40 41 42 43 44 45 46 47 48
while [ $# -gt 0 ] ; do
    arg=$1; shift
    if [[ $arg =~ --(.*)=(.*) ]] ; then
        eval ${BASH_REMATCH[1]}=${BASH_REMATCH[2]}
    else
        usage; exit 1;
    fi
done

if [[ ! ( ( $ctest_model = Nightly ) || ( $ctest_model = Experimental ) || ( $ctest_model = Continuous ) ) ]]; then
    echo "--ctest_model must be Nightly, Experimental, or Continuous"
    usage
49
fi
50

51
export CMAKE_PREFIX_PATH=/usr/local/BerkeleyDB.$BDBVERSION:$CMAKE_PREFIX_PATH
52

53 54 55
# delete some characters that cygwin and osx have trouble with
function sanitize() {
    tr -d '[/:\\\\()]'
56 57
}

58
# gather some info
59
svnserver=https://svn.tokutek.com/tokudb
60 61 62 63 64
nodename=$(uname -n)
system=$(uname -s | tr '[:upper:]' '[:lower:]' | sanitize)
release=$(uname -r | sanitize)
arch=$(uname -m | sanitize)
date=$(date +%Y%m%d)
65
ncpus=$(grep bogomips /proc/cpuinfo | wc -l)
66
njobs=$(echo "$ncpus / 3" | bc)
67

68 69
# setup intel compiler env
if [ $ftcc = icc ] ; then
70 71 72 73 74 75 76 77 78
    d=/opt/intel/bin
    if [ -d $d ] ; then
	export PATH=$d:$PATH
	. $d/compilervars.sh intel64
    fi
    d=/opt/intel/cilkutil/bin
    if [ -d $d ] ; then
	export PATH=$d:$PATH
    fi
79 80 81 82 83
    export ftar=`which xiar`
    export ftld=`which xild`
else
    export ftar=`which ar`
    export ftld=`which ld`
84 85
fi

86
export GCCVERSION=$($ftcc --version|head -1|cut -f3 -d" ")
87

88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
function retry() {
    local cmd
    local retries
    local exitcode
    cmd=$*
    let retries=0
    while [ $retries -le 10 ] ; do
        echo `date` $cmd
        bash -c "$cmd"
        exitcode=$?
        echo `date` $cmd $exitcode $retries
        let retries=retries+1
        if [ $exitcode -eq 0 ] ; then break; fi
        sleep 10
    done
    test $exitcode = 0
}

106 107 108
if [[ $commit -eq 1 ]]; then
    svnbase=~/svn.build
    if [ ! -d $svnbase ] ; then mkdir $svnbase ; fi
109

110 111 112 113 114
    # checkout the build dir
    buildbase=$svnbase/tokudb.build
    if [ ! -d $buildbase ] ; then
        mkdir $buildbase
    fi
115

116 117 118
    # make the build directory, possibly on multiple machines simultaneously, there can be only one
    builddir=$buildbase/$date
    pushd $buildbase
119 120 121
    set +e
    svn mkdir $svnserver/tokudb.build/$date -m "" || true
    retry svn co -q $svnserver/tokudb.build/$date
122 123 124
    if [ ! -d $date ] ; then
        exit 1
    fi
125
    set -e
126
    popd
127

128 129 130 131
    tracefilepfx=$builddir/$productname+$ftcc-$GCCVERSION+bdb-$BDBVERSION+$nodename+$system+$release+$arch
else
    tracefilepfx=$FULLTOKUDBDIR/test-trace
fi
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146

function getsysinfo() {
    tracefile=$1; shift
    uname -a >$tracefile 2>&1
    ulimit -a >>$tracefile 2>&1
    cmake --version >>$tracefile 2>&1
    $ftcc -v >>$tracefile 2>&1
    valgrind --version >>$tracefile 2>&1
    cat /etc/issue >>$tracefile 2>&1
    cat /proc/version >>$tracefile 2>&1
    cat /proc/cpuinfo >>$tracefile 2>&1
    env >>$tracefile 2>&1
}

function get_latest_svn_revision() {
147
    svn info $1 | awk -v ORS="" '/Last Changed Rev:/ { print $4 }'
148
}
149

150 151 152
function my_mktemp() {
    mktemp /tmp/$(whoami).$1.XXXXXXXXXX
}
153

154 155
yesterday="$(date -u -d yesterday +%F) 03:59:00 +0000"

156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172
################################################################################
## run tests on icc release build
resultsdir=$tracefilepfx-Release
mkdir $resultsdir
tracefile=$tracefilepfx-Release/trace

getsysinfo $tracefile

mkdir -p $FULLTOKUDBDIR/Release >/dev/null 2>&1
cd $FULLTOKUDBDIR/Release
cmake \
    -D CMAKE_BUILD_TYPE=Release \
    -D INTEL_CC=ON \
    -D BUILD_TESTING=ON \
    -D USE_BDB=ON \
    -D RUN_LONG_TESTS=ON \
    -D USE_CILK=OFF \
173 174 175 176
    -D USE_CTAGS=OFF \
    -D USE_GTAGS=OFF \
    -D USE_ETAGS=OFF \
    -D USE_CSCOPE=OFF \
177 178
    .. 2>&1 | tee -a $tracefile
cmake --system-information $resultsdir/sysinfo
179
make clean
180 181
# update to yesterday exactly just before ctest does nightly update
svn up -q -r "{$yesterday}" ..
182
set +e
183
ctest -j$njobs \
184 185 186 187 188
    -D ${ctest_model}Start \
    -D ${ctest_model}Update \
    -D ${ctest_model}Configure \
    -D ${ctest_model}Build \
    -D ${ctest_model}Test \
189 190 191 192 193
    2>&1 | tee -a $tracefile
set -e

cp $tracefile notes.txt
set +e
194
ctest -D ${ctest_model}Submit -A notes.txt \
195 196 197 198 199 200
    2>&1 | tee -a $tracefile
set -e
rm notes.txt

tag=$(head -n1 Testing/TAG)
cp -r Testing/$tag $resultsdir
201 202 203
if [[ $commit -eq 1 ]]; then
    cf=$(my_mktemp ftresult)
    cat "$resultsdir/trace" | awk '
204 205 206 207 208 209 210 211 212 213
/[0-9]+% tests passed, [0-9]+ tests failed out of [0-9]+/ {
    fail=$4;
    total=$9;
    pass=total-fail;
    ORS=" ";
    if (fail>0) {
        print "FAIL=" fail
    }
    print "PASS=" pass
}' >"$cf"
214 215 216
    get_latest_svn_revision $FULLTOKUDBDIR >>"$cf"
    echo -n " " >>"$cf"
    cat "$resultsdir/trace" | awk '
217 218 219 220 221 222 223
BEGIN {
    FS=": ";
}
/Build name/ {
    print $2;
    exit
}' >>"$cf"
224 225
    (echo; echo) >>"$cf"
    cat "$resultsdir/trace" | awk '
226 227 228 229 230 231 232 233 234 235
BEGIN {
    printit=0
}
/[0-9]*\% tests passed, [0-9]* tests failed out of [0-9]*/ { printit=1 }
/^   Site:/ { printit=0 }
{
    if (printit) {
        print $0
    }
}' >>"$cf"
236 237 238 239
    svn add $resultsdir
    svn commit -F "$cf" $resultsdir
    rm $cf
fi
240

241 242 243 244 245 246
if [[ $commit -eq 1 ]]; then
    # hack to make long tests run nightly but not when run in experimental mode
    longtests=ON
else
    longtests=OFF
fi
247
################################################################################
248 249
## run gcov on gcc debug build
resultsdir=$tracefilepfx-Coverage
250
mkdir $resultsdir
251
tracefile=$tracefilepfx-Coverage/trace
252 253 254

getsysinfo $tracefile

255 256
mkdir -p $FULLTOKUDBDIR/Coverage >/dev/null 2>&1
cd $FULLTOKUDBDIR/Coverage
257 258 259
cmake \
    -D CMAKE_BUILD_TYPE=Debug \
    -D BUILD_TESTING=ON \
260
    -D USE_GCOV=ON \
261
    -D USE_BDB=OFF \
262
    -D RUN_LONG_TESTS=$longtests \
263
    -D USE_CILK=OFF \
264 265 266 267
    -D USE_CTAGS=OFF \
    -D USE_GTAGS=OFF \
    -D USE_ETAGS=OFF \
    -D USE_CSCOPE=OFF \
268 269
    .. 2>&1 | tee -a $tracefile
cmake --system-information $resultsdir/sysinfo
270
make clean
271 272
# update to yesterday exactly just before ctest does nightly update
svn up -q -r "{$yesterday}" ..
273
set +e
274
ctest -j$njobs \
275 276 277 278 279
    -D ${ctest_model}Start \
    -D ${ctest_model}Update \
    -D ${ctest_model}Configure \
    -D ${ctest_model}Build \
    -D ${ctest_model}Test \
280
    -D ${ctest_model}Coverage \
281 282 283 284 285
    2>&1 | tee -a $tracefile
set -e

cp $tracefile notes.txt
set +e
286
ctest -D ${ctest_model}Submit -A notes.txt \
287 288 289 290 291 292
    2>&1 | tee -a $tracefile
set -e
rm notes.txt

tag=$(head -n1 Testing/TAG)
cp -r Testing/$tag $resultsdir
293 294 295
if [[ $commit -eq 1 ]]; then
    cf=$(my_mktemp ftresult)
    cat "$resultsdir/trace" | awk '
296 297 298
BEGIN {
    ORS=" ";
}
299 300 301
/Percentage Coverage:/ {
    covpct=$3;
}
302 303 304 305 306 307
/[0-9]+% tests passed, [0-9]+ tests failed out of [0-9]+/ {
    fail=$4;
    total=$9;
    pass=total-fail;
}
END {
308
    print "COVERAGE=" covpct
309 310 311 312 313
    if (fail>0) {
        print "FAIL=" fail
    }
    print "PASS=" pass
}' >"$cf"
314 315 316
    get_latest_svn_revision $FULLTOKUDBDIR >>"$cf"
    echo -n " " >>"$cf"
    cat "$resultsdir/trace" | awk '
317 318 319 320 321 322 323
BEGIN {
    FS=": ";
}
/Build name/ {
    print $2;
    exit
}' >>"$cf"
324 325
    (echo; echo) >>"$cf"
    cat "$resultsdir/trace" | awk '
326 327 328 329 330 331 332 333 334 335
BEGIN {
    printit=0
}
/[0-9]*\% tests passed, [0-9]* tests failed out of [0-9]*/ { printit=1 }
/^   Site:/ { printit=0 }
{
    if (printit) {
        print $0
    }
}' >>"$cf"
336 337 338 339
    svn add $resultsdir
    svn commit -F "$cf" $resultsdir
    rm $cf
fi
340 341

################################################################################
342 343
## run valgrind on icc debug build
resultsdir=$tracefilepfx-Debug
344
mkdir $resultsdir
345
tracefile=$tracefilepfx-Debug/trace
346 347 348

getsysinfo $tracefile

349 350
mkdir -p $FULLTOKUDBDIR/Debug >/dev/null 2>&1
cd $FULLTOKUDBDIR/Debug
351 352
cmake \
    -D CMAKE_BUILD_TYPE=Debug \
353
    -D INTEL_CC=ON \
354 355
    -D BUILD_TESTING=ON \
    -D USE_BDB=OFF \
356
    -D RUN_LONG_TESTS=$longtests \
357
    -D USE_CILK=OFF \
358 359 360 361
    -D USE_CTAGS=OFF \
    -D USE_GTAGS=OFF \
    -D USE_ETAGS=OFF \
    -D USE_CSCOPE=OFF \
362 363
    .. 2>&1 | tee -a $tracefile
cmake --system-information $resultsdir/sysinfo
364
make clean
365 366
# update to yesterday exactly just before ctest does nightly update
svn up -q -r "{$yesterday}" ..
367
set +e
368
ctest -j$njobs \
369 370 371 372 373
    -D ${ctest_model}Start \
    -D ${ctest_model}Update \
    -D ${ctest_model}Configure \
    -D ${ctest_model}Build \
    -D ${ctest_model}Test \
374
    -D ${ctest_model}MemCheck \
375 376 377 378 379
    2>&1 | tee -a $tracefile
set -e

cp $tracefile notes.txt
set +e
380
ctest -D ${ctest_model}Submit -A notes.txt \
381 382 383 384 385 386
    2>&1 | tee -a $tracefile
set -e
rm notes.txt

tag=$(head -n1 Testing/TAG)
cp -r Testing/$tag $resultsdir
387 388 389
if [[ $commit -eq 1 ]]; then
    cf=$(my_mktemp ftresult)
    cat "$resultsdir/trace" | awk '
390
BEGIN {
391 392
    errs=0;
    look=0;
393 394 395 396 397 398 399
    ORS=" ";
}
/[0-9]+% tests passed, [0-9]+ tests failed out of [0-9]+/ {
    fail=$4;
    total=$9;
    pass=total-fail;
}
400 401 402 403 404 405 406 407 408 409 410 411 412
/^Memory checking results:/ {
    look=1;
    FS=" - ";
}
/Errors while running CTest/ {
    look=0;
    FS=" ";
}
{
    if (look) {
        errs+=$2;
    }
}
413
END {
414
    print "ERRORS=" errs;
415 416 417 418 419
    if (fail>0) {
        print "FAIL=" fail
    }
    print "PASS=" pass
}' >"$cf"
420 421 422
    get_latest_svn_revision $FULLTOKUDBDIR >>"$cf"
    echo -n " " >>"$cf"
    cat "$resultsdir/trace" | awk '
423 424 425 426 427 428 429
BEGIN {
    FS=": ";
}
/Build name/ {
    print $2;
    exit
}' >>"$cf"
430 431
    (echo; echo) >>"$cf"
    cat "$resultsdir/trace" | awk '
432 433 434 435
BEGIN {
    printit=0
}
/[0-9]*\% tests passed, [0-9]* tests failed out of [0-9]*/ { printit=1 }
436
/Memory check project/ { printit=0 }
437 438 439 440 441 442
/^   Site:/ { printit=0 }
{
    if (printit) {
        print $0
    }
}' >>"$cf"
443 444 445 446
    svn add $resultsdir
    svn commit -F "$cf" $resultsdir
    rm $cf
fi
447 448

exit 0