summaryrefslogtreecommitdiff
path: root/tests/test.sh
blob: f055b43b32249ee8e023dd5c065eba9c03ea1193 (plain)
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!/bin/bash
#
# It is intended to run the command "make test" from the root directory of the library
#


THIS=`basename $0`
    
function print_help() {
    echo "Use: $THIS [options...]"
    echo "Options:"
    echo "  -p <php>     Specify PHP executable to run (default: /usr/bin/php)."
    echo "  -e <file>    Name of test extension (default: extfortest.so)."
    echo "  -n           Do not compile the test extension."
    echo "  -w <file>    Write a list of all failed tests to <file>."
    echo "  -a <file>    Same as -w but append rather then truncating <file>."
    echo "  -d foo=bar   Pass -d option to the php binary (Define INI entry foo"
    echo "               with value 'bar')."
    echo "  -g <opt>     Comma separated list of groups to show during test run"
    echo "               (possible values: PASS, FAIL, XFAIL, SKIP, BORK, WARN, LEAK, REDIRECT)."
    echo "  -m           Test for memory leaks with Valgrind."
    echo "  -s <file>    Write output to <file>."
    echo "  -x           Sets 'SKIP_SLOW_TESTS' environmental variable."
    echo "  -o           Cancels sets 'SKIP_ONLINE_TESTS' (default set)."
    echo "  -v           Verbose mode."
    echo "  -h           This Help."
    echo
    exit;
}

PHP_BIN="/usr/bin/php"
SCR_OPT=""
COMPILE_EXT=1
OFFLINE=1
EXT_NAME="extfortest.so"

while getopts ":p:e:nw:a:d:g:ms:xovh" opt ;
do
    case $opt in
        p)
            PHP_BIN=$OPTARG;
            ;;
        e)
            EXT_NAME=$OPTARG;
            ;;
        n)
            COMPILE_EXT=0
            ;;
        w)
            SCR_OPT="$SCR_OPT -w $OPTARG"
            ;;
        a)
            SCR_OPT="$SCR_OPT -a $OPTARG"
            ;;
        d)
            SCR_OPT="$SCR_OPT -d $OPTARG"
            ;;
        g)
            SCR_OPT="$SCR_OPT -g $OPTARG"
            ;;
        s)
            SCR_OPT="$SCR_OPT -s $OPTARG"
            ;;
        m)
            SCR_OPT="$SCR_OPT -m"
            ;;
        x)
            SCR_OPT="$SCR_OPT -x"
            ;;
        o)
            OFFLINE=0
            ;;
        v)
            SCR_OPT="$SCR_OPT -v"
            ;;
        h)
            print_help
            ;;
        *)
            echo "wrong option -$OPTARG";
            echo "";
            print_help
            ;;
    esac
done

# default offline mode
if [ 1 = $OFFLINE ]; then
    SCR_OPT="$SCR_OPT --offline"
fi

TEST_FILES=`find ./php/phpt -type f -name "*.phpt"`

#RUN_SCR="$PHP_BIN -z ./cpp/$EXT_NAME"
RUN_SCR="$PHP_BIN -d enable_dl=On -d extension_dir=./ext_dir -d extension=$EXT_NAME"


# Create a local copy of the directory with the extension for run without installation
./prepare.sh $EXT_NAME


if [ 1 = $COMPILE_EXT ]; then
    echo "Compile the test extension"
    cd cpp
    make clean && make
    cd ..
fi


# run tests
$PHP_BIN run-tests.php $SCR_OPT -p "$RUN_SCR" $TEST_FILES