diff options
author | Takayuki Matsuoka <t-mat@users.noreply.github.com> | 2022-11-09 14:42:03 (GMT) |
---|---|---|
committer | Takayuki Matsuoka <t-mat@users.noreply.github.com> | 2022-11-09 14:42:03 (GMT) |
commit | 08f1483b0a4e685c2211f3ca24a9e505502dc333 (patch) | |
tree | a964fc84d6e205b82227c2478a7aa4be878b642d | |
parent | 214bfb325bd4db112b73859912b919aa35e12d61 (diff) | |
download | lz4-08f1483b0a4e685c2211f3ca24a9e505502dc333.zip lz4-08f1483b0a4e685c2211f3ca24a9e505502dc333.tar.gz lz4-08f1483b0a4e685c2211f3ca24a9e505502dc333.tar.bz2 |
Add environment check for freestanding test
Freestanding test is intended to run on only Linux x86_64 platform.
Because it uses Linux x86_64 syscall directly to avoid any dependency to the standard library.
This changeset adds platform checking code to tests/Makefile to avoid unintended
error in non-Linux x86_64 platforms.
This changeset resolves issue #1186
-rw-r--r-- | tests/Makefile | 37 | ||||
-rw-r--r-- | tests/freestanding.c | 1 |
2 files changed, 34 insertions, 4 deletions
diff --git a/tests/Makefile b/tests/Makefile index b446e4e..cebb0d1 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -115,9 +115,6 @@ decompress-partial: lz4.o decompress-partial.c decompress-partial-usingDict: lz4.o decompress-partial-usingDict.c $(CC) $(FLAGS) $^ -o $@$(EXT) -freestanding: freestanding.c - $(CC) -ffreestanding -nostdlib $^ -o $@$(EXT) - .PHONY: clean clean: @$(MAKE) -C $(LZ4DIR) $@ > $(VOID) @@ -353,10 +350,44 @@ test-decompress-partial : decompress-partial decompress-partial-usingDict @echo "\n ---- test decompress-partial-usingDict ----" ./decompress-partial-usingDict$(EXT) + +#----------------------------------------------------------------------------- +# freestanding test only for Linux x86_64 +#----------------------------------------------------------------------------- +ifeq ($(OS),Windows_NT) + UNAME_S := Windows +else + UNAME_S := $(shell uname -s) +endif + +ifeq ($(OS),Windows_NT) + UNAME_P := Unknown +else + UNAME_P := $(shell uname -p) +endif + +FREESTANDING_CFLAGS := -ffreestanding -nostdlib + +ifneq ($(UNAME_S), Linux) + FREESTANDING_CFLAGS := +endif + +ifneq ($(UNAME_P), x86_64) + FREESTANDING_CFLAGS := +endif + +freestanding: freestanding.c + $(CC) $(FREESTANDING_CFLAGS) $^ -o $@$(EXT) + test-freestanding: freestanding @echo "\n ---- test freestanding ----" +ifeq ($(FREESTANDING_CFLAGS),) + @echo "\n (skip)" +else ./freestanding$(EXT) -strace ./freestanding$(EXT) -ltrace ./freestanding$(EXT) +endif + endif diff --git a/tests/freestanding.c b/tests/freestanding.c index ceff4c5..6109aa7 100644 --- a/tests/freestanding.c +++ b/tests/freestanding.c @@ -30,7 +30,6 @@ #if !defined(__x86_64__) || !defined(__linux__) -EXTERN_C void _start(void) { } int main(int argc, char** argv) { return 0; } #else |