s3-tests use $PREFIX to ensure tests don't work outside the test area
[nivanova/samba-autobuild/.git] / source3 / selftest / s3-selftest.sh
1 #!/bin/sh
2
3 FILTER_XFAIL="${PYTHON} -u ${SELFTESTDIR}/filter-subunit --expected-failures=${SOURCEDIR}/selftest/knownfail"
4 if [ "x${SUBUNIT_FORMATTER}" = x"" ]; then
5         SUBUNIT_FORMATTER="${PYTHON} -u ${SELFTESTDIR}/format-subunit --prefix=${SELFTESTPREFIX} --immediate"
6 fi
7
8 cleanup_and_exit() {
9         if test "$1" = 0 -o -z "$1"; then
10                 exit 0
11         else
12                 exit $1
13         fi
14 }
15
16 st_test_done() {
17         test -f ${SELFTESTPREFIX}/st_done || { echo "SELFTEST FAILED"; cleanup_and_exit 1; }
18 }
19
20 if [ "x${RUN_FROM_BUILD_FARM}" = "xyes" ]; then
21         ( rm -f ${SELFTESTPREFIX}/st_done && \
22                 ${PERL} ${SELFTESTDIR}/selftest.pl \
23                         --prefix=${SELFTESTPREFIX} --target=samba3 \
24                         --testlist="${SOURCEDIR}/selftest/tests.sh|" \
25                         --exclude=${SOURCEDIR}/selftest/skip \
26                         --socket-wrapper ${TESTS} \
27         && touch ${SELFTESTPREFIX}/st_done ) | \
28                 ${FILTER_XFAIL} --strip-passed-output
29         EXIT_STATUS=$?
30
31         st_test_done
32 else
33         ( rm -f ${SELFTESTPREFIX}/st_done && \
34                 ${PERL} ${SELFTESTDIR}/selftest.pl \
35                         --prefix=${SELFTESTPREFIX} --target=samba3 \
36                         --testlist="${SOURCEDIR}/selftest/tests.sh|" \
37                         --exclude=${SOURCEDIR}/selftest/skip \
38                         --socket-wrapper ${TESTS} \
39         && touch ${SELFTESTPREFIX}/st_done ) | \
40                 ${FILTER_XFAIL} | ${SUBUNIT_FORMATTER}
41         EXIT_STATUS=$?
42
43         st_test_done
44 fi
45
46 cleanup_and_exit ${EXIT_STATUS}