# End-to-end check of the packer, at the CLI level: assemble a tape, pack it, # then run the *file* both ways and require identical output. The in-process # test (r8forge_tape_pack_test) covers the codec and the bracket strategies; this # one covers the two programs a person actually runs, including the image format # and its trailer. # # cmake -DR8FORGE=... -DPACK=... -DRUN=... -DSOURCE=... -DWORK=... -P pack_roundtrip.cmake foreach(var R8FORGE PACK RUN SOURCE WORK) if(NOT DEFINED ${var}) message(FATAL_ERROR "pack_roundtrip.cmake needs -D${var}=...") endif() endforeach() execute_process(COMMAND ${R8FORGE} ${SOURCE} OUTPUT_VARIABLE text RESULT_VARIABLE rc) if(NOT rc EQUAL 0) message(FATAL_ERROR "assembling ${SOURCE} failed: ${rc}") endif() string(LENGTH "${text}" length) file(WRITE ${WORK}/pack_roundtrip.rot8 "${text}") execute_process(COMMAND ${PACK} ${WORK}/pack_roundtrip.rot8 -o ${WORK}/pack_roundtrip.r8t --verify OUTPUT_VARIABLE packed RESULT_VARIABLE rc) if(NOT rc EQUAL 0) message(FATAL_ERROR "packing failed: ${rc} ${packed}") endif() message(STATUS "${packed}") foreach(flags "" "--loop-stack" "--retest" "--loop-stack --retest") separate_arguments(flag_list UNIX_COMMAND "${flags}") execute_process(COMMAND ${RUN} ${WORK}/pack_roundtrip.rot8 ${flag_list} OUTPUT_VARIABLE from_text RESULT_VARIABLE rc) if(NOT rc EQUAL 0) message(FATAL_ERROR "text run failed (${flags}): ${rc}") endif() execute_process(COMMAND ${RUN} ${WORK}/pack_roundtrip.r8t ${flag_list} OUTPUT_VARIABLE from_image RESULT_VARIABLE rc) if(NOT rc EQUAL 0) message(FATAL_ERROR "packed run failed (${flags}): ${rc}") endif() if(NOT from_image STREQUAL from_text) message(FATAL_ERROR "packed image prints something else (${flags})\n" " text: ${from_text}\n image: ${from_image}") endif() string(REGEX MATCH "\\(([0-9]+) steps" _ "${from_text}") message(STATUS "${length} instructions, ${from_image}") endforeach() # Image damage (flipped bit, missing trailer, nonsense geometry) is covered by # r8forge_tape_pack_test, which can corrupt a vector without touching files.