run-tests 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #!/bin/sh
  2. set -e
  3. DIR=$(readlink -f $(dirname $0))
  4. echo "Compiling the tests …"
  5. test -d "$DIR/../../build/obj/test/libapt/" || mkdir -p "$DIR/../../build/obj/test/libapt/"
  6. (cd $DIR && make)
  7. echo "Running all testcases …"
  8. LDPATH="$DIR/../../build/bin"
  9. EXT="_libapt_test"
  10. for testapp in $(ls ${LDPATH}/*$EXT)
  11. do
  12. name=$(basename ${testapp})
  13. tmppath=""
  14. if [ $name = "GetListOfFilesInDir${EXT}" ]; then
  15. # TODO: very-low: move env creation to the actual test-app
  16. echo "Prepare Testarea for \033[1;35m$name\033[0m ..."
  17. tmppath=$(mktemp -d)
  18. touch "${tmppath}/anormalfile" \
  19. "${tmppath}/01yet-anothernormalfile" \
  20. "${tmppath}/anormalapt.conf" \
  21. "${tmppath}/01yet-anotherapt.conf" \
  22. "${tmppath}/anormalapt.list" \
  23. "${tmppath}/01yet-anotherapt.list" \
  24. "${tmppath}/wrongextension.wron" \
  25. "${tmppath}/wrong-extension.wron" \
  26. "${tmppath}/strangefile." \
  27. "${tmppath}/s.t.r.a.n.g.e.f.i.l.e" \
  28. "${tmppath}/.hiddenfile" \
  29. "${tmppath}/.hiddenfile.conf" \
  30. "${tmppath}/.hiddenfile.list" \
  31. "${tmppath}/multi..dot" \
  32. "${tmppath}/multi.dot.conf" \
  33. "${tmppath}/multi.dot.list" \
  34. "${tmppath}/disabledfile.disabled" \
  35. "${tmppath}/disabledfile.conf.disabled" \
  36. "${tmppath}/disabledfile.list.disabled" \
  37. "${tmppath}/invälid.conf" \
  38. "${tmppath}/invalíd" \
  39. "${tmppath}/01invalíd"
  40. mkdir "${tmppath}/invaliddir" \
  41. "${tmppath}/directory.conf" \
  42. "${tmppath}/directory.list" \
  43. "${tmppath}/directory.wron" \
  44. "${tmppath}/directory.list.disabled"
  45. ln -s "${tmppath}/anormalfile" "${tmppath}/linkedfile.list"
  46. ln -s "${tmppath}/non-existing-file" "${tmppath}/brokenlink.list"
  47. elif [ $name = "getLanguages${EXT}" ]; then
  48. echo "Prepare Testarea for \033[1;35m$name\033[0m ..."
  49. tmppath=$(mktemp -d)
  50. touch "${tmppath}/ftp.de.debian.org_debian_dists_sid_main_i18n_Translation-tr" \
  51. "${tmppath}/ftp.de.debian.org_debian_dists_sid_main_i18n_Translation-pt" \
  52. "${tmppath}/ftp.de.debian.org_debian_dists_sid_main_i18n_Translation-se~" \
  53. "${tmppath}/ftp.de.debian.org_debian_dists_sid_main_i18n_Translation-st.bak"
  54. elif [ $name = "HashSums${EXT}" ]; then
  55. TMP="$(mktemp)"
  56. dmesg > $TMP
  57. echo -n "Testing with \033[1;35m${name}\033[0m ... "
  58. 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"
  59. rm $TMP
  60. continue
  61. fi
  62. echo -n "Testing with \033[1;35m${name}\033[0m ... "
  63. LD_LIBRARY_PATH=${LDPATH} ${testapp} ${tmppath} && echo "\033[1;32mOKAY\033[0m" || echo "\033[1;31mFAILED\033[0m"
  64. if [ -n "$tmppath" -a -d "$tmppath" ]; then
  65. echo "Cleanup Testarea after \033[1;35m$name\033[0m ..."
  66. rm -rf "$tmppath"
  67. fi
  68. done