source: trunk/speed/add_test.sh @ 2504

Last change on this file since 2504 was 2504, checked in by bradbell, 7 years ago

add missing copyright message

  • Property svn:executable set to *
  • Property svn:keywords set to Id
File size: 2.2 KB
Line 
1#! /bin/bash -e
2# $Id: add_test.sh 2504 2012-10-24 16:42:34Z bradbell $
3# -----------------------------------------------------------------------------
4# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell
5#
6# CppAD is distributed under multiple licenses. This distribution is under
7# the terms of the
8#                     Common Public License Version 1.0.
9#
10# A copy of this license is included in the COPYING file of this distribution.
11# Please visit http://www.coin-or.org/CppAD/ for information on other licenses.
12# -----------------------------------------------------------------------------
13# Use this shell script when a new test is added to initially create
14# the source code files */test_name.cpp which return false (for not available).
15#
16echo "Change this script so that it automates the omhelp commands"
17echo "at the beginning of the created files."
18echo exit 1
19#
20if [ "$1" == "" ]
21then
22        echo "usage: new_test.sh test_name"
23        echo "where test_name is the name of the new test being added"
24        exit 1
25fi
26test_name="$1"
27if [ ! -e "link_$test_name.cpp" ]
28then
29        echo "The file ./link_$test_name.cpp does not yet exist."
30        echo "It must first be created before executing this script."
31        exit 1
32fi
33if ! grep "speed\/link_$test_name.cpp" main.cpp
34then
35        echo "link_$test_name.cpp has not yet been added to main.cpp"
36        exit 1
37fi
38list="
39        adolc
40        cppad
41        double
42        fadbad
43        sacado
44"
45for dir in profile $list
46do
47        if grep "link_$test_name.cpp" $dir/makefile.am
48        then
49                echo "$test_name.cpp is already in $dir/makefile.am"
50                exit 1
51        fi
52        if [ -e $dir/$test_name.cpp ]
53        then
54                echo "The file $dir/$test_name.cpp already exists."
55                exit 1
56        fi
57done
58#
59sed -i main.cpp -e "s/speed\/link[^%]*\$/&%\n\tspeed\/link_$test_name.cpp/"
60#
61copy=`sed -n ../COPYING -e '/^\/\*/,/\*\/$/p'`
62link=`sed -n link_$test_name.cpp -e "/^ *extern *bool *link_$test_name/,/^);/p"`
63fun=`echo "$link" | sed -e 's/extern */\n/' -e 's/^);/)\n{\n\treturn false;\n}/'`
64for dir in $list
65do
66        echo "$copy$fun" > $dir/$test_name.cpp
67        sed -i $dir/makefile.am \
68                -e "s/\/main.cpp.*/&\n\t..\/link_$test_name.cpp \\\\/" \
69                -e "s/\/link_$test_name.cpp.*/&\n\t$test_name.cpp \\\\/"
70done
71sed -i profile/makefile.am \
72        -e "s/\/main.cpp.*/&\n\t..\/link_$test_name.cpp \\\\/" \
73        -e "s/\/link_$test_name.cpp.*/&\n\t..\/cppad\/$test_name.cpp \\\\/"
Note: See TracBrowser for help on using the repository browser.