run-tests 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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. "${tmppath}/ftp.de.debian.org_debian_dists_sid_main_i18n_Translation-ast_DE" \
  65. "${tmppath}/ftp.de.debian.org_debian_dists_sid_main_i18n_Translation-tlh%5fDE"
  66. elif [ $name = "HashSums${EXT}" ]; then
  67. TMP="$(readlink -f "./${0}")"
  68. echo -n "Testing with ${NAME} "
  69. 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 "$TESTOKAY" || echo "$TESTFAIL"
  70. continue
  71. elif [ $name = "CompareVersion${EXT}" ]; then
  72. tmppath="${DIR}/versions.lst"
  73. elif [ $name = "CdromFindPackages${EXT}" ]; then
  74. tmppath=$(mktemp -d)
  75. mkdir -p "${tmppath}/.disk" "${tmppath}/pool" \
  76. "${tmppath}/dists/stable/main/binary-i386" \
  77. "${tmppath}/dists/stable/main/source" \
  78. "${tmppath}/dists/stable/contrib/binary-amd64" \
  79. "${tmppath}/dists/stable/contrib/binary-all" \
  80. "${tmppath}/dists/unstable/main/binary-i386" \
  81. "${tmppath}/dists/unstable/main/i18n" \
  82. "${tmppath}/dists/unstable/main/source" \
  83. "${tmppath}/dists/broken/non-free/source"
  84. touch "${tmppath}/dists/broken/.aptignr" \
  85. "${tmppath}/dists/stable/main/binary-i386/Packages" \
  86. "${tmppath}/dists/stable/main/binary-i386/Packages.bz2" \
  87. "${tmppath}/dists/stable/main/source/Sources.xz" \
  88. "${tmppath}/dists/stable/contrib/binary-amd64/Packages" \
  89. "${tmppath}/dists/stable/contrib/binary-amd64/Packages.gz" \
  90. "${tmppath}/dists/stable/contrib/binary-all/Packages" \
  91. "${tmppath}/dists/unstable/main/binary-i386/Packages.xz" \
  92. "${tmppath}/dists/unstable/main/binary-i386/Packages.lzma" \
  93. "${tmppath}/dists/unstable/main/i18n/Translation-en" \
  94. "${tmppath}/dists/unstable/main/i18n/Translation-de.bz2" \
  95. "${tmppath}/dists/unstable/main/source/Sources.xz" \
  96. "${tmppath}/dists/broken/non-free/source/Sources.gz" \
  97. "${tmppath}/dists/stable/Release.gpg" \
  98. "${tmppath}/dists/stable/Release" \
  99. "${tmppath}/dists/unstable/InRelease" \
  100. "${tmppath}/dists/broken/Release.gpg"
  101. ln -s "${tmppath}/dists/unstable" "${tmppath}/dists/sid"
  102. fi
  103. echo -n "Testing with ${NAME} "
  104. LD_LIBRARY_PATH=${LDPATH} ${testapp} ${tmppath} && echo "$TESTOKAY" || echo "$TESTFAIL"
  105. if [ -n "$tmppath" -a -d "$tmppath" ]; then
  106. rm -rf "$tmppath"
  107. fi
  108. done