zstd/tests/Makefile

298 lines
9.9 KiB
Makefile
Raw Normal View History

# ##########################################################################
# Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
# All rights reserved.
#
2017-01-17 03:40:06 -08:00
# This Makefile is validated for Linux, macOS, *BSD, Hurd, Solaris, MSYS2 targets
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree. An additional grant
# of patent rights can be found in the PATENTS file in the same directory.
# ##########################################################################
2016-08-18 04:18:11 -07:00
# datagen : Synthetic and parametrable data generator, for tests
2016-08-24 23:47:18 -07:00
# fullbench : Precisely measure speed for each zstd inner functions
# fullbench32: Same as fullbench, but forced to compile in 32-bits mode
2016-08-18 04:18:11 -07:00
# fuzzer : Test tool, to check zstd integrity on target platform
# fuzzer32: Same as fuzzer, but forced to compile in 32-bits mode
2016-08-24 23:47:18 -07:00
# paramgrill : parameter tester for zstd
# test-zstd-speed.py : script for testing zstd speed difference between commits
# versionsTest : compatibility test between zstd versions stored on Github (v0.1+)
# zstreamtest : Fuzzer test tool for zstd streaming API
# zstreamtest32: Same as zstreamtest, but forced to compile in 32-bits mode
# ##########################################################################
2016-08-18 04:18:11 -07:00
ZSTDDIR = ../lib
PRGDIR = ../programs
2016-08-18 05:04:57 -07:00
PYTHON ?= python3
TESTARTEFACT := versionsTest namespaceTest
2016-06-12 13:31:47 -07:00
CPPFLAGS+= -I$(ZSTDDIR) -I$(ZSTDDIR)/common -I$(ZSTDDIR)/compress -I$(ZSTDDIR)/dictBuilder -I$(ZSTDDIR)/deprecated -I$(PRGDIR)
2016-12-17 07:28:12 -08:00
CFLAGS ?= -O3
CFLAGS += -g -Wall -Wextra -Wcast-qual -Wcast-align -Wshadow -Wstrict-aliasing=1 \
-Wswitch-enum -Wdeclaration-after-statement -Wstrict-prototypes -Wundef
2016-12-17 07:28:12 -08:00
CFLAGS += $(MOREFLAGS)
FLAGS = $(CPPFLAGS) $(CFLAGS) $(LDFLAGS)
2016-08-18 04:18:11 -07:00
ZSTDCOMMON_FILES := $(ZSTDDIR)/common/*.c
ZSTDCOMP_FILES := $(ZSTDDIR)/compress/*.c
ZSTDDECOMP_FILES := $(ZSTDDIR)/decompress/*.c
2016-08-18 04:18:11 -07:00
ZSTD_FILES := $(ZSTDDECOMP_FILES) $(ZSTDCOMMON_FILES) $(ZSTDCOMP_FILES)
ZBUFF_FILES := $(ZSTDDIR)/deprecated/*.c
2016-08-18 04:18:11 -07:00
ZDICT_FILES := $(ZSTDDIR)/dictBuilder/*.c
# Define *.exe as extension for Windows systems
ifneq (,$(filter Windows%,$(OS)))
EXT =.exe
MULTITHREAD = -DZSTD_MULTITHREAD
2016-08-18 04:18:11 -07:00
else
EXT =
MULTITHREAD = -pthread -DZSTD_MULTITHREAD
2016-08-18 04:18:11 -07:00
endif
2016-11-03 07:38:13 -07:00
VOID = /dev/null
ZSTREAM_TESTTIME = -T2mn
FUZZERTEST ?= -T5mn
ZSTDRTTEST = --test-large-data
2016-08-18 04:18:11 -07:00
.PHONY: default all all32 dll clean test test32 test-all namespaceTest versionsTest
default: fullbench
2016-08-18 04:18:11 -07:00
all: fullbench fuzzer zstreamtest paramgrill datagen zbufftest
2016-08-18 04:18:11 -07:00
all32: fullbench32 fuzzer32 zstreamtest32 zbufftest32
2016-08-18 04:18:11 -07:00
dll: fuzzer-dll zstreamtest-dll zbufftest-dll
2016-12-17 07:28:12 -08:00
2016-08-18 04:18:11 -07:00
zstd:
$(MAKE) -C $(PRGDIR) $@
2016-08-18 04:18:11 -07:00
zstd32:
$(MAKE) -C $(PRGDIR) $@
2016-08-18 04:18:11 -07:00
2016-11-03 01:11:56 -07:00
zstd-nolegacy:
$(MAKE) -C $(PRGDIR) $@
2016-08-18 04:18:11 -07:00
2016-11-30 06:20:24 -08:00
gzstd:
$(MAKE) -C $(PRGDIR) $@
fullbench : $(ZSTD_FILES) $(PRGDIR)/datagen.c fullbench.c
2016-08-18 04:18:11 -07:00
$(CC) $(FLAGS) $^ -o $@$(EXT)
fullbench32 : $(ZSTD_FILES) $(PRGDIR)/datagen.c fullbench.c
2016-08-18 04:18:11 -07:00
$(CC) -m32 $(FLAGS) $^ -o $@$(EXT)
2016-11-21 03:51:01 -08:00
fullbench-lib: $(PRGDIR)/datagen.c fullbench.c
$(MAKE) -C $(ZSTDDIR) libzstd.a
$(CC) $(FLAGS) $^ -o $@$(EXT) $(ZSTDDIR)/libzstd.a
fullbench-dll: $(PRGDIR)/datagen.c fullbench.c
$(MAKE) -C $(ZSTDDIR) libzstd
$(CC) $(FLAGS) $^ -o $@$(EXT) -DZSTD_DLL_IMPORT=1 $(ZSTDDIR)/dll/libzstd.dll
2016-12-17 07:28:12 -08:00
fuzzer : $(ZSTD_FILES) $(ZDICT_FILES) $(PRGDIR)/datagen.c fuzzer.c
2016-08-18 04:18:11 -07:00
$(CC) $(FLAGS) $^ -o $@$(EXT)
fuzzer32 : $(ZSTD_FILES) $(ZDICT_FILES) $(PRGDIR)/datagen.c fuzzer.c
2016-12-17 07:28:12 -08:00
$(CC) -m32 $(FLAGS) $^ -o $@$(EXT)
fuzzer-dll : LDFLAGS+= -L$(ZSTDDIR) -lzstd
fuzzer-dll : $(ZSTDDIR)/common/xxhash.c $(PRGDIR)/datagen.c fuzzer.c
$(MAKE) -C $(ZSTDDIR) libzstd
$(CC) $(CPPFLAGS) $(CFLAGS) $^ $(LDFLAGS) -o $@$(EXT)
2016-08-18 04:18:11 -07:00
zbufftest : CPPFLAGS += -I$(ZSTDDIR)/deprecated
zbufftest : CFLAGS += -Wno-deprecated-declarations # required to silence deprecation warnings
zbufftest : $(ZSTD_FILES) $(ZBUFF_FILES) $(PRGDIR)/datagen.c zbufftest.c
$(CC) $(FLAGS) $^ -o $@$(EXT)
2016-08-18 04:18:11 -07:00
zbufftest32 : CPPFLAGS += -I$(ZSTDDIR)/deprecated
zbufftest32 : CFLAGS += -Wno-deprecated-declarations -m32
zbufftest32 : $(ZSTD_FILES) $(ZBUFF_FILES) $(PRGDIR)/datagen.c zbufftest.c
$(CC) $(FLAGS) $^ -o $@$(EXT)
2016-08-18 04:18:11 -07:00
zbufftest-dll : CPPFLAGS += -I$(ZSTDDIR)/deprecated
zbufftest-dll : CFLAGS += -Wno-deprecated-declarations # required to silence deprecation warnings
zbufftest-dll : LDFLAGS+= -L$(ZSTDDIR) -lzstd
zbufftest-dll : $(ZSTDDIR)/common/xxhash.c $(PRGDIR)/datagen.c zbufftest.c
$(MAKE) -C $(ZSTDDIR) libzstd
$(CC) $(CPPFLAGS) $(CFLAGS) $^ $(LDFLAGS) -o $@$(EXT)
zstreamtest : $(ZSTD_FILES) $(ZDICT_FILES) $(PRGDIR)/datagen.c zstreamtest.c
$(CC) $(FLAGS) $(MULTITHREAD) $^ -o $@$(EXT)
2016-08-18 04:18:11 -07:00
zstreamtest32 : $(ZSTD_FILES) $(ZDICT_FILES) $(PRGDIR)/datagen.c zstreamtest.c
$(CC) -m32 $(FLAGS) $(MULTITHREAD) $^ -o $@$(EXT)
2016-08-18 04:18:11 -07:00
2016-12-17 07:28:12 -08:00
zstreamtest-dll : LDFLAGS+= -L$(ZSTDDIR) -lzstd
zstreamtest-dll : $(ZSTDDIR)/common/xxhash.c $(PRGDIR)/datagen.c zstreamtest.c
$(MAKE) -C $(ZSTDDIR) libzstd
$(CC) $(CPPFLAGS) $(CFLAGS) $^ $(LDFLAGS) -o $@$(EXT)
paramgrill : $(ZSTD_FILES) $(PRGDIR)/datagen.c paramgrill.c
2016-08-18 04:18:11 -07:00
$(CC) $(FLAGS) $^ -lm -o $@$(EXT)
datagen : $(PRGDIR)/datagen.c datagencli.c
2016-08-18 04:18:11 -07:00
$(CC) $(FLAGS) $^ -o $@$(EXT)
roundTripCrash : $(ZSTD_FILES) roundTripCrash.c
$(CC) $(FLAGS) $^ -o $@$(EXT)
2016-12-10 19:12:13 -08:00
longmatch : $(ZSTD_FILES) longmatch.c
$(CC) $(FLAGS) $^ -o $@$(EXT)
2016-12-20 11:13:45 -08:00
invalidDictionaries : $(ZSTD_FILES) invalidDictionaries.c
$(CC) $(FLAGS) $^ -o $@$(EXT)
2016-12-16 13:29:23 -08:00
symbols : symbols.c
$(MAKE) -C $(ZSTDDIR) libzstd
ifneq (,$(filter Windows%,$(OS)))
cp $(ZSTDDIR)/dll/libzstd.dll .
$(CC) $(FLAGS) $^ -o $@$(EXT) -DZSTD_DLL_IMPORT=1 libzstd.dll
else
$(CC) $(FLAGS) $^ -o $@$(EXT) -Wl,-rpath=$(ZSTDDIR) $(ZSTDDIR)/libzstd.so
endif
2016-12-31 16:10:13 -08:00
pool : pool.c $(ZSTDDIR)/common/pool.c $(ZSTDDIR)/common/threading.c
$(CC) $(FLAGS) $(MULTITHREAD) $^ -o $@$(EXT)
2016-12-29 23:41:03 -08:00
2016-08-18 05:04:57 -07:00
namespaceTest:
if $(CC) namespaceTest.c ../lib/common/xxhash.c -o $@ ; then echo compilation should fail; exit 1 ; fi
$(RM) $@
versionsTest:
$(PYTHON) test-zstd-versions.py
clean:
2016-08-18 04:18:11 -07:00
$(MAKE) -C ../lib clean
2016-08-18 05:04:57 -07:00
@$(RM) -fR $(TESTARTEFACT)
@$(RM) -f core *.o tmp* result* *.gcda dictionary *.zst \
$(PRGDIR)/zstd$(EXT) $(PRGDIR)/zstd32$(EXT) \
2016-08-18 04:18:11 -07:00
fullbench$(EXT) fullbench32$(EXT) \
2016-11-21 04:58:58 -08:00
fullbench-lib$(EXT) fullbench-dll$(EXT) \
2016-08-18 04:18:11 -07:00
fuzzer$(EXT) fuzzer32$(EXT) zbufftest$(EXT) zbufftest32$(EXT) \
fuzzer-dll$(EXT) zstreamtest-dll$(EXT) zbufftest-dll$(EXT)\
2016-12-16 13:29:23 -08:00
zstreamtest$(EXT) zstreamtest32$(EXT) \
datagen$(EXT) paramgrill$(EXT) roundTripCrash$(EXT) longmatch$(EXT) \
2016-12-29 23:41:03 -08:00
symbols$(EXT) invalidDictionaries$(EXT) pool$(EXT)
@echo Cleaning completed
2016-08-18 04:18:11 -07:00
#----------------------------------------------------------------------------------
#make valgrindTest is validated only for Linux, OSX, BSD, Hurd and Solaris targets
2016-08-18 04:18:11 -07:00
#----------------------------------------------------------------------------------
ifneq (,$(filter $(shell uname),Linux Darwin GNU/kFreeBSD GNU OpenBSD FreeBSD NetBSD DragonFly SunOS))
2016-08-18 04:18:11 -07:00
HOST_OS = POSIX
2016-09-15 08:23:15 -07:00
valgrindTest: VALGRIND = valgrind --leak-check=full --error-exitcode=1
valgrindTest: zstd datagen fuzzer fullbench
2016-08-18 04:18:11 -07:00
@echo "\n ---- valgrind tests : memory analyzer ----"
$(VALGRIND) ./datagen -g50M > $(VOID)
$(VALGRIND) $(PRGDIR)/zstd ; if [ $$? -eq 0 ] ; then echo "zstd without argument should have failed"; false; fi
./datagen -g80 | $(VALGRIND) $(PRGDIR)/zstd - -c > $(VOID)
./datagen -g16KB | $(VALGRIND) $(PRGDIR)/zstd -vf - -c > $(VOID)
./datagen -g2930KB | $(VALGRIND) $(PRGDIR)/zstd -5 -vf - -o tmp
$(VALGRIND) $(PRGDIR)/zstd -vdf tmp -c > $(VOID)
./datagen -g64MB | $(VALGRIND) $(PRGDIR)/zstd -vf - -c > $(VOID)
2016-08-18 04:18:11 -07:00
@rm tmp
$(VALGRIND) ./fuzzer -T1mn -t1
$(VALGRIND) ./fullbench -i1
endif
ifneq (,$(filter MSYS%,$(shell uname)))
HOST_OS = MSYS
endif
#-----------------------------------------------------------------------------
#make tests validated only for MSYS, Linux, OSX, BSD, Hurd and Solaris targets
#-----------------------------------------------------------------------------
2016-08-18 04:18:11 -07:00
ifneq (,$(filter $(HOST_OS),MSYS POSIX))
DIFF:=diff
ifneq (,$(filter $(shell uname),SunOS))
DIFF:=gdiff
endif
2016-08-18 04:18:11 -07:00
zstd-playTests: datagen
2016-11-14 08:26:58 -08:00
file $(ZSTD)
2016-11-14 03:57:05 -08:00
ZSTD="$(QEMU_SYS) $(ZSTD)" ./playTests.sh $(ZSTDRTTEST)
2016-08-18 04:18:11 -07:00
2016-12-31 16:10:13 -08:00
test: test-zstd test-fullbench test-fuzzer test-zstream test-longmatch test-invalidDictionaries test-pool
2016-08-18 04:18:11 -07:00
test32: test-zstd32 test-fullbench32 test-fuzzer32 test-zstream32
2016-08-18 04:18:11 -07:00
test-all: test test32 valgrindTest
test-zstd: ZSTD = $(PRGDIR)/zstd
2016-08-18 04:18:11 -07:00
test-zstd: zstd zstd-playTests
test-zstd32: ZSTD = $(PRGDIR)/zstd32
2016-08-18 04:18:11 -07:00
test-zstd32: zstd32 zstd-playTests
2016-11-03 01:11:56 -07:00
test-zstd-nolegacy: ZSTD = $(PRGDIR)/zstd
test-zstd-nolegacy: zstd-nolegacy zstd-playTests
2016-08-18 04:18:11 -07:00
2016-11-30 06:20:24 -08:00
test-gzstd: gzstd
2016-12-05 09:02:40 -08:00
$(PRGDIR)/zstd README.md test-zstd-speed.py
2016-11-30 06:20:24 -08:00
gzip README.md test-zstd-speed.py
2016-12-05 09:02:40 -08:00
cat README.md.zst test-zstd-speed.py.gz >zstd_gz.zst
cat README.md.gz test-zstd-speed.py.zst >gz_zstd.gz
2016-11-30 06:20:24 -08:00
$(PRGDIR)/zstd -d README.md.gz -o README2.md
$(PRGDIR)/zstd -d README.md.gz test-zstd-speed.py.gz
2016-12-05 09:02:40 -08:00
$(PRGDIR)/zstd -d zstd_gz.zst gz_zstd.gz
$(DIFF) -q zstd_gz gz_zstd
2016-12-05 09:31:14 -08:00
echo Hello World ZSTD | $(PRGDIR)/zstd -c - >hello.zst
echo Hello World GZIP | gzip -c - >hello.gz
echo Hello World TEXT >hello.txt
cat hello.zst hello.gz hello.txt >hello_zst_gz_txt.gz
$(PRGDIR)/zstd -dcf hello.*
$(PRGDIR)/zstd -dcf - <hello_zst_gz_txt.gz
2016-11-30 06:20:24 -08:00
2016-08-18 04:18:11 -07:00
test-fullbench: fullbench datagen
2016-11-14 03:57:05 -08:00
$(QEMU_SYS) ./fullbench -i1
$(QEMU_SYS) ./fullbench -i1 -P0
2016-08-18 04:18:11 -07:00
test-fullbench32: fullbench32 datagen
2016-11-14 03:57:05 -08:00
$(QEMU_SYS) ./fullbench32 -i1
$(QEMU_SYS) ./fullbench32 -i1 -P0
2016-08-18 04:18:11 -07:00
test-fuzzer: fuzzer
2016-11-14 03:57:05 -08:00
$(QEMU_SYS) ./fuzzer $(FUZZERTEST)
2016-08-18 04:18:11 -07:00
test-fuzzer32: fuzzer32
2016-11-14 03:57:05 -08:00
$(QEMU_SYS) ./fuzzer32 $(FUZZERTEST)
2016-08-18 04:18:11 -07:00
test-zbuff: zbufftest
$(QEMU_SYS) ./zbufftest $(ZSTREAM_TESTTIME)
2016-08-18 04:18:11 -07:00
test-zbuff32: zbufftest32
$(QEMU_SYS) ./zbufftest32 $(ZSTREAM_TESTTIME)
2016-08-18 04:18:11 -07:00
test-zstream: zstreamtest
$(QEMU_SYS) ./zstreamtest $(ZSTREAM_TESTTIME)
2016-08-18 04:18:11 -07:00
test-zstream32: zstreamtest32
$(QEMU_SYS) ./zstreamtest32 $(ZSTREAM_TESTTIME)
2016-08-18 04:18:11 -07:00
2016-12-10 19:12:13 -08:00
test-longmatch: longmatch
$(QEMU_SYS) ./longmatch
2016-12-20 11:13:45 -08:00
test-invalidDictionaries: invalidDictionaries
$(QEMU_SYS) ./invalidDictionaries
2016-12-16 13:29:23 -08:00
test-symbols: symbols
$(QEMU_SYS) ./symbols
2016-12-29 23:41:03 -08:00
test-pool: pool
$(QEMU_SYS) ./pool
2016-08-18 04:18:11 -07:00
endif