1#!/bin/sh 2 3BACKENDS="EVPORT KQUEUE EPOLL DEVPOLL POLL SELECT WIN32" 4TESTS="test-eof test-closed test-weof test-time test-changelist test-fdleak" 5FAILED=no 6TEST_OUTPUT_FILE=${TEST_OUTPUT_FILE:-/dev/null} 7REGRESS_ARGS=${REGRESS_ARGS:-} 8 9# /bin/echo is a little more likely to support -n than sh's builtin echo, 10# printf is even more likely 11if test "`printf %s hello 2>&1`" = "hello" 12then 13 ECHO_N="printf %s" 14else 15 if test -x /bin/echo 16 then 17 ECHO_N="/bin/echo -n" 18 else 19 ECHO_N="echo -n" 20 fi 21fi 22 23if test "$TEST_OUTPUT_FILE" != "/dev/null" 24then 25 touch "$TEST_OUTPUT_FILE" || exit 1 26fi 27 28TEST_DIR=. 29TEST_SRC_DIR=. 30 31T=`echo "$0" | sed -e 's/test.sh$//' | sed -e 's/test-script.sh//' ` 32if test -x "$T/test-init" 33then 34 TEST_DIR="$T" 35elif test -x "./test/test-init" 36then 37 TEST_DIR="./test" 38fi 39if test -f "$T/check-dumpevents.py" 40then 41 TEST_SRC_DIR="$T" 42elif test -f "./test/check-dumpevents.py" 43then 44 TEST_SRC_DIR="./test" 45fi 46 47setup () { 48 for i in $BACKENDS; do 49 eval "EVENT_NO$i=yes; export EVENT_NO$i" 50 done 51 unset EVENT_EPOLL_USE_CHANGELIST 52 unset EVENT_PRECISE_TIMER 53} 54 55announce () { 56 echo "$@" 57 echo "$@" >>"$TEST_OUTPUT_FILE" 58} 59 60announce_n () { 61 $ECHO_N "$@" 62 echo "$@" >>"$TEST_OUTPUT_FILE" 63} 64 65 66run_tests () { 67 if $TEST_DIR/test-init 2>>"$TEST_OUTPUT_FILE" ; 68 then 69 true 70 else 71 announce Skipping test 72 return 73 fi 74 for i in $TESTS; do 75 announce_n " $i: " 76 if $TEST_DIR/$i >>"$TEST_OUTPUT_FILE" ; 77 then 78 announce OKAY ; 79 else 80 announce FAILED ; 81 FAILED=yes 82 fi 83 done 84 announce_n " test-dumpevents: " 85 if python2 -c 'import sys; assert(sys.version_info >= (2, 4))' 2>/dev/null && test -f $TEST_SRC_DIR/check-dumpevents.py; then 86 if $TEST_DIR/test-dumpevents | python2 $TEST_SRC_DIR/check-dumpevents.py >> "$TEST_OUTPUT_FILE" ; 87 then 88 announce OKAY ; 89 else 90 announce FAILED ; 91 fi 92 else 93 # no python 94 if $TEST_DIR/test-dumpevents >/dev/null; then 95 announce "OKAY (output not checked)" ; 96 else 97 announce "FAILED (output not checked)" ; 98 fi 99 fi 100 test -x $TEST_DIR/regress || return 101 announce_n " regress: " 102 if test "$TEST_OUTPUT_FILE" = "/dev/null" ; 103 then 104 $TEST_DIR/regress --quiet $REGRESS_ARGS 105 else 106 $TEST_DIR/regress $REGRESS_ARGS >>"$TEST_OUTPUT_FILE" 107 fi 108 if test "$?" = "0" ; 109 then 110 announce OKAY ; 111 else 112 announce FAILED ; 113 FAILED=yes 114 fi 115} 116 117do_test() { 118 setup 119 announce "$1 $2" 120 unset EVENT_NO$1 121 if test "$2" = "(changelist)" ; then 122 EVENT_EPOLL_USE_CHANGELIST=yes; export EVENT_EPOLL_USE_CHANGELIST 123 elif test "$2" = "(timerfd)" ; then 124 EVENT_PRECISE_TIMER=1; export EVENT_PRECISE_TIMER 125 elif test "$2" = "(timerfd+changelist)" ; then 126 EVENT_EPOLL_USE_CHANGELIST=yes; export EVENT_EPOLL_USE_CHANGELIST 127 EVENT_PRECISE_TIMER=1; export EVENT_PRECISE_TIMER 128 fi 129 130 run_tests 131} 132 133announce "Running tests:" 134 135do_test EPOLL "(timerfd)" 136do_test EPOLL "(changelist)" 137do_test EPOLL "(timerfd+changelist)" 138for i in $BACKENDS; do 139 do_test $i 140done 141 142if test "$FAILED" = "yes"; then 143 exit 1 144fi 145