]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Print differences between expected output in test-compress cmake script and upload...
authorNathan Moinvaziri <nathan@nathanm.com>
Fri, 30 Apr 2021 01:45:41 +0000 (18:45 -0700)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Mon, 3 May 2021 08:48:24 +0000 (10:48 +0200)
.github/workflows/cmake.yml
cmake/test-compress.cmake

index 95d3b5aa6411993fc08723094a16e0a0477c9e4a..8178e2a189500709acac3c607d099812c4a231ba 100644 (file)
@@ -441,4 +441,9 @@ jobs:
         path: |
           ${{ matrix.build-dir || '.' }}/CMakeFiles/CMakeOutput.log
           ${{ matrix.build-dir || '.' }}/CMakeFiles/CMakeError.log
+          ${{ matrix.build-dir || '.' }}/Testing/Temporary/*.log
+          ${{ matrix.build-dir || '.' }}/test/**/*.diff
+          ${{ matrix.build-dir || '.' }}/test/**/*.hex
+          ${{ matrix.build-dir || '.' }}/test/**/*.gz*
+          ${{ matrix.build-dir || '.' }}/test/**/*.out
         retention-days: 30
index 4e90821147fba2654c4cdfcd229a647e9cbbe9b0..97c387da2d348bcecdfb110fb7b9525bdabf1b78 100644 (file)
@@ -64,14 +64,41 @@ set(OUTPUT_BASE "${CMAKE_CURRENT_BINARY_DIR}/test/${TEST_NAME}-${UNIQUE_ID}")
 get_filename_component(OUTPUT_DIR "${OUTPUT_BASE}" DIRECTORY)
 file(MAKE_DIRECTORY "${OUTPUT_DIR}")
 
+# Cleanup temporary files
 macro(cleanup)
-    # Cleanup temporary files
-    file(REMOVE
-        ${OUTPUT_BASE}.gz
-        ${OUTPUT_BASE}.out
-        ${OUTPUT_BASE}.gzip
-        ${OUTPUT_BASE}.gzip.gz
-        ${OUTPUT_BASE}.gzip.out)
+    if(NOT DEFINED ENV{CI})
+        file(REMOVE
+            ${OUTPUT_BASE}.gz
+            ${OUTPUT_BASE}.out
+            ${OUTPUT_BASE}.gzip
+            ${OUTPUT_BASE}.gzip.gz
+            ${OUTPUT_BASE}.gzip.out)
+    endif()
+endmacro()
+
+# Show differences between two files
+macro(diff src1 src2)
+    find_program(XXD xxd)
+    if(XXD)
+        find_program(DIFF diff)
+        if(DIFF)
+            set(XXD_COMMAND ${XXD} ${src1} ${src1}.hex)
+            execute_process(COMMAND ${XXD_COMMAND})
+            set(XXD_COMMAND ${XXD} ${src2} ${src2}.hex)
+            execute_process(COMMAND ${XXD_COMMAND})
+
+            set(DIFF_COMMAND ${DIFF} -u ${src1}.hex ${src2}.hex)
+            execute_process(COMMAND ${DIFF_COMMAND}
+                OUTPUT_FILE ${src2}.diff)
+
+            file(READ ${src2}.diff DIFF_OUTPUT)
+            message(STATUS ${DIFF_OUTPUT})
+
+            if(NOT DEFINED ENV{CI})
+                file(REMOVE ${src1}.hex ${src2}.hex ${src2}.diff)
+            endif()
+        endif()
+    endif()
 endmacro()
 
 # Compress input file
@@ -122,6 +149,7 @@ if(COMPARE)
         RESULT_VARIABLE CMD_RESULT)
 
     if(CMD_RESULT)
+        diff(${INPUT} ${OUTPUT_BASE}.out)
         cleanup()
         message(FATAL_ERROR "Compare minigzip decompress failed: ${CMD_RESULT}")
     endif()
@@ -158,6 +186,7 @@ if(GZIP_VERIFY AND NOT "${COMPRESS_ARGS}" MATCHES "-T")
             RESULT_VARIABLE CMD_RESULT)
 
         if(CMD_RESULT)
+            diff(${INPUT} ${OUTPUT_BASE}.gzip.out)
             cleanup()
             message(FATAL_ERROR "Compare gzip decompress failed: ${CMD_RESULT}")
         endif()
@@ -209,6 +238,7 @@ if(GZIP_VERIFY AND NOT "${COMPRESS_ARGS}" MATCHES "-T")
                 RESULT_VARIABLE CMD_RESULT)
 
             if(CMD_RESULT)
+                diff(${INPUT} ${OUTPUT_BASE}.gzip)
                 cleanup()
                 message(FATAL_ERROR "Compare decompress gzip failed: ${CMD_RESULT}")
             endif()