summaryrefslogtreecommitdiff
path: root/run-xcachetest
blob: e5eaaa0c4d15dd1d503017d217c7cef4ad18921b (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
#!/bin/sh

getAbsolutePath() {
	which readlink >/dev/null 2>&1 && readlink -f "$@" || echo "$@"
}

# use symlink first
if test -x ./php-cli ; then
	php_cli=`getAbsolutePath ./php-cli`
elif test ! -z "$TEST_PHP_EXECUTABLE" && test -x "$TEST_PHP_EXECUTABLE"; then
	php_cli="$TEST_PHP_EXECUTABLE"
else
	php_cli="`which php`"
fi

test_args="-c \"$TEST_INI\""' -d "open_basedir=" -d "safe_mode=0" -d "output_buffering=0" -d "memory_limit=-1"'

if test -x ./php-cgi ; then
	php_cgi=`getAbsolutePath ./php-cgi`
else
	php_cgi="`which php-cgi`"
fi

echo '#!/bin/sh' > ./php-cli-test
echo 'exec "'$php_cli'" '$test_args' "$@"' >> php-cli-test
chmod +x ./php-cli-test

echo '#!/bin/sh' > ./php-cgi-test
echo 'exec "'$php_cgi'" '$test_args' "$@"' >> php-cgi-test
chmod +x ./php-cgi-test

TEST_PHP_EXECUTABLE=`getAbsolutePath ./php-cli-test`
TEST_PHP_CGI_EXECUTABLE=`getAbsolutePath ./php-cgi-test`
real_php_src=`getAbsolutePath ./php-src`;
test -z "$TEST_PHP_SRCDIR" && TEST_PHP_SRCDIR=$real_php_src

export TEST_PHP_EXECUTABLE
export TEST_PHP_CGI_EXECUTABLE
export TEST_PHP_SRCDIR

echo "XCache test running with:"
echo "TEST_PHP_CGI_EXECUTABLE: $TEST_PHP_CGI_EXECUTABLE"
echo "TEST_PHP_EXECUTABLE:     $TEST_PHP_EXECUTABLE"
echo "TEST_PHP_SRCDIR:         $TEST_PHP_SRCDIR"

patch_run_tests_ext() {
	if test -z "$TEST_EXT" ; then
		sed "s#'ext',##g"
	else
		cat
	fi
}
patch_run_tests_report_leaks() {
	if test -z "$TEST_REPORT_MEMLEAKS" ; then
		sed "s#'report_memleaks=1',#'report_memleaks=0',#g"
	else
		cat
	fi
}
run_tests_src=$real_php_src/run-tests.php
patch_run_tests_ext < "$run_tests_src" | sed "s#^\\\$test_dirs = array('.*#\\\$test_dirs = array();#" | patch_run_tests_report_leaks > run-tests.php
exec "$TEST_PHP_EXECUTABLE" `getAbsolutePath ./run-tests.php` "$@"