run-tests 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #!/bin/sh
  2. set -e
  3. DIR=$(readlink -f $(dirname $0))
  4. echo "Compiling the tests …"
  5. (cd $DIR && make)
  6. echo "Running all testcases …"
  7. LDPATH="$DIR/../../build/bin"
  8. EXT="_libapt_test"
  9. # detect if output is on a terminal (colorful) or better not
  10. if expr match "$(readlink -f /proc/$$/fd/1)" '/dev/pts/[0-9]\+' > /dev/null; then
  11. COLHIGH='\033[1;35m'
  12. COLRESET='\033[0m'
  13. TESTOKAY='\033[1;32mOKAY\033[0m'
  14. TESTFAIL='\033[1;31mFAILED\033[0m'
  15. else
  16. COLHIGH=''
  17. COLRESET=''
  18. TESTOKAY='OK'
  19. TESTFAIL='###FAILED###'
  20. fi
  21. for testapp in $(ls ${LDPATH}/*$EXT)
  22. do
  23. name=$(basename ${testapp})
  24. NAME="${COLHIGH}${name}${COLRESET}"
  25. tmppath=""
  26. if [ $name = "GetListOfFilesInDir${EXT}" ]; then
  27. # TODO: very-low: move env creation to the actual test-app
  28. tmppath=$(mktemp -d)
  29. touch "${tmppath}/anormalfile" \
  30. "${tmppath}/01yet-anothernormalfile" \
  31. "${tmppath}/anormalapt.conf" \
  32. "${tmppath}/01yet-anotherapt.conf" \
  33. "${tmppath}/anormalapt.list" \
  34. "${tmppath}/01yet-anotherapt.list" \
  35. "${tmppath}/wrongextension.wron" \
  36. "${tmppath}/wrong-extension.wron" \
  37. "${tmppath}/strangefile." \
  38. "${tmppath}/s.t.r.a.n.g.e.f.i.l.e" \
  39. "${tmppath}/.hiddenfile" \
  40. "${tmppath}/.hiddenfile.conf" \
  41. "${tmppath}/.hiddenfile.list" \
  42. "${tmppath}/multi..dot" \
  43. "${tmppath}/multi.dot.conf" \
  44. "${tmppath}/multi.dot.list" \
  45. "${tmppath}/disabledfile.disabled" \
  46. "${tmppath}/disabledfile.conf.disabled" \
  47. "${tmppath}/disabledfile.list.disabled" \
  48. "${tmppath}/invälid.conf" \
  49. "${tmppath}/invalíd" \
  50. "${tmppath}/01invalíd"
  51. mkdir "${tmppath}/invaliddir" \
  52. "${tmppath}/directory.conf" \
  53. "${tmppath}/directory.list" \
  54. "${tmppath}/directory.wron" \
  55. "${tmppath}/directory.list.disabled"
  56. ln -s "${tmppath}/anormalfile" "${tmppath}/linkedfile.list"
  57. ln -s "${tmppath}/non-existing-file" "${tmppath}/brokenlink.list"
  58. elif [ $name = "getLanguages${EXT}" ]; then
  59. tmppath=$(mktemp -d)
  60. touch "${tmppath}/ftp.de.debian.org_debian_dists_sid_main_i18n_Translation-tr" \
  61. "${tmppath}/ftp.de.debian.org_debian_dists_sid_main_i18n_Translation-pt" \
  62. "${tmppath}/ftp.de.debian.org_debian_dists_sid_main_i18n_Translation-se~" \
  63. "${tmppath}/ftp.de.debian.org_debian_dists_sid_main_i18n_Translation-st.bak"
  64. elif [ $name = "HashSums${EXT}" ]; then
  65. TMP="$(mktemp)"
  66. dmesg > $TMP
  67. echo -n "Testing with \033[1;35m${name}\033[0m ... "
  68. LD_LIBRARY_PATH=${LDPATH} ${testapp} $TMP $(md5sum $TMP | cut -d' ' -f 1) $(sha1sum $TMP | cut -d' ' -f 1) $(sha256sum $TMP | cut -d' ' -f 1) $(sha512sum $TMP | cut -d' ' -f 1) && echo "\033[1;32mOKAY\033[0m" || echo "\033[1;31mFAILED\033[0m"
  69. rm $TMP
  70. continue
  71. elif [ $name = "CompareVersion${EXT}" ]; then
  72. tmppath="${DIR}/versions.lst"
  73. fi
  74. echo -n "Testing with ${NAME} "
  75. LD_LIBRARY_PATH=${LDPATH} ${testapp} ${tmppath} && echo "$TESTOKAY" || echo "$TESTFAIL"
  76. if [ -n "$tmppath" -a -d "$tmppath" ]; then
  77. rm -rf "$tmppath"
  78. fi
  79. done