run-tests 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. #!/bin/sh
  2. set -e
  3. DIR=$(readlink -f $(dirname $0))
  4. if [ -z "$MAKELEVEL" ]; then
  5. echo 'Compiling the tests …'
  6. (cd $DIR && make)
  7. echo 'Running all testcases …'
  8. fi
  9. LDPATH="$DIR/../../build/bin"
  10. EXT="_libapt_test"
  11. EXIT_CODE=0
  12. # detect if output is on a terminal (colorful) or better not
  13. if expr match "$(readlink -f /proc/$$/fd/1)" '/dev/pts/[0-9]\+' > /dev/null; then
  14. COLHIGH='\033[1;35m'
  15. COLRESET='\033[0m'
  16. TESTOKAY='\033[1;32mOKAY\033[0m'
  17. TESTFAIL='\033[1;31mFAILED\033[0m'
  18. else
  19. COLHIGH=''
  20. COLRESET=''
  21. TESTOKAY='OK'
  22. TESTFAIL='###FAILED###'
  23. fi
  24. for testapp in $(ls ${LDPATH}/*$EXT)
  25. do
  26. name=$(basename ${testapp})
  27. NAME="${COLHIGH}${name}${COLRESET}"
  28. tmppath=""
  29. if [ $name = "GetListOfFilesInDir${EXT}" ]; then
  30. # TODO: very-low: move env creation to the actual test-app
  31. tmppath=$(mktemp -d)
  32. touch "${tmppath}/anormalfile" \
  33. "${tmppath}/01yet-anothernormalfile" \
  34. "${tmppath}/anormalapt.conf" \
  35. "${tmppath}/01yet-anotherapt.conf" \
  36. "${tmppath}/anormalapt.list" \
  37. "${tmppath}/01yet-anotherapt.list" \
  38. "${tmppath}/wrongextension.wron" \
  39. "${tmppath}/wrong-extension.wron" \
  40. "${tmppath}/strangefile." \
  41. "${tmppath}/s.t.r.a.n.g.e.f.i.l.e" \
  42. "${tmppath}/.hiddenfile" \
  43. "${tmppath}/.hiddenfile.conf" \
  44. "${tmppath}/.hiddenfile.list" \
  45. "${tmppath}/multi..dot" \
  46. "${tmppath}/multi.dot.conf" \
  47. "${tmppath}/multi.dot.list" \
  48. "${tmppath}/disabledfile.disabled" \
  49. "${tmppath}/disabledfile.conf.disabled" \
  50. "${tmppath}/disabledfile.list.disabled" \
  51. "${tmppath}/invälid.conf" \
  52. "${tmppath}/invalíd" \
  53. "${tmppath}/01invalíd"
  54. mkdir "${tmppath}/invaliddir" \
  55. "${tmppath}/directory.conf" \
  56. "${tmppath}/directory.list" \
  57. "${tmppath}/directory.wron" \
  58. "${tmppath}/directory.list.disabled"
  59. ln -s "${tmppath}/anormalfile" "${tmppath}/linkedfile.list"
  60. ln -s "${tmppath}/non-existing-file" "${tmppath}/brokenlink.list"
  61. elif [ $name = "getLanguages${EXT}" ]; then
  62. tmppath=$(mktemp -d)
  63. touch "${tmppath}/ftp.de.debian.org_debian_dists_sid_main_i18n_Translation-tr" \
  64. "${tmppath}/ftp.de.debian.org_debian_dists_sid_main_i18n_Translation-pt" \
  65. "${tmppath}/ftp.de.debian.org_debian_dists_sid_main_i18n_Translation-se~" \
  66. "${tmppath}/ftp.de.debian.org_debian_dists_sid_main_i18n_Translation-st.bak" \
  67. "${tmppath}/ftp.de.debian.org_debian_dists_sid_main_i18n_Translation-ast_DE" \
  68. "${tmppath}/ftp.de.debian.org_debian_dists_sid_main_i18n_Translation-tlh%5fDE"
  69. elif [ $name = "HashSums${EXT}" ]; then
  70. TMP="$(readlink -f "./${0}")"
  71. tmppath="$TMP"
  72. tmppath="${tmppath} $(md5sum $TMP | cut -d' ' -f 1)"
  73. tmppath="${tmppath} $(sha1sum $TMP | cut -d' ' -f 1)"
  74. tmppath="${tmppath} $(sha256sum $TMP | cut -d' ' -f 1)"
  75. tmppath="${tmppath} $(sha512sum $TMP | cut -d' ' -f 1)"
  76. elif [ $name = "CompareVersion${EXT}" ]; then
  77. tmppath="${DIR}/versions.lst"
  78. elif [ $name = "CdromFindPackages${EXT}" ]; then
  79. tmppath=$(mktemp -d)
  80. mkdir -p "${tmppath}/.disk" "${tmppath}/pool" \
  81. "${tmppath}/dists/stable/main/binary-i386" \
  82. "${tmppath}/dists/stable/main/source" \
  83. "${tmppath}/dists/stable/contrib/binary-amd64" \
  84. "${tmppath}/dists/stable/contrib/binary-all" \
  85. "${tmppath}/dists/unstable/main/binary-i386" \
  86. "${tmppath}/dists/unstable/main/i18n" \
  87. "${tmppath}/dists/unstable/main/source" \
  88. "${tmppath}/dists/broken/non-free/source"
  89. touch "${tmppath}/dists/broken/.aptignr" \
  90. "${tmppath}/dists/stable/main/binary-i386/Packages" \
  91. "${tmppath}/dists/stable/main/binary-i386/Packages.bz2" \
  92. "${tmppath}/dists/stable/main/source/Sources.xz" \
  93. "${tmppath}/dists/stable/contrib/binary-amd64/Packages" \
  94. "${tmppath}/dists/stable/contrib/binary-amd64/Packages.gz" \
  95. "${tmppath}/dists/stable/contrib/binary-all/Packages" \
  96. "${tmppath}/dists/unstable/main/binary-i386/Packages.xz" \
  97. "${tmppath}/dists/unstable/main/binary-i386/Packages.lzma" \
  98. "${tmppath}/dists/unstable/main/i18n/Translation-en" \
  99. "${tmppath}/dists/unstable/main/i18n/Translation-de.bz2" \
  100. "${tmppath}/dists/unstable/main/source/Sources.xz" \
  101. "${tmppath}/dists/broken/non-free/source/Sources.gz" \
  102. "${tmppath}/dists/stable/Release.gpg" \
  103. "${tmppath}/dists/stable/Release" \
  104. "${tmppath}/dists/unstable/InRelease" \
  105. "${tmppath}/dists/broken/Release.gpg"
  106. ln -s "${tmppath}/dists/unstable" "${tmppath}/dists/sid"
  107. elif [ $name = "CdromFindMountPointForDevice${EXT}" ]; then
  108. tmppath=$(mktemp)
  109. echo 'rootfs / rootfs rw 0 0
  110. sysfs /sys sysfs rw,nosuid,nodev,noexec,relatime 0 0
  111. sysfs0 /sys0 sysfs rw,nosuid,nodev,noexec,relatime 0 0
  112. /dev/disk/by-uuid/fadcbc52-6284-4874-aaaa-dcee1f05fe21 / ext4 rw,relatime,errors=remount-ro,data=ordered 0 0
  113. /dev/sda1 /boot/efi vfat rw,nosuid,nodev,noexec,relatime,fmask=0000,dmask=0000,allow_utime=0022,codepage=437,iocharset=utf8,shortname=lower,quiet,utf8,errors=remount-ro,rw,nosuid,nodev,noexec,relatime,fmask=0000,dmask=0000,allow_utime=0022,codepage=437,iocharset=utf8,shortname=lower,quiet,utf8,errors=remount-ro,rw,nosuid,nodev,noexec,relatime,fmask=0000,dmask=0000,allow_utime=0022,codepage=437,iocharset=utf8,shortname=lower,quiet,utf8,errors=remount-ro,rw,nosuid,nodev,noexec,relatime,fmask=0000,dmask=0000,allow_utime=0022,codepage=437,iocharset=utf8,shortname=lower,quiet,utf8,errors=remount-ro 0 0
  114. tmpfs /tmp tmpfs rw,nosuid,nodev,relatime 0 0' > $tmppath
  115. fi
  116. echo -n "Testing with ${NAME} "
  117. if MALLOC_PERTURB_=21 MALLOC_CHECK_=2 LD_LIBRARY_PATH=${LDPATH} ${testapp} ${tmppath} ; then
  118. echo "$TESTOKAY"
  119. else
  120. echo "$TESTFAIL"
  121. EXIT_CODE=1
  122. fi
  123. if [ -n "$tmppath" -a -d "$tmppath" ]; then
  124. rm -rf "$tmppath"
  125. fi
  126. done
  127. exit $EXIT_CODE