Codebase list cppad / upstream/2015.00.00.4 example / test_one.sh.in
upstream/2015.00.00.4

Tree @upstream/2015.00.00.4 (Download .tar.gz)

test_one.sh.in @upstream/2015.00.00.4raw · history · blame

#! /bin/bash -e
# $Id: test_one.sh.in 3322 2014-09-12 10:29:34Z bradbell $
# -----------------------------------------------------------------------------
# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell
#
# CppAD is distributed under multiple licenses. This distribution is under
# the terms of the 
#                     GNU General Public License Version 3.
#
# A copy of this license is included in the COPYING file of this distribution.
# Please visit http://www.coin-or.org/CppAD/ for information on other licenses.
# -----------------------------------------------------------------------------
# Run one of the tests
if [ "$1" = "" ]
then
	echo "usage: test_one.sh file [extra]"
	echo "file is the *.cpp file name with extension"
	echo "and extra is extra options for g++ command"
	exit 1
fi
if [ ! -e "$1" ]
then
	echo "Cannot find the file $1"
	exit 1
fi
# determine the function name
fun=`grep "^bool *[a-zA-Z0-9_]*( *void *)" $1 | tail -1 | \
	sed -e "s/^bool *\([a-zA-Z0-9_]*\) *( *void *)/\1/"`
#
if [ -e test_one.exe ]
then
	rm test_one.exe
fi
if [ -e test_one.cpp ]
then
	rm test_one.cpp
fi
sed < example.cpp > test_one.cpp \
-e '/ok *\&= *Run( /d' \
-e "s/.*This line is used by test_one.sh.*/	ok \&= Run( $fun, \"$fun\");/"  
#
if echo "$fun" | grep 'eigen' > /dev/null
then
	cxxflags='-g -Wall -ansi -pedantic-errors'
else
	cxxflags='-g -Wall -ansi -pedantic-errors -Wshadow'
fi
cmd="g++ test_one.cpp $*
	-o test_one.exe
	$cxxflags
	-g
	-fopenmp
	-lboost_thread
	-lpthread
	-std=c++11 -DCPPAD_ADOLC_EXAMPLES -DCPPAD_EIGEN_EXAMPLES
	-I.. 
"
if [ -e @adolc_prefix@/include ]
then
	cmd="$cmd -I@adolc_prefix@/include"
fi
if [ -e @colpack_prefix@/include ]
then
	cmd="$cmd -I@colpack_prefix@/include"
fi
if [ -e @eigen_prefix@/include ]
then
	cmd="$cmd -I@eigen_prefix@/include"
fi
for lib in lib lib64
do
	if [ -e @adolc_prefix@/$lib ]
	then
		cmd="$cmd -L@adolc_prefix@/$lib -ladolc -lColPack"
		export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:@adolc_prefix@/$lib"
	fi
	if [ -e @colpack_prefix@/$lib ]
	then
		cmd="$cmd -L@colpack_prefix@/$lib -lColPack"
		export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:@colpack_prefix@/$lib"
	fi
done
echo $cmd
$cmd
#
echo "./test_one.exe"
if ! ./test_one.exe
then
	exit 1
fi
exit 0