Skip to content

Commit

Permalink
Added cmake tests to verify output of makefixed (madler#398)
Browse files Browse the repository at this point in the history
* Add auto-generated header files to .gitignore
* Remove auto-generated header files in make clean
  • Loading branch information
nmoinvaz authored and Dead2 committed Sep 14, 2019
1 parent 5d4d630 commit 1ea02cc
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ CMakeFiles
Testing
*.cmake
*.stackdump
*._h
zconf.h
zconf.h.cmakein
zconf.h.included
Expand Down
12 changes: 12 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -890,6 +890,18 @@ if (ZLIB_ENABLE_TESTS)
add_test(NAME CVE-2003-0107 COMMAND CVE-2003-0107)
endif()

set(MAKEFIXED_COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:makefixed>)
add_test(NAME makefixed
COMMAND ${CMAKE_COMMAND}
"-DCOMMAND=${MAKEFIXED_COMMAND}"
-DOUTPUT=${CMAKE_CURRENT_SOURCE_DIR}/inffixed._h
-P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/run-and-redirect.cmake)

add_test(NAME makefixed-cmp
COMMAND ${CMAKE_COMMAND} -E compare_files
${CMAKE_CURRENT_SOURCE_DIR}/inffixed.h
${CMAKE_CURRENT_SOURCE_DIR}/inffixed._h)

set(GH_361_COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:minigzip> -4)
add_test(NAME GH-361
COMMAND ${CMAKE_COMMAND}
Expand Down
1 change: 1 addition & 0 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ clean:
rm -f *.gcda *.gcno *.gcov
rm -f a.out a.exe
rm -f *.pc
rm -f *._h

maintainer-clean: distclean
distclean: clean
Expand Down
22 changes: 15 additions & 7 deletions cmake/run-and-redirect.cmake
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
if(WIN32)
set(DEVNULL NUL)
if(NOT OUTPUT)
if(WIN32)
set(OUTPUT NUL)
else()
set(OUTPUT /dev/null)
endif()
endif()
if(INPUT)
execute_process(COMMAND ${COMMAND}
RESULT_VARIABLE CMD_RESULT
INPUT_FILE ${INPUT}
OUTPUT_FILE ${OUTPUT})
else()
set(DEVNULL /dev/null)
execute_process(COMMAND ${COMMAND}
RESULT_VARIABLE CMD_RESULT
OUTPUT_FILE ${OUTPUT})
endif()
execute_process(COMMAND ${COMMAND}
RESULT_VARIABLE CMD_RESULT
INPUT_FILE ${INPUT}
OUTPUT_FILE ${DEVNULL})
if(SUCCESS_EXIT)
list(FIND SUCCESS_EXIT ${CMD_RESULT} _INDEX)
if (${_INDEX} GREATER -1)
Expand Down

0 comments on commit 1ea02cc

Please sign in to comment.