1 #!/bin/sh -e 2 3 DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 4 5 ECHO=echo 6 RM="rm -f" 7 GREP="grep" 8 INTOVOID="/dev/null" 9 10 die() { 11 $ECHO "$@" 1>&2 12 exit 1 13 } 14 15 isPresent() { 16 $GREP $@ tmplog || die "$@" "should be present" 17 } 18 19 mustBeAbsent() { 20 $GREP $@ tmplog && die "$@ should not be there !!" 21 $ECHO "$@ correctly not present" # for some reason, this $ECHO must exist, otherwise mustBeAbsent() always fails (??) 22 } 23 24 # default compilation : all features enabled - no zbuff 25 $ECHO "testing default library compilation" 26 CFLAGS= make -C $DIR/../lib libzstd libzstd.a > $INTOVOID 27 nm $DIR/../lib/libzstd.a | $GREP "\.o" > tmplog 28 isPresent "zstd_compress.o" 29 isPresent "zstd_decompress.o" 30 isPresent "zdict.o" 31 isPresent "zstd_v07.o" 32 mustBeAbsent "zbuff_compress.o" 33 $RM tmplog 34 35 # Check that the exec-stack bit isn't set 36 readelf -lW $DIR/../lib/libzstd.so | $GREP "GNU_STACK" > tmplog 37 mustBeAbsent "RWE" 38 $RM $DIR/../lib/libzstd.a $DIR/../lib/libzstd.so* tmplog 39 40 # compression disabled => also disable zdict 41 $ECHO "testing with compression disabled" 42 ZSTD_LIB_COMPRESSION=0 CFLAGS= make -C $DIR/../lib libzstd.a > $INTOVOID 43 nm $DIR/../lib/libzstd.a | $GREP "\.o" > tmplog 44 mustBeAbsent "zstd_compress.o" 45 isPresent "zstd_decompress.o" 46 mustBeAbsent "zdict.o" 47 isPresent "zstd_v07.o" 48 mustBeAbsent "zbuff_compress.o" 49 $RM $DIR/../lib/libzstd.a tmplog 50 51 # decompression disabled => also disable legacy 52 $ECHO "testing with decompression disabled" 53 ZSTD_LIB_DECOMPRESSION=0 CFLAGS= make -C $DIR/../lib libzstd.a > $INTOVOID 54 nm $DIR/../lib/libzstd.a | $GREP "\.o" > tmplog 55 isPresent "zstd_compress.o" 56 mustBeAbsent "zstd_decompress.o" 57 isPresent "zdict.o" 58 mustBeAbsent "zstd_v07.o" 59 mustBeAbsent "zbuff_compress.o" 60 $RM $DIR/../lib/libzstd.a tmplog 61 62 # deprecated function disabled => only remove zbuff 63 $ECHO "testing with deprecated functions disabled" 64 ZSTD_LIB_DEPRECATED=0 CFLAGS= make -C $DIR/../lib libzstd.a > $INTOVOID 65 nm $DIR/../lib/libzstd.a | $GREP "\.o" > tmplog 66 isPresent "zstd_compress.o" 67 isPresent "zstd_decompress.o" 68 isPresent "zdict.o" 69 isPresent "zstd_v07.o" 70 mustBeAbsent "zbuff_compress.o" 71 $RM $DIR/../lib/libzstd.a tmplog 72 73 # deprecated function enabled => zbuff present 74 $ECHO "testing with deprecated functions enabled" 75 ZSTD_LIB_DEPRECATED=1 CFLAGS= make -C $DIR/../lib libzstd.a > $INTOVOID 76 nm $DIR/../lib/libzstd.a | $GREP "\.o" > tmplog 77 isPresent "zstd_compress.o" 78 isPresent "zstd_decompress.o" 79 isPresent "zdict.o" 80 isPresent "zstd_v07.o" 81 isPresent "zbuff_compress.o" 82 $RM $DIR/../lib/libzstd.a tmplog 83 84 # dictionary builder disabled => only remove zdict 85 $ECHO "testing with dictionary builder disabled" 86 ZSTD_LIB_DICTBUILDER=0 CFLAGS= make -C $DIR/../lib libzstd.a > $INTOVOID 87 nm $DIR/../lib/libzstd.a | $GREP "\.o" > tmplog 88 isPresent "zstd_compress.o" 89 isPresent "zstd_decompress.o" 90 mustBeAbsent "zdict.o" 91 isPresent "zstd_v07.o" 92 mustBeAbsent "zbuff_compress.o" 93 $RM $DIR/../lib/libzstd.a tmplog 94 95 # both decompression and dictionary builder disabled => only compression remains 96 $ECHO "testing with both decompression and dictionary builder disabled (only compression remains)" 97 ZSTD_LIB_DECOMPRESSION=0 ZSTD_LIB_DICTBUILDER=0 CFLAGS= make -C $DIR/../lib libzstd.a > $INTOVOID 98 nm $DIR/../lib/libzstd.a | $GREP "\.o" > tmplog 99 isPresent "zstd_compress.o" 100 mustBeAbsent "zstd_decompress.o" 101 mustBeAbsent "zdict.o" 102 mustBeAbsent "zstd_v07.o" 103 mustBeAbsent "zbuff_compress.o" 104 $RM $DIR/../lib/libzstd.a tmplog 105