Statistics
| Branch: | Tag: | Revision:

one / share / test / do_tests.sh @ ae53d437

History | View | Annotate | Download (3.46 KB)

1
#!/bin/bash
2
#-------------------------------------------------------------------------------
3
# DEFINE THE TESTS
4
#-------------------------------------------------------------------------------
5
TWD_DIR="../../src"
6
BASE_DIR=$PWD
7

    
8
TESTS="$TWD_DIR/vnm/test \
9
       $TWD_DIR/xml/test \
10
       $TWD_DIR/scheduler/src/pool/test \
11
       $TWD_DIR/common/test \
12
       $TWD_DIR/host/test \
13
       $TWD_DIR/cluster/test \
14
       $TWD_DIR/template/test \
15
       $TWD_DIR/image/test \
16
       $TWD_DIR/authm/test \
17
       $TWD_DIR/vm/test \
18
       $TWD_DIR/um/test \
19
       $TWD_DIR/lcm/test \
20
       $TWD_DIR/pool/test \
21
       $TWD_DIR/vm_template/test \
22
       $TWD_DIR/group/test"
23

    
24
#-------------------------------------------------------------------------------
25
# COMMAND LINE PARSING
26
#-------------------------------------------------------------------------------
27
usage() {
28
 echo
29
 echo "Usage: do_test.sh [-smvgxclh]"
30
 echo
31
 echo "-m: use MyQSL backend (defaults to Sqlite)"
32
 echo "-v: run tests using valgrind (memcheck) output will be memgrind.out"
33
 echo "-g: run tests using valgrind (callgrind) output will be callgrind.out"
34
 echo "-l: keep logs"
35
 echo "-x: create xml output files, for Hudson"
36
 echo "-c: clear output files from previous executions"
37
 echo
38
 echo "-h: prints this help"
39
}
40
#-------------------------------------------------------------------------------
41

    
42
TEMP_OPT=`getopt -o mvgclbhx -n 'install.sh' -- "$@"`
43

    
44
if [ $? != 0 ] ; then
45
    usage
46
    exit 1
47
fi
48

    
49
eval set -- "$TEMP_OPT"
50

    
51
MYSQL="no"
52
VAL_MEM="no"
53
VAL_CALL="no"
54
LOGS="no"
55
XMLS="no"
56
CLEAR="no"
57

    
58

    
59
while true ; do
60
    case "$1" in
61
        -h) usage; exit 0;;
62
        -m) MYSQL="yes"   ; shift ;;
63
        -v) VAL_MEM="yes" ; shift ;;
64
        -g) VAL_CALL="yes"; shift ;;
65
        -l) LOGS="yes"    ; shift ;;
66
        -x) XMLS="yes"    ; shift ;;
67
        -c) CLEAR="yes"   ; shift ;;
68
        --) shift ; break ;;
69
        *)  usage; exit 1 ;;
70
    esac
71
done
72

    
73

    
74
#-------------------------------------------------------------------------------
75
# SETUP ARGUMENTS
76
#-------------------------------------------------------------------------------
77

    
78
if [ "$MYSQL" = "yes" ] ; then
79
    TEST_ARGS="-m"
80
else
81
    TEST_ARGS="-s"
82
fi
83

    
84
if [ "$LOGS" = "yes" ] ; then
85
    TEST_ARGS="$TEST_ARGS -l"
86
fi
87

    
88
if [ "$XMLS" = "yes" ] ; then
89
    TEST_ARGS="$TEST_ARGS -x"
90
fi
91

    
92
CALLER=""
93

    
94
if [ "$VAL_MEM" = "yes" ] ; then
95
    CALLER="valgrind --show-reachable=yes --leak-check=full"
96
elif [ "$VAL_CALL" = "yes" ] ; then
97
    CALLER="valgrind --tool=callgrind"
98
fi
99

    
100

    
101
for i in $TESTS ; do
102
    cd $BASE_DIR
103

    
104
    echo ; echo
105
    echo "#####################################################################"
106
    echo "#####################################################################"
107
    echo "Doing $i ..."
108
    echo "#####################################################################"
109
    echo "#####################################################################"
110
    echo ; echo
111
    cd $i
112

    
113
    if [ "$CLEAR" = "yes" ] ; then
114
        rm -f callgrind.out* test.db* *.log* memgrid.out* *.xml ONE_test_database*
115
    else
116
        for j in `ls test*` ; do
117
            if [ -x $j ] ; then
118
                echo ; echo "---------------------------------------------------------------------"
119
                echo "Test Program: $j"
120
                echo "---------------------------------------------------------------------"
121
                $CALLER ./$j $TEST_ARGS
122
                echo "---------------------------------------------------------------------"
123
            fi
124
        done
125
    fi
126
done
127

    
128
cd $BASE_DIR
129

    
130
exit 0