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