1 #!/bin/sh 2 3 TESTS_DIR="./tests" 4 CONFIG_DIR=${TESTS_DIR}"/config" 5 CHANGES_DIR="/tmp/.uci" 6 TMP_DIR=${TESTS_DIR}"/tmp" 7 FULL_SUITE=${TESTS_DIR}"/full_suite.sh" 8 9 UCI_BIN=${UCI_BIN:-"../uci"} 10 [ -x "$UCI_BIN" ] || { 11 echo "uci is not present." >&2 12 return 1 13 } 14 VALGRIND="valgrind --quiet --show-leak-kinds=all --leak-check=full --track-origins=yes" 15 UCI_BIN="${VALGRIND} ${UCI_BIN}" 16 UCI="${UCI_BIN} -c ${CONFIG_DIR} -p ${CHANGES_DIR}" 17 UCI_Q="${UCI_BIN} -c ${CONFIG_DIR} -p ${CHANGES_DIR} -q" 18 19 REF_DIR="./references" 20 SCRIPTS_DIR="./tests.d" 21 DO_TEST="./shunit2/shunit2" 22 23 rm -rf ${TESTS_DIR} 24 mkdir -p ${TESTS_DIR} 25 26 cat << 'EOF' > ${FULL_SUITE} 27 setUp() { 28 mkdir -p ${CONFIG_DIR} ${CHANGES_DIR} ${TMP_DIR} 29 } 30 tearDown() { 31 rm -rf ${CONFIG_DIR} ${CHANGES_DIR} ${TMP_DIR} 32 } 33 assertSameFile() { 34 local ref=$1 35 local test=$2 36 diff -qr $ref $test 37 assertTrue $? || { 38 echo "REF:" 39 cat $ref 40 echo "----" 41 echo "TEST:" 42 cat $test 43 echo "----" 44 } 45 } 46 assertNotSegFault() 47 { 48 [ $1 -eq 139 ] && fail "Returned with 139: segmentation fault (SIGSEGV)!!!" 49 } 50 assertNotIllegal() 51 { 52 [ $1 -eq 132 ] && fail "Returned with 132: Illegal instruction (SIGILL)!!!" 53 } 54 assertFailWithNoReturn() { 55 local test="$1" 56 value=$( $test ) 57 rv=$? 58 assertFalse "'$test' does not fail" $rv 59 assertNotSegFault $rv 60 assertNotIllegal $rv 61 assertNull "'$test' returns '$value'" "$value" 62 } 63 EOF 64 65 for suite in "${SCRIPTS_DIR}"/* 66 do 67 cat "${suite}" >> ${FULL_SUITE} 68 done 69 70 echo ". ${DO_TEST}" >> ${FULL_SUITE} 71 72 REF_DIR="${REF_DIR}" \ 73 CONFIG_DIR="${CONFIG_DIR}" \ 74 CHANGES_DIR="${CHANGES_DIR}" \ 75 TMP_DIR="${TMP_DIR}" \ 76 UCI="${UCI}" \ 77 UCI_Q="${UCI_Q}" \ 78 /bin/sh ${FULL_SUITE} 79 80 rm -rf ${TESTS_DIR}
This page was automatically generated by LXR 0.3.1. • OpenWrt