blob: f9e1e76c6357d987d8679908f07058eecbfdc3d2 [file] [log] [blame]
George Lu8e626752018-06-05 15:20:34 -07001#!/bin/sh -e
2
Yann Colletb7421f82018-10-24 11:32:09 -07003DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
4
5ECHO=echo
6RM="rm -f"
7GREP="grep"
8INTOVOID="/dev/null"
9
George Lu8e626752018-06-05 15:20:34 -070010die() {
11 $ECHO "$@" 1>&2
12 exit 1
13}
14
Yann Colletb7421f82018-10-24 11:32:09 -070015isPresent() {
16 $GREP $@ tmplog || die "$@" "should be present"
17}
George Lu8e626752018-06-05 15:20:34 -070018
Yann Colletb7421f82018-10-24 11:32:09 -070019mustBeAbsent() {
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 Lu8e626752018-06-05 15:20:34 -070023
senhuang42a4233052021-04-19 17:12:51 -040024# default compilation : all features enabled - no zbuff
Yann Colletb7421f82018-10-24 11:32:09 -070025$ECHO "testing default library compilation"
Nick Terrell360c2632021-11-30 12:29:55 -080026CFLAGS= make -C $DIR/../lib libzstd libzstd.a > $INTOVOID
Yann Colletb7421f82018-10-24 11:32:09 -070027nm $DIR/../lib/libzstd.a | $GREP "\.o" > tmplog
28isPresent "zstd_compress.o"
29isPresent "zstd_decompress.o"
30isPresent "zdict.o"
31isPresent "zstd_v07.o"
senhuang42a4233052021-04-19 17:12:51 -040032mustBeAbsent "zbuff_compress.o"
Nick Terrell360c2632021-11-30 12:29:55 -080033$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
Yann Colletb7421f82018-10-24 11:32:09 -070039
senhuang42a4233052021-04-19 17:12:51 -040040# compression disabled => also disable zdict
Yann Colletb7421f82018-10-24 11:32:09 -070041$ECHO "testing with compression disabled"
George Lu8e626752018-06-05 15:20:34 -070042ZSTD_LIB_COMPRESSION=0 CFLAGS= make -C $DIR/../lib libzstd.a > $INTOVOID
Yann Colletb7421f82018-10-24 11:32:09 -070043nm $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
George Lu8e626752018-06-05 15:20:34 -070050
senhuang42a4233052021-04-19 17:12:51 -040051# decompression disabled => also disable legacy
Yann Colletb7421f82018-10-24 11:32:09 -070052$ECHO "testing with decompression disabled"
George Lu8e626752018-06-05 15:20:34 -070053ZSTD_LIB_DECOMPRESSION=0 CFLAGS= make -C $DIR/../lib libzstd.a > $INTOVOID
Yann Colletb7421f82018-10-24 11:32:09 -070054nm $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
George Lueab62622018-06-06 11:33:39 -070061
Yann Colletb7421f82018-10-24 11:32:09 -070062# deprecated function disabled => only remove zbuff
63$ECHO "testing with deprecated functions disabled"
George Lueab62622018-06-06 11:33:39 -070064ZSTD_LIB_DEPRECATED=0 CFLAGS= make -C $DIR/../lib libzstd.a > $INTOVOID
Yann Colletb7421f82018-10-24 11:32:09 -070065nm $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
George Lueab62622018-06-06 11:33:39 -070072
senhuang42a4233052021-04-19 17:12:51 -040073# 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
Yann Colletb7421f82018-10-24 11:32:09 -070084# dictionary builder disabled => only remove zdict
85$ECHO "testing with dictionary builder disabled"
George Lueab62622018-06-06 11:33:39 -070086ZSTD_LIB_DICTBUILDER=0 CFLAGS= make -C $DIR/../lib libzstd.a > $INTOVOID
Yann Colletb7421f82018-10-24 11:32:09 -070087nm $DIR/../lib/libzstd.a | $GREP "\.o" > tmplog
88isPresent "zstd_compress.o"
89isPresent "zstd_decompress.o"
90mustBeAbsent "zdict.o"
91isPresent "zstd_v07.o"
senhuang42a4233052021-04-19 17:12:51 -040092mustBeAbsent "zbuff_compress.o"
Yann Colletb7421f82018-10-24 11:32:09 -070093$RM $DIR/../lib/libzstd.a tmplog
George Lueab62622018-06-06 11:33:39 -070094
Yann Colletb7421f82018-10-24 11:32:09 -070095# both decompression and dictionary builder disabled => only compression remains
96$ECHO "testing with both decompression and dictionary builder disabled (only compression remains)"
George Lueab62622018-06-06 11:33:39 -070097ZSTD_LIB_DECOMPRESSION=0 ZSTD_LIB_DICTBUILDER=0 CFLAGS= make -C $DIR/../lib libzstd.a > $INTOVOID
Yann Colletb7421f82018-10-24 11:32:09 -070098nm $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