📄 testone
字号:
#!/bin/sh -# $Id: testone,v 1.5 2002/07/05 22:17:59 dda Exp $## Run just one C++ regression test, the single argument# is the basename of the test, e.g. TestRpcServererror(){ echo '' >&2 echo "C++ regression error: $@" >&2 echo '' >&2 ecode=1}# compares the result against the good version,# reports differences, and removes the result file# if there are no differences.#compare_result(){ good="$1" latest="$2" if [ ! -e "$good" ]; then echo "Note: $good does not exist" return fi tmpout=/tmp/blddb$$.tmp diff "$good" "$latest" > $tmpout if [ -s $tmpout ]; then nbad=`grep '^[0-9]' $tmpout | wc -l` error "$good and $latest differ in $nbad places." else rm $latest fi rm -f $tmpout}ecode=0stdinflag=ngdbflag=nCXX=${CXX:-c++}LIBS=${LIBS:-}# remove any -c option in the CXXFLAGSCXXFLAGS="`echo " ${CXXFLAGS} " | sed -e 's/ -c //g'`"# determine the prefix of the install treeprefix=""while :do case "$1" in --prefix=* ) prefix="`echo $1 | sed -e 's/--prefix=//'`"; shift LIBS="-L$prefix/lib -ldb_cxx $LIBS" CXXFLAGS="-I$prefix/include $CXXFLAGS" export LD_LIBRARY_PATH="$prefix/lib:$LD_LIBRARY_PATH" ;; --stdin ) stdinflag=y; shift ;; --gdb ) CXXFLAGS="-g $CXXFLAGS" gdbflag=y; shift ;; * ) break ;; esacdoneif [ "$#" = 0 ]; then echo 'Usage: testone [ --prefix=<dir> | --stdin ] TestName' exit 1finame="$1"# compilerm -rf TESTDIR; mkdir TESTDIRcd ./TESTDIR${CXX} ${CXXFLAGS} -o $name ../$name.cpp ${LIBS} > ../$name.compileout 2>&1if [ $? != 0 -o -s ../$name.compileout ]; then error "compilation of $name failed, see $name.compileout" exit 1firm -f ../$name.compileout# find input and error fileinfile=../$name.testinif [ ! -f $infile ]; then infile=/dev/nullfi# run and diff resultsrm -rf TESTDIRif [ "$gdbflag" = y ]; then if [ -s $infile ]; then echo "Input file is $infile" fi gdb ./$name exit 0elif [ "$stdinflag" = y ]; then ./$name >../$name.out 2>../$name.errelse ./$name <$infile >../$name.out 2>../$name.errficd ..testerr=$name.testerrif [ ! -f $testerr ]; then testerr=/dev/nullfitestout=$name.testoutif [ ! -f $testout ]; then testout=/dev/nullficompare_result $testout $name.outcompare_result $testerr $name.errrm -rf TESTDIRexit $ecode
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -