George Lu | 8e62675 | 2018-06-05 15:20:34 -0700 | [diff] [blame] | 1 | #!/bin/sh -e |
| 2 | |
Yann Collet | b7421f8 | 2018-10-24 11:32:09 -0700 | [diff] [blame] | 3 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" |
| 4 | |
| 5 | ECHO=echo |
| 6 | RM="rm -f" |
| 7 | GREP="grep" |
| 8 | INTOVOID="/dev/null" |
| 9 | |
George Lu | 8e62675 | 2018-06-05 15:20:34 -0700 | [diff] [blame] | 10 | die() { |
| 11 | $ECHO "$@" 1>&2 |
| 12 | exit 1 |
| 13 | } |
| 14 | |
Yann Collet | b7421f8 | 2018-10-24 11:32:09 -0700 | [diff] [blame] | 15 | isPresent() { |
| 16 | $GREP $@ tmplog || die "$@" "should be present" |
| 17 | } |
George Lu | 8e62675 | 2018-06-05 15:20:34 -0700 | [diff] [blame] | 18 | |
Yann Collet | b7421f8 | 2018-10-24 11:32:09 -0700 | [diff] [blame] | 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 | } |
George Lu | 8e62675 | 2018-06-05 15:20:34 -0700 | [diff] [blame] | 23 | |
senhuang42 | a423305 | 2021-04-19 17:12:51 -0400 | [diff] [blame] | 24 | # default compilation : all features enabled - no zbuff |
Yann Collet | b7421f8 | 2018-10-24 11:32:09 -0700 | [diff] [blame] | 25 | $ECHO "testing default library compilation" |
Nick Terrell | 360c263 | 2021-11-30 12:29:55 -0800 | [diff] [blame] | 26 | CFLAGS= make -C $DIR/../lib libzstd libzstd.a > $INTOVOID |
Yann Collet | b7421f8 | 2018-10-24 11:32:09 -0700 | [diff] [blame] | 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" |
senhuang42 | a423305 | 2021-04-19 17:12:51 -0400 | [diff] [blame] | 32 | mustBeAbsent "zbuff_compress.o" |
Nick Terrell | 360c263 | 2021-11-30 12:29:55 -0800 | [diff] [blame] | 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 |
Yann Collet | b7421f8 | 2018-10-24 11:32:09 -0700 | [diff] [blame] | 39 | |
senhuang42 | a423305 | 2021-04-19 17:12:51 -0400 | [diff] [blame] | 40 | # compression disabled => also disable zdict |
Yann Collet | b7421f8 | 2018-10-24 11:32:09 -0700 | [diff] [blame] | 41 | $ECHO "testing with compression disabled" |
George Lu | 8e62675 | 2018-06-05 15:20:34 -0700 | [diff] [blame] | 42 | ZSTD_LIB_COMPRESSION=0 CFLAGS= make -C $DIR/../lib libzstd.a > $INTOVOID |
Yann Collet | b7421f8 | 2018-10-24 11:32:09 -0700 | [diff] [blame] | 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 |
George Lu | 8e62675 | 2018-06-05 15:20:34 -0700 | [diff] [blame] | 50 | |
senhuang42 | a423305 | 2021-04-19 17:12:51 -0400 | [diff] [blame] | 51 | # decompression disabled => also disable legacy |
Yann Collet | b7421f8 | 2018-10-24 11:32:09 -0700 | [diff] [blame] | 52 | $ECHO "testing with decompression disabled" |
George Lu | 8e62675 | 2018-06-05 15:20:34 -0700 | [diff] [blame] | 53 | ZSTD_LIB_DECOMPRESSION=0 CFLAGS= make -C $DIR/../lib libzstd.a > $INTOVOID |
Yann Collet | b7421f8 | 2018-10-24 11:32:09 -0700 | [diff] [blame] | 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 |
George Lu | eab6262 | 2018-06-06 11:33:39 -0700 | [diff] [blame] | 61 | |
Yann Collet | b7421f8 | 2018-10-24 11:32:09 -0700 | [diff] [blame] | 62 | # deprecated function disabled => only remove zbuff |
| 63 | $ECHO "testing with deprecated functions disabled" |
George Lu | eab6262 | 2018-06-06 11:33:39 -0700 | [diff] [blame] | 64 | ZSTD_LIB_DEPRECATED=0 CFLAGS= make -C $DIR/../lib libzstd.a > $INTOVOID |
Yann Collet | b7421f8 | 2018-10-24 11:32:09 -0700 | [diff] [blame] | 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 |
George Lu | eab6262 | 2018-06-06 11:33:39 -0700 | [diff] [blame] | 72 | |
senhuang42 | a423305 | 2021-04-19 17:12:51 -0400 | [diff] [blame] | 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 | |
Yann Collet | b7421f8 | 2018-10-24 11:32:09 -0700 | [diff] [blame] | 84 | # dictionary builder disabled => only remove zdict |
| 85 | $ECHO "testing with dictionary builder disabled" |
George Lu | eab6262 | 2018-06-06 11:33:39 -0700 | [diff] [blame] | 86 | ZSTD_LIB_DICTBUILDER=0 CFLAGS= make -C $DIR/../lib libzstd.a > $INTOVOID |
Yann Collet | b7421f8 | 2018-10-24 11:32:09 -0700 | [diff] [blame] | 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" |
senhuang42 | a423305 | 2021-04-19 17:12:51 -0400 | [diff] [blame] | 92 | mustBeAbsent "zbuff_compress.o" |
Yann Collet | b7421f8 | 2018-10-24 11:32:09 -0700 | [diff] [blame] | 93 | $RM $DIR/../lib/libzstd.a tmplog |
George Lu | eab6262 | 2018-06-06 11:33:39 -0700 | [diff] [blame] | 94 | |
Yann Collet | b7421f8 | 2018-10-24 11:32:09 -0700 | [diff] [blame] | 95 | # both decompression and dictionary builder disabled => only compression remains |
| 96 | $ECHO "testing with both decompression and dictionary builder disabled (only compression remains)" |
George Lu | eab6262 | 2018-06-06 11:33:39 -0700 | [diff] [blame] | 97 | ZSTD_LIB_DECOMPRESSION=0 ZSTD_LIB_DICTBUILDER=0 CFLAGS= make -C $DIR/../lib libzstd.a > $INTOVOID |
Yann Collet | b7421f8 | 2018-10-24 11:32:09 -0700 | [diff] [blame] | 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 |