1#!/bin/sh -e 2 3DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 4 5ECHO=echo 6RM="rm -f" 7GREP="grep" 8INTOVOID="/dev/null" 9 10die() { 11 $ECHO "$@" 1>&2 12 exit 1 13} 14 15isPresent() { 16 $GREP $@ tmplog || die "$@" "should be present" 17} 18 19mustBeAbsent() { 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" 26CFLAGS= make -C $DIR/../lib libzstd libzstd.a > $INTOVOID 27nm $DIR/../lib/libzstd.a | $GREP "\.o" > tmplog 28isPresent "zstd_compress.o" 29isPresent "zstd_decompress.o" 30isPresent "zdict.o" 31isPresent "zstd_v07.o" 32mustBeAbsent "zbuff_compress.o" 33$RM tmplog 34 35# Check that the exec-stack bit isn't set 36readelf -lW $DIR/../lib/libzstd.so | $GREP "GNU_STACK" > tmplog 37mustBeAbsent "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" 42ZSTD_LIB_COMPRESSION=0 CFLAGS= make -C $DIR/../lib libzstd.a > $INTOVOID 43nm $DIR/../lib/libzstd.a | $GREP "\.o" > tmplog 44mustBeAbsent "zstd_compress.o" 45isPresent "zstd_decompress.o" 46mustBeAbsent "zdict.o" 47isPresent "zstd_v07.o" 48mustBeAbsent "zbuff_compress.o" 49$RM $DIR/../lib/libzstd.a tmplog 50 51# decompression disabled => also disable legacy 52$ECHO "testing with decompression disabled" 53ZSTD_LIB_DECOMPRESSION=0 CFLAGS= make -C $DIR/../lib libzstd.a > $INTOVOID 54nm $DIR/../lib/libzstd.a | $GREP "\.o" > tmplog 55isPresent "zstd_compress.o" 56mustBeAbsent "zstd_decompress.o" 57isPresent "zdict.o" 58mustBeAbsent "zstd_v07.o" 59mustBeAbsent "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" 64ZSTD_LIB_DEPRECATED=0 CFLAGS= make -C $DIR/../lib libzstd.a > $INTOVOID 65nm $DIR/../lib/libzstd.a | $GREP "\.o" > tmplog 66isPresent "zstd_compress.o" 67isPresent "zstd_decompress.o" 68isPresent "zdict.o" 69isPresent "zstd_v07.o" 70mustBeAbsent "zbuff_compress.o" 71$RM $DIR/../lib/libzstd.a tmplog 72 73# deprecated function enabled => zbuff present 74$ECHO "testing with deprecated functions enabled" 75ZSTD_LIB_DEPRECATED=1 CFLAGS= make -C $DIR/../lib libzstd.a > $INTOVOID 76nm $DIR/../lib/libzstd.a | $GREP "\.o" > tmplog 77isPresent "zstd_compress.o" 78isPresent "zstd_decompress.o" 79isPresent "zdict.o" 80isPresent "zstd_v07.o" 81isPresent "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" 86ZSTD_LIB_DICTBUILDER=0 CFLAGS= make -C $DIR/../lib libzstd.a > $INTOVOID 87nm $DIR/../lib/libzstd.a | $GREP "\.o" > tmplog 88isPresent "zstd_compress.o" 89isPresent "zstd_decompress.o" 90mustBeAbsent "zdict.o" 91isPresent "zstd_v07.o" 92mustBeAbsent "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)" 97ZSTD_LIB_DECOMPRESSION=0 ZSTD_LIB_DICTBUILDER=0 CFLAGS= make -C $DIR/../lib libzstd.a > $INTOVOID 98nm $DIR/../lib/libzstd.a | $GREP "\.o" > tmplog 99isPresent "zstd_compress.o" 100mustBeAbsent "zstd_decompress.o" 101mustBeAbsent "zdict.o" 102mustBeAbsent "zstd_v07.o" 103mustBeAbsent "zbuff_compress.o" 104$RM $DIR/../lib/libzstd.a tmplog 105