summaryrefslogtreecommitdiffstats
path: root/lowercasing_test/src/tests/create-test.sh
blob: feca94c7de2e66cdec458390ad213995fc37bc1c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/bin/sh
# Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

gen_ignore_file() {
    echo "generating '$1' ..."
    echo ".depend"       > $1
    echo "Makefile"     >> $1
    echo "${test}_test" >> $1
}

gen_project_file() {
    echo "generating '$1' ..."
    echo "APPLICATION ${test}_test"               > $1
    echo "OBJS $test"                            >> $1
    echo "EXTERNALLIBS searchlib"                >> $1
    echo "EXTERNALLIBS vespalib"                 >> $1
    echo "EXTERNALLIBS vespalog"                 >> $1
    echo ""                                      >> $1
    echo "CUSTOMMAKE"                            >> $1
    echo "test: depend ${test}_test"             >> $1
    echo -e "\t@./${test}_test"                  >> $1
}

gen_source() {
    echo "generating '$1' ..."
    echo "#include <vespa/log/log.h>"                   > $1
    echo "LOG_SETUP(\"${test}_test\");"          >> $1
    echo "#include <vespa/fastos/fastos.h>"            >> $1
    echo "#include <vespa/vespalib/testkit/testapp.h>" >> $1
    echo ""                                      >> $1
    echo ""                                      >> $1
    echo "TEST_SETUP(Test);"                     >> $1
    echo ""                                      >> $1
    echo "int"                                   >> $1
    echo "Test::Main()"                          >> $1
    echo "{"                                     >> $1
    echo "    TEST_INIT(\"${test}_test\");"      >> $1
    echo "    TEST_DONE();"                      >> $1
    echo "}"                                     >> $1
}

gen_desc() {
    echo "generating '$1' ..."
    echo "$test test. Take a look at $test.cpp for details." > $1
}

gen_file_list() {
    echo "generating '$1' ..."
    echo "$test.cpp" > $1
}

if [ $# -ne 1 ]; then
	echo "usage: $0 <name>"
	echo "  name: name of the test to create"
	exit 1
fi

test=$1
if [ -e $test ]; then
    echo "$test already present, don't want to mess it up..."
    exit 1
fi

echo "creating directory '$test' ..."
mkdir -p $test || exit 1
cd $test || exit 1
test=`basename $test`

gen_ignore_file  .cvsignore
gen_project_file fastos.project
gen_source       $test.cpp
gen_desc         DESC
gen_file_list    FILES