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.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 $DIR/../lib/libzstd.a tmplog 34 35# compression disabled => also disable zdict 36$ECHO "testing with compression disabled" 37ZSTD_LIB_COMPRESSION=0 CFLAGS= make -C $DIR/../lib libzstd.a > $INTOVOID 38nm $DIR/../lib/libzstd.a | $GREP "\.o" > tmplog 39mustBeAbsent "zstd_compress.o" 40isPresent "zstd_decompress.o" 41mustBeAbsent "zdict.o" 42isPresent "zstd_v07.o" 43mustBeAbsent "zbuff_compress.o" 44$RM $DIR/../lib/libzstd.a tmplog 45 46# decompression disabled => also disable legacy 47$ECHO "testing with decompression disabled" 48ZSTD_LIB_DECOMPRESSION=0 CFLAGS= make -C $DIR/../lib libzstd.a > $INTOVOID 49nm $DIR/../lib/libzstd.a | $GREP "\.o" > tmplog 50isPresent "zstd_compress.o" 51mustBeAbsent "zstd_decompress.o" 52isPresent "zdict.o" 53mustBeAbsent "zstd_v07.o" 54mustBeAbsent "zbuff_compress.o" 55$RM $DIR/../lib/libzstd.a tmplog 56 57# deprecated function disabled => only remove zbuff 58$ECHO "testing with deprecated functions disabled" 59ZSTD_LIB_DEPRECATED=0 CFLAGS= make -C $DIR/../lib libzstd.a > $INTOVOID 60nm $DIR/../lib/libzstd.a | $GREP "\.o" > tmplog 61isPresent "zstd_compress.o" 62isPresent "zstd_decompress.o" 63isPresent "zdict.o" 64isPresent "zstd_v07.o" 65mustBeAbsent "zbuff_compress.o" 66$RM $DIR/../lib/libzstd.a tmplog 67 68# deprecated function enabled => zbuff present 69$ECHO "testing with deprecated functions enabled" 70ZSTD_LIB_DEPRECATED=1 CFLAGS= make -C $DIR/../lib libzstd.a > $INTOVOID 71nm $DIR/../lib/libzstd.a | $GREP "\.o" > tmplog 72isPresent "zstd_compress.o" 73isPresent "zstd_decompress.o" 74isPresent "zdict.o" 75isPresent "zstd_v07.o" 76isPresent "zbuff_compress.o" 77$RM $DIR/../lib/libzstd.a tmplog 78 79# dictionary builder disabled => only remove zdict 80$ECHO "testing with dictionary builder disabled" 81ZSTD_LIB_DICTBUILDER=0 CFLAGS= make -C $DIR/../lib libzstd.a > $INTOVOID 82nm $DIR/../lib/libzstd.a | $GREP "\.o" > tmplog 83isPresent "zstd_compress.o" 84isPresent "zstd_decompress.o" 85mustBeAbsent "zdict.o" 86isPresent "zstd_v07.o" 87mustBeAbsent "zbuff_compress.o" 88$RM $DIR/../lib/libzstd.a tmplog 89 90# both decompression and dictionary builder disabled => only compression remains 91$ECHO "testing with both decompression and dictionary builder disabled (only compression remains)" 92ZSTD_LIB_DECOMPRESSION=0 ZSTD_LIB_DICTBUILDER=0 CFLAGS= make -C $DIR/../lib libzstd.a > $INTOVOID 93nm $DIR/../lib/libzstd.a | $GREP "\.o" > tmplog 94isPresent "zstd_compress.o" 95mustBeAbsent "zstd_decompress.o" 96mustBeAbsent "zdict.o" 97mustBeAbsent "zstd_v07.o" 98mustBeAbsent "zbuff_compress.o" 99$RM $DIR/../lib/libzstd.a tmplog 100