+# run-and-compare.cmake -- Runs a command and compares its output to an expected value
+
+# Copyright (C) 2021 Nathan Moinvaziri
+# Licensed under the Zlib license, see LICENSE.md for details
+
+# Required Variables
+# COMMAND - Command to run
+# OUTPUT - Standard output
+# COMPARE - String to compare output against
+
+# Optional Variables
+# INPUT - Standard intput
+# IGNORE_LINE_ENDINGS - Ignore line endings when comparing output
+
if(NOT DEFINED OUTPUT OR NOT DEFINED COMPARE OR NOT DEFINED COMMAND)
message(FATAL_ERROR "Run and compare arguments missing")
endif()
+# run-and-redirect.cmake -- Runs a command and validates exit code
+
+# Copyright (C) 2021 Nathan Moinvaziri
+# Licensed under the Zlib license, see LICENSE.md for details
+
+# Normally ctest will always fail with non-zero exit code, but we have tests
+# that need to check specific exit codes.
+
+# Required Variables
+# COMMAND - Command to run
+
+# Optional Variables
+# INPUT - Standard intput
+# OUTPUT - Standard output (default: /dev/null)
+# SUCCESS_EXIT - List of successful exit codes (default: 0, ie: 0;1)
+
# If no output is specified, discard output
if(NOT DEFINED OUTPUT)
if(WIN32)
+# test-compress.cmake -- Runs a test against an input file to make sure that the specified
+# targets are able to to compress and then decompress it successfully. Optionally verify
+# the results with gzip. Output files are generated with unique names to prevent parallel
+# tests from corrupting one another. Default target arguments are compatible with minigzip.
+
+# Copyright (C) 2021 Nathan Moinvaziri
+# Licensed under the Zlib license, see LICENSE.md for details
+
+# that test a specific input file for compression or decompression.
+
+# Required Variables
+# INPUT - Input file to test
+# TARGET or - Command to run for both compress and decompress
+# COMPRESS_TARGET and - Command to run to compress input file
+# DECOMPRESS_TARGET - Command to run to decompress output file
+
+# Optional Variables
+# COMPRESS_ARGS - Arguments to pass for compress command (default: -c -k)
+# DECOMPRESS_ARGS - Arguments to pass to decompress command (default: -d -c)
+
+# GZIP_VERIFY - Verify that gzip can decompress the COMPRESS_TARGET output and
+# verify that DECOMPRESS_TARGET can decompress gzip output of INPUT
+# COMPARE - Verify decompressed output is the same as input
+# SUCCESS_EXIT - List of successful exit codes (default: 0, ie: 0;1)
+
if(TARGET)
set(COMPRESS_TARGET ${TARGET})
set(DECOMPRESS_TARGET ${TARGET})
message(FATAL_ERROR "Cannot find minigzip decompress input: ${OUTPUT}.gzip.gz")
endif()
- # Check minigzip can decompress gzip compressed output
+ # Check decompress target can handle gzip compressed output
execute_process(COMMAND ${CMAKE_COMMAND}
"-DCOMMAND=${DECOMPRESS_COMMAND}"
-DINPUT=${OUTPUT}.gzip.gz