source: trunk/speed/add_test.sh @ 1370

Last change on this file since 1370 was 1370, checked in by bradbell, 10 years ago

trunk: Fix svn_add_id.sh and use it set Id property for some missed files.

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