test-variants.sh 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. #!/bin/sh
  2. set -e
  3. set -u
  4. set -x
  5. SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
  6. PROG_DIR="$SCRIPT_DIR/../programs"
  7. ZSTD="$PROG_DIR/zstd"
  8. ZSTD_COMPRESS="$PROG_DIR/zstd-compress"
  9. ZSTD_DECOMPRESS="$PROG_DIR/zstd-decompress"
  10. ZSTD_NOLEGACY="$PROG_DIR/zstd-nolegacy"
  11. ZSTD_DICTBUILDER="$PROG_DIR/zstd-dictBuilder"
  12. ZSTD_FRUGAL="$PROG_DIR/zstd-frugal"
  13. ZSTD_NOMT="$PROG_DIR/zstd-nomt"
  14. println() {
  15. printf '%b\n' "${*}"
  16. }
  17. die() {
  18. println "$@" 1>&2
  19. exit 1
  20. }
  21. symbol_present() {
  22. (nm $1 || echo "symbol_present $@ failed") | grep $2
  23. }
  24. symbol_not_present() {
  25. symbol_present $@ && die "Binary '$1' mistakenly contains symbol '$2'" ||:
  26. }
  27. compress_not_present() {
  28. symbol_not_present "$1" ZSTD_compress
  29. }
  30. decompress_not_present() {
  31. symbol_not_present "$1" ZSTD_decompress
  32. }
  33. dict_not_present() {
  34. symbol_not_present "$1" ZDICT_
  35. symbol_not_present "$1" COVER_
  36. }
  37. cliextra_not_present() {
  38. symbol_not_present "$1" TRACE_
  39. symbol_not_present "$1" BMK_
  40. }
  41. legacy_not_present() {
  42. symbol_not_present "$1" ZSTDv0
  43. }
  44. test_help() {
  45. "$1" --help | grep -- "$2"
  46. }
  47. test_no_help() {
  48. test_help $@ && die "'$1' supports '$2' when it shouldn't" ||:
  49. }
  50. extras_not_present() {
  51. dict_not_present $@
  52. legacy_not_present $@
  53. cliextra_not_present $@
  54. test_no_help $@ "--train"
  55. test_no_help $@ "-b#"
  56. }
  57. test_compress() {
  58. echo "hello" | "$1" | "$ZSTD" -t
  59. }
  60. test_decompress() {
  61. echo "hello" | "$ZSTD" | "$1" -t
  62. }
  63. test_zstd() {
  64. test_compress $@
  65. test_decompress $@
  66. }
  67. extras_not_present "$ZSTD_FRUGAL"
  68. extras_not_present "$ZSTD_COMPRESS"
  69. extras_not_present "$ZSTD_DECOMPRESS"
  70. compress_not_present "$ZSTD_DECOMPRESS"
  71. decompress_not_present "$ZSTD_COMPRESS"
  72. decompress_not_present "$ZSTD_DICTBUILDER"
  73. cliextra_not_present "$ZSTD_DICTBUILDER"
  74. legacy_not_present "$ZSTD_DICTBUILDER"
  75. legacy_not_present "$ZSTD_NOLEGACY"
  76. symbol_not_present "$ZSTD" ZSTDv01
  77. symbol_not_present "$ZSTD" ZSTDv02
  78. symbol_not_present "$ZSTD" ZSTDv03
  79. symbol_not_present "$ZSTD" ZSTDv04
  80. test_compress "$ZSTD_COMPRESS"
  81. test_decompress "$ZSTD_DECOMPRESS"
  82. test_zstd "$ZSTD_FRUGAL"
  83. test_zstd "$ZSTD_NOLEGACY"
  84. test_help "$ZSTD" '-b#'
  85. test_help "$ZSTD" --train
  86. test_help "$ZSTD_DICTBUILDER" --train
  87. println "Success!"