diff options
Diffstat (limited to 'tests/integration')
| -rw-r--r-- | tests/integration/ft8/run_tx_loopback.cmake | 86 | ||||
| -rw-r--r-- | tests/integration/ft8/tx_loopback.expected.txt | 2 | ||||
| -rw-r--r-- | tests/integration/jt9/compare_decoder_output.cmake | 44 | ||||
| -rw-r--r-- | tests/integration/jt9/compare_mtd_messages.cmake | 133 | ||||
| -rw-r--r-- | tests/integration/jt9/smoke_decoder_callback.cmake | 47 | ||||
| -rw-r--r-- | tests/integration/jt9/verify_elf_stack.cmake | 30 | ||||
| -rw-r--r-- | tests/integration/jt9/verify_jt4_12000_read_extent.cmake | 67 | ||||
| -rw-r--r-- | tests/integration/jtty/live_audio.expected.txt | 1 | ||||
| -rw-r--r-- | tests/integration/jtty/run_live_audio.cmake | 66 | ||||
| -rw-r--r-- | tests/integration/jtty/run_tx_loopback.cmake | 84 | ||||
| -rw-r--r-- | tests/integration/jtty/tx_loopback.expected.txt | 2 | ||||
| -rwxr-xr-x | tests/integration/run-live-audio-parallel-experiment.sh | 194 | ||||
| -rw-r--r-- | tests/integration/wsprd/compare_wsprd_output.cmake | 41 |
13 files changed, 797 insertions, 0 deletions
diff --git a/tests/integration/ft8/run_tx_loopback.cmake b/tests/integration/ft8/run_tx_loopback.cmake new file mode 100644 index 00000000..52853949 --- /dev/null +++ b/tests/integration/ft8/run_tx_loopback.cmake @@ -0,0 +1,86 @@ +foreach (required_variable WSJTX WORK_DIR EXPECTED DATA_DIR) + if (NOT DEFINED ${required_variable} OR "${${required_variable}}" STREQUAL "") + message (FATAL_ERROR "${required_variable} is required") + endif () +endforeach () + +set (ipc_dir "${WORK_DIR}-ipc") +file (REMOVE_RECURSE "${WORK_DIR}") +file (MAKE_DIRECTORY + "${WORK_DIR}/capture/config" + "${WORK_DIR}/capture/data" + "${WORK_DIR}/capture/cache" + "${WORK_DIR}/replay/config" + "${WORK_DIR}/replay/data" + "${WORK_DIR}/replay/cache" + "${ipc_dir}/capture" + "${ipc_dir}/replay") + +set (capture "${WORK_DIR}/ft8-tx-loopback.wav") +set (capture_environment + "XDG_CONFIG_HOME=${WORK_DIR}/capture/config" + "XDG_DATA_HOME=${WORK_DIR}/capture/data" + "XDG_CACHE_HOME=${WORK_DIR}/capture/cache" + "WSJT_QMAP_SHARED_MEMORY_KEY=mem_qmap-test_wsjtx_ft8_tx_loopback") +set (replay_environment + "XDG_CONFIG_HOME=${WORK_DIR}/replay/config" + "XDG_DATA_HOME=${WORK_DIR}/replay/data" + "XDG_CACHE_HOME=${WORK_DIR}/replay/cache" + "WSJT_QMAP_SHARED_MEMORY_KEY=mem_qmap-test_wsjtx_ft8_tx_loopback") +if (NOT APPLE) + list (APPEND capture_environment "TMPDIR=${ipc_dir}/capture") + list (APPEND replay_environment "TMPDIR=${ipc_dir}/replay") +endif () + +execute_process ( + COMMAND "${CMAKE_COMMAND}" -E env + ${capture_environment} + "${WSJTX}" + --ft8-tx-loopback-test "${capture}" + --rig-name CTEST-FT8-TX-CAPTURE + WORKING_DIRECTORY "${WORK_DIR}/capture" + RESULT_VARIABLE capture_result + OUTPUT_VARIABLE capture_stdout + ERROR_VARIABLE capture_stderr) +if (NOT capture_result STREQUAL "0") + message (FATAL_ERROR + "WSJT-X FT8 transmit capture failed with exit code ${capture_result}\n" + "stdout:\n${capture_stdout}\n" + "stderr:\n${capture_stderr}") +endif () + +if (NOT EXISTS "${capture}") + message (FATAL_ERROR "WSJT-X did not create ${capture}") +endif () +file (SIZE "${capture}" capture_size) +if (NOT capture_size EQUAL 1440044) + message (FATAL_ERROR + "WSJT-X FT8 capture must contain a 44-byte header and 720000 frames; size=${capture_size}") +endif () +file (READ "${capture}" capture_header OFFSET 0 LIMIT 44 HEX) +if (NOT capture_header MATCHES + "^5249464624f9150057415645666d7420100000000100010080bb000000770100020010006461746100f91500$") + message (FATAL_ERROR + "WSJT-X capture is not an exact 48 kHz mono signed 16-bit PCM RIFF/WAVE period: ${capture_header}") +endif () + +execute_process ( + COMMAND "${CMAKE_COMMAND}" -E env + ${replay_environment} + "${WSJTX}" + --live-audio-test "${capture}" + --live-audio-expected "${EXPECTED}" + --live-audio-data-dir "${DATA_DIR}" + --rig-name CTEST-FT8-TX-REPLAY + WORKING_DIRECTORY "${WORK_DIR}/replay" + RESULT_VARIABLE replay_result + OUTPUT_VARIABLE replay_stdout + ERROR_VARIABLE replay_stderr) +if (NOT replay_result STREQUAL "0") + message (FATAL_ERROR + "WSJT-X FT8 transmit replay failed with exit code ${replay_result}\n" + "stdout:\n${replay_stdout}\n" + "stderr:\n${replay_stderr}") +endif () + +message (STATUS "WSJT-X FT8 transmit loopback smoke test passed") diff --git a/tests/integration/ft8/tx_loopback.expected.txt b/tests/integration/ft8/tx_loopback.expected.txt new file mode 100644 index 00000000..175fa871 --- /dev/null +++ b/tests/integration/ft8/tx_loopback.expected.txt @@ -0,0 +1,2 @@ +# Message identities are compared as a set; numeric metadata is informational. +000000 0 0.0 1500 ~ CQ KA1ABC FN42 diff --git a/tests/integration/jt9/compare_decoder_output.cmake b/tests/integration/jt9/compare_decoder_output.cmake new file mode 100644 index 00000000..a7d28827 --- /dev/null +++ b/tests/integration/jt9/compare_decoder_output.cmake @@ -0,0 +1,44 @@ +foreach (required_variable JT9 MODE SAMPLE EXPECTED WORK_DIR SOURCE_DIR) + if (NOT DEFINED ${required_variable} OR "${${required_variable}}" STREQUAL "") + message (FATAL_ERROR "${required_variable} is required") + endif () +endforeach () + +file (MAKE_DIRECTORY "${WORK_DIR}") +set (actual_file "${WORK_DIR}/actual.txt") +set (stderr_file "${WORK_DIR}/stderr.txt") + +execute_process ( + COMMAND "${JT9}" + -a "${WORK_DIR}" + -t "${WORK_DIR}" + -r "${SOURCE_DIR}" + ${MODE} + "${SAMPLE}" + WORKING_DIRECTORY "${WORK_DIR}" + RESULT_VARIABLE decoder_result + OUTPUT_VARIABLE decoder_stdout + ERROR_VARIABLE decoder_stderr) + +file (WRITE "${actual_file}" "${decoder_stdout}") +file (WRITE "${stderr_file}" "${decoder_stderr}") + +if (NOT "${decoder_result}" STREQUAL "0") + message (FATAL_ERROR + "jt9 exited with ${decoder_result}\n" + "stdout:\n${decoder_stdout}\n" + "stderr:\n${decoder_stderr}") +endif () + +if (NOT "${decoder_stderr}" STREQUAL "") + message (FATAL_ERROR "jt9 wrote to stderr:\n${decoder_stderr}") +endif () + +file (READ "${EXPECTED}" expected_output) +if (NOT "${decoder_stdout}" STREQUAL "${expected_output}") + message (FATAL_ERROR + "jt9 output differs from ${EXPECTED}\n" + "expected:\n${expected_output}\n" + "actual:\n${decoder_stdout}\n" + "preserved output: ${actual_file}") +endif () diff --git a/tests/integration/jt9/compare_mtd_messages.cmake b/tests/integration/jt9/compare_mtd_messages.cmake new file mode 100644 index 00000000..4011dca7 --- /dev/null +++ b/tests/integration/jt9/compare_mtd_messages.cmake @@ -0,0 +1,133 @@ +foreach (required_variable JT9 SAMPLE EXPECTED WORK_DIR SOURCE_DIR MTD_WORKERS + DECODE_CYCLES FFT_THREADS) + if (NOT DEFINED ${required_variable} OR "${${required_variable}}" STREQUAL "") + message (FATAL_ERROR "${required_variable} is required") + endif () +endforeach () + +file (MAKE_DIRECTORY "${WORK_DIR}") + +set (input_samples "${SAMPLE}") +set (expected_completion_count 1) +if (CONSECUTIVE_PERIODS) + set (input_samples) + foreach (utc IN ITEMS 133430 133445 133500 133515) + set (period_sample "${WORK_DIR}/210703_${utc}.wav") + configure_file ("${SAMPLE}" "${period_sample}" COPYONLY) + list (APPEND input_samples "${period_sample}") + endforeach () + list (LENGTH input_samples expected_completion_count) +endif () + +set (qso_arguments) +set (qso_variables MY_CALL DX_CALL QSO_FREQUENCY QSO_PROGRESS) +set (configured_qso_variable_count 0) +foreach (qso_variable IN LISTS qso_variables) + if (DEFINED ${qso_variable} AND NOT "${${qso_variable}}" STREQUAL "") + math (EXPR configured_qso_variable_count + "${configured_qso_variable_count} + 1") + endif () +endforeach () +if (configured_qso_variable_count GREATER 0 AND + NOT configured_qso_variable_count EQUAL 4) + message (FATAL_ERROR + "MY_CALL, DX_CALL, QSO_FREQUENCY, and QSO_PROGRESS must be set together") +elseif (configured_qso_variable_count EQUAL 4) + list (APPEND qso_arguments + -c "${MY_CALL}" -x "${DX_CALL}" -f "${QSO_FREQUENCY}" -Q "${QSO_PROGRESS}") +endif () + +set (actual_file "${WORK_DIR}/actual.txt") +set (stderr_file "${WORK_DIR}/stderr.txt") +file (WRITE "${stderr_file}" "") + +execute_process ( + COMMAND "${CMAKE_COMMAND}" -E env OMP_STACKSIZE=16M + "${JT9}" + -8 -M -N ${MTD_WORKERS} -d 3 -C ${DECODE_CYCLES} -E 3 -D 3 + -p 15 -m ${FFT_THREADS} -L 200 -H 3000 + -a "${WORK_DIR}" + -t "${WORK_DIR}" + -r "${SOURCE_DIR}" + ${qso_arguments} + ${input_samples} + WORKING_DIRECTORY "${WORK_DIR}" + RESULT_VARIABLE decoder_result + OUTPUT_VARIABLE decoder_stdout + ERROR_FILE "${stderr_file}") + +file (WRITE "${actual_file}" "${decoder_stdout}") +file (READ "${stderr_file}" decoder_stderr) + +if (NOT "${decoder_result}" STREQUAL "0") + message (FATAL_ERROR + "jt9 MTD exited with ${decoder_result}\n" + "stdout:\n${decoder_stdout}\n" + "stderr:\n${decoder_stderr}") +endif () + +if (NOT "${decoder_stderr}" STREQUAL "") + message (FATAL_ERROR "jt9 MTD wrote to stderr:\n${decoder_stderr}") +endif () + +string (REGEX MATCHALL "<DecodeFinished>" completion_markers "${decoder_stdout}") +list (LENGTH completion_markers completion_count) +if (NOT completion_count EQUAL expected_completion_count) + message (FATAL_ERROR + "jt9 MTD completed ${completion_count} decode periods; " + "expected ${expected_completion_count}") +endif () + +file (READ "${EXPECTED}" expected_output) + +# OpenMP worker completion order and numeric decode metadata are not stable invariants. +function (extract_ft8_messages decoder_output output_variable) + set (required_period "${ARGV2}") + string (REPLACE "\r\n" "\n" normalized_output "${decoder_output}") + string (REPLACE "\n" ";" output_lines "${normalized_output}") + set (messages) + foreach (line IN LISTS output_lines) + if (NOT "${required_period}" STREQUAL "") + string (STRIP "${line}" stripped_line) + string (FIND "${stripped_line}" "${required_period} " period_position) + if (NOT period_position EQUAL 0) + continue () + endif () + endif () + string (FIND "${line}" "~" marker_position) + if (marker_position GREATER_EQUAL 0) + math (EXPR message_position "${marker_position} + 1") + string (SUBSTRING "${line}" ${message_position} -1 message) + string (STRIP "${message}" message) + if (NOT "${message}" STREQUAL "") + list (APPEND messages "${message}") + endif () + endif () + endforeach () + list (REMOVE_DUPLICATES messages) + list (SORT messages) + set (${output_variable} "${messages}" PARENT_SCOPE) +endfunction () + +extract_ft8_messages ("${expected_output}" expected_messages) +extract_ft8_messages ("${decoder_stdout}" actual_messages) + +if (CONSECUTIVE_PERIODS) + foreach (utc IN ITEMS 133430 133445 133500 133515) + extract_ft8_messages ("${decoder_stdout}" period_messages "${utc}") + if (NOT "${period_messages}" STREQUAL "${expected_messages}") + message (FATAL_ERROR + "jt9 MTD decoded message set differs in period ${utc}") + endif () + endforeach () +endif () + +if (NOT "${actual_messages}" STREQUAL "${expected_messages}") + string (REPLACE ";" "\n " expected_display "${expected_messages}") + string (REPLACE ";" "\n " actual_display "${actual_messages}") + message (FATAL_ERROR + "jt9 MTD decoded message set differs from ${EXPECTED}\n" + "expected:\n ${expected_display}\n" + "actual:\n ${actual_display}\n" + "preserved output: ${actual_file}") +endif () diff --git a/tests/integration/jt9/smoke_decoder_callback.cmake b/tests/integration/jt9/smoke_decoder_callback.cmake new file mode 100644 index 00000000..6a4e698f --- /dev/null +++ b/tests/integration/jt9/smoke_decoder_callback.cmake @@ -0,0 +1,47 @@ +foreach (required_variable JT9 SAMPLE EXPECTED_MESSAGE WORK_DIR SOURCE_DIR) + if (NOT DEFINED ${required_variable} OR "${${required_variable}}" STREQUAL "") + message (FATAL_ERROR "${required_variable} is required") + endif () +endforeach () + +file (MAKE_DIRECTORY "${WORK_DIR}") +set (actual_file "${WORK_DIR}/actual.txt") + +execute_process ( + COMMAND "${JT9}" + -a "${WORK_DIR}" + -t "${WORK_DIR}" + -r "${SOURCE_DIR}" + -8 + -d 1 + -x b + -L 1000 + -H 1400 + "${SAMPLE}" + WORKING_DIRECTORY "${WORK_DIR}" + RESULT_VARIABLE decoder_result + OUTPUT_VARIABLE decoder_stdout + ERROR_VARIABLE decoder_stderr) + +file (WRITE "${actual_file}" "${decoder_stdout}") + +if (NOT "${decoder_result}" STREQUAL "0") + message (FATAL_ERROR + "jt9 exited with ${decoder_result}\n" + "stdout:\n${decoder_stdout}\n" + "stderr:\n${decoder_stderr}") +endif () + +if (NOT "${decoder_stderr}" STREQUAL "") + message (FATAL_ERROR "jt9 wrote to stderr:\n${decoder_stderr}") +endif () + +string (FIND "${decoder_stdout}" "${EXPECTED_MESSAGE}" message_position) +string (FIND "${decoder_stdout}" "<DecodeFinished>" completion_position) +if (message_position LESS 0 OR completion_position LESS 0) + message (FATAL_ERROR + "jt9 did not complete the expected FT8 callback path\n" + "expected message: ${EXPECTED_MESSAGE}\n" + "actual:\n${decoder_stdout}\n" + "preserved output: ${actual_file}") +endif () diff --git a/tests/integration/jt9/verify_elf_stack.cmake b/tests/integration/jt9/verify_elf_stack.cmake new file mode 100644 index 00000000..30db932b --- /dev/null +++ b/tests/integration/jt9/verify_elf_stack.cmake @@ -0,0 +1,30 @@ +foreach (required_variable READELF EXECUTABLE) + if (NOT DEFINED ${required_variable} OR "${${required_variable}}" STREQUAL "") + message (FATAL_ERROR "${required_variable} is required") + endif () +endforeach () + +execute_process ( + COMMAND "${READELF}" -W -l "${EXECUTABLE}" + RESULT_VARIABLE readelf_result + OUTPUT_VARIABLE readelf_stdout + ERROR_VARIABLE readelf_stderr) + +if (NOT "${readelf_result}" STREQUAL "0") + message (FATAL_ERROR + "readelf exited with ${readelf_result}\n" + "stdout:\n${readelf_stdout}\n" + "stderr:\n${readelf_stderr}") +endif () + +string (REGEX MATCH "GNU_STACK[^\r\n]*" stack_header "${readelf_stdout}") +if (NOT stack_header) + message (FATAL_ERROR "${EXECUTABLE} has no GNU_STACK program header") +endif () + +if (stack_header MATCHES "[ \t]RWE([ \t]|$)" OR + NOT stack_header MATCHES "[ \t]RW([ \t]|$)") + message (FATAL_ERROR + "${EXECUTABLE} does not have a non-executable read/write stack:\n" + "${stack_header}") +endif () diff --git a/tests/integration/jt9/verify_jt4_12000_read_extent.cmake b/tests/integration/jt9/verify_jt4_12000_read_extent.cmake new file mode 100644 index 00000000..7011cc39 --- /dev/null +++ b/tests/integration/jt9/verify_jt4_12000_read_extent.cmake @@ -0,0 +1,67 @@ +foreach (required_variable JT9 JT4SIM WORK_DIR) + if (NOT DEFINED ${required_variable} OR "${${required_variable}}" STREQUAL "") + message (FATAL_ERROR "${required_variable} is required") + endif () +endforeach () + +file (MAKE_DIRECTORY "${WORK_DIR}") +execute_process ( + COMMAND "${JT4SIM}" "G3WDG OK1KIR RRR" F 1 0 0 1 99 + WORKING_DIRECTORY "${WORK_DIR}" + RESULT_VARIABLE simulator_result + OUTPUT_QUIET + ERROR_VARIABLE simulator_stderr) +if (NOT "${simulator_result}" STREQUAL "0") + message (FATAL_ERROR + "jt4sim exited with ${simulator_result}\n${simulator_stderr}") +endif () + +set (full_wav "${WORK_DIR}/000000_0001.wav") +set (truncated_wav "${WORK_DIR}/000000_0001_truncated.wav") +# Keep enough samples to distinguish a complete JT4 read from premature termination. +set (truncate_script [=[ +import struct +import sys + +sample_count = 580000 +file_size = 44 + 2 * sample_count +with open(sys.argv[1], "rb") as source_file: + wav_data = bytearray(source_file.read(file_size)) +if len(wav_data) != file_size: + raise RuntimeError("generated JT4 WAV is too short") +struct.pack_into("<I", wav_data, 4, file_size - 8) +struct.pack_into("<I", wav_data, 40, 2 * sample_count) +with open(sys.argv[2], "wb") as truncated_file: + truncated_file.write(wav_data) +]=]) +execute_process ( + COMMAND python3 -c "${truncate_script}" "${full_wav}" "${truncated_wav}" + RESULT_VARIABLE truncate_result + OUTPUT_QUIET + ERROR_VARIABLE truncate_stderr) +if (NOT "${truncate_result}" STREQUAL "0") + message (FATAL_ERROR "Failed to create truncated JT4 WAV\n${truncate_stderr}") +endif () + +execute_process ( + COMMAND "${JT9}" + -a "${WORK_DIR}" + -t "${WORK_DIR}" + --jt4 -b F -f 1000 -d 3 + "${truncated_wav}" + WORKING_DIRECTORY "${WORK_DIR}" + RESULT_VARIABLE decoder_result + OUTPUT_VARIABLE decoder_stdout + ERROR_VARIABLE decoder_stderr) +if (NOT "${decoder_result}" STREQUAL "0") + message (FATAL_ERROR + "jt9 exited with ${decoder_result}\n" + "stdout:\n${decoder_stdout}\n" + "stderr:\n${decoder_stderr}") +endif () +if (NOT "${decoder_stdout}" MATCHES "EOF on input file") + message (FATAL_ERROR + "jt9 did not read beyond the obsolete 570240-sample cutoff\n" + "stdout:\n${decoder_stdout}\n" + "stderr:\n${decoder_stderr}") +endif () diff --git a/tests/integration/jtty/live_audio.expected.txt b/tests/integration/jtty/live_audio.expected.txt new file mode 100644 index 00000000..7dbc5165 --- /dev/null +++ b/tests/integration/jtty/live_audio.expected.txt @@ -0,0 +1 @@ +CQ TEST DE KA1ABC LIVE AUDIO SMOKE TEST diff --git a/tests/integration/jtty/run_live_audio.cmake b/tests/integration/jtty/run_live_audio.cmake new file mode 100644 index 00000000..1dcbd7a2 --- /dev/null +++ b/tests/integration/jtty/run_live_audio.cmake @@ -0,0 +1,66 @@ +foreach (required_variable SJTTY WSJTX WORK_DIR EXPECTED) + if (NOT DEFINED ${required_variable} OR "${${required_variable}}" STREQUAL "") + message (FATAL_ERROR "${required_variable} is required") + endif () +endforeach () + +set (ipc_dir "${WORK_DIR}-ipc") +file (REMOVE_RECURSE "${WORK_DIR}") +file (MAKE_DIRECTORY + "${WORK_DIR}/config" + "${WORK_DIR}/data" + "${WORK_DIR}/cache" + "${ipc_dir}") + +execute_process ( + COMMAND "${SJTTY}" + "CQ TEST DE KA1ABC LIVE AUDIO SMOKE TEST" + 1500 0.25 AW 0 384 1 99 + WORKING_DIRECTORY "${WORK_DIR}" + RESULT_VARIABLE generator_result + OUTPUT_VARIABLE generator_stdout + ERROR_VARIABLE generator_stderr) +if (NOT generator_result STREQUAL "0") + message (FATAL_ERROR + "sjtty failed with exit code ${generator_result}\n" + "stdout:\n${generator_stdout}\n" + "stderr:\n${generator_stderr}") +endif () + +set (fixture "${WORK_DIR}/000000_000001.wav") +if (NOT EXISTS "${fixture}") + message (FATAL_ERROR "sjtty did not create ${fixture}") +endif () +file (SIZE "${fixture}" fixture_size) +if (fixture_size LESS 45) + message (FATAL_ERROR "sjtty created a malformed ${fixture_size}-byte WAV") +endif () + +set (wsjtx_environment + "XDG_CONFIG_HOME=${WORK_DIR}/config" + "XDG_DATA_HOME=${WORK_DIR}/data" + "XDG_CACHE_HOME=${WORK_DIR}/cache" + "WSJT_QMAP_SHARED_MEMORY_KEY=mem_qmap-test_wsjtx_live_audio_jtty") +if (NOT APPLE) + list (APPEND wsjtx_environment "TMPDIR=${ipc_dir}") +endif () + +execute_process ( + COMMAND "${CMAKE_COMMAND}" -E env + ${wsjtx_environment} + "${WSJTX}" + --jtty-live-audio-test "${fixture}" + --jtty-live-audio-expected "${EXPECTED}" + --rig-name CTEST-LIVE-AUDIO-JTTY + WORKING_DIRECTORY "${WORK_DIR}" + RESULT_VARIABLE wsjtx_result + OUTPUT_VARIABLE wsjtx_stdout + ERROR_VARIABLE wsjtx_stderr) +if (NOT wsjtx_result STREQUAL "0") + message (FATAL_ERROR + "WSJT-X JTTY live-audio smoke test failed with exit code ${wsjtx_result}\n" + "stdout:\n${wsjtx_stdout}\n" + "stderr:\n${wsjtx_stderr}") +endif () + +message (STATUS "WSJT-X JTTY live-audio smoke test passed") diff --git a/tests/integration/jtty/run_tx_loopback.cmake b/tests/integration/jtty/run_tx_loopback.cmake new file mode 100644 index 00000000..cb6c0494 --- /dev/null +++ b/tests/integration/jtty/run_tx_loopback.cmake @@ -0,0 +1,84 @@ +foreach (required_variable WSJTX WORK_DIR EXPECTED) + if (NOT DEFINED ${required_variable} OR "${${required_variable}}" STREQUAL "") + message (FATAL_ERROR "${required_variable} is required") + endif () +endforeach () + +set (ipc_dir "${WORK_DIR}-ipc") +file (REMOVE_RECURSE "${WORK_DIR}") +file (MAKE_DIRECTORY + "${WORK_DIR}/capture/config" + "${WORK_DIR}/capture/data" + "${WORK_DIR}/capture/cache" + "${WORK_DIR}/replay/config" + "${WORK_DIR}/replay/data" + "${WORK_DIR}/replay/cache" + "${ipc_dir}/capture" + "${ipc_dir}/replay") + +set (capture "${WORK_DIR}/jtty-tx-loopback.wav") +set (capture_environment + "XDG_CONFIG_HOME=${WORK_DIR}/capture/config" + "XDG_DATA_HOME=${WORK_DIR}/capture/data" + "XDG_CACHE_HOME=${WORK_DIR}/capture/cache" + "WSJT_QMAP_SHARED_MEMORY_KEY=mem_qmap-test_wsjtx_jtty_tx_loopback") +set (replay_environment + "XDG_CONFIG_HOME=${WORK_DIR}/replay/config" + "XDG_DATA_HOME=${WORK_DIR}/replay/data" + "XDG_CACHE_HOME=${WORK_DIR}/replay/cache" + "WSJT_QMAP_SHARED_MEMORY_KEY=mem_qmap-test_wsjtx_jtty_tx_loopback") +if (NOT APPLE) + list (APPEND capture_environment "TMPDIR=${ipc_dir}/capture") + list (APPEND replay_environment "TMPDIR=${ipc_dir}/replay") +endif () + +execute_process ( + COMMAND "${CMAKE_COMMAND}" -E env + ${capture_environment} + "${WSJTX}" + --jtty-tx-loopback-test "${capture}" + --rig-name CTEST-JTTY-TX-CAPTURE + WORKING_DIRECTORY "${WORK_DIR}/capture" + RESULT_VARIABLE capture_result + OUTPUT_VARIABLE capture_stdout + ERROR_VARIABLE capture_stderr) +if (NOT capture_result STREQUAL "0") + message (FATAL_ERROR + "WSJT-X JTTY transmit capture failed with exit code ${capture_result}\n" + "stdout:\n${capture_stdout}\n" + "stderr:\n${capture_stderr}") +endif () + +if (NOT EXISTS "${capture}") + message (FATAL_ERROR "WSJT-X did not create ${capture}") +endif () +file (SIZE "${capture}" capture_size) +if (capture_size LESS 45) + message (FATAL_ERROR "WSJT-X created a malformed ${capture_size}-byte WAV") +endif () +file (READ "${capture}" capture_header OFFSET 0 LIMIT 28 HEX) +if (NOT capture_header MATCHES + "^52494646........57415645666d7420100000000100010080bb0000$") + message (FATAL_ERROR + "WSJT-X capture is not a 48 kHz mono PCM RIFF/WAVE file: ${capture_header}") +endif () + +execute_process ( + COMMAND "${CMAKE_COMMAND}" -E env + ${replay_environment} + "${WSJTX}" + --jtty-live-audio-test "${capture}" + --jtty-live-audio-expected "${EXPECTED}" + --rig-name CTEST-JTTY-TX-REPLAY + WORKING_DIRECTORY "${WORK_DIR}/replay" + RESULT_VARIABLE replay_result + OUTPUT_VARIABLE replay_stdout + ERROR_VARIABLE replay_stderr) +if (NOT replay_result STREQUAL "0") + message (FATAL_ERROR + "WSJT-X JTTY transmit replay failed with exit code ${replay_result}\n" + "stdout:\n${replay_stdout}\n" + "stderr:\n${replay_stderr}") +endif () + +message (STATUS "WSJT-X JTTY transmit loopback smoke test passed") diff --git a/tests/integration/jtty/tx_loopback.expected.txt b/tests/integration/jtty/tx_loopback.expected.txt new file mode 100644 index 00000000..3761f4f4 --- /dev/null +++ b/tests/integration/jtty/tx_loopback.expected.txt @@ -0,0 +1,2 @@ +WB9XYZ 599 0123 +WB9XYZ TU CQ KA1ABC CQ diff --git a/tests/integration/run-live-audio-parallel-experiment.sh b/tests/integration/run-live-audio-parallel-experiment.sh new file mode 100755 index 00000000..12079251 --- /dev/null +++ b/tests/integration/run-live-audio-parallel-experiment.sh @@ -0,0 +1,194 @@ +#!/usr/bin/env bash +# Local soak for overlapping GUI/audio smokes and non-GUI canaries. +# Not used by CI. +# +# --smoke checks the harness only (no GUI tests). Use that before a long soak. +set -u +set -o pipefail + +usage () { + cat <<'EOF' +Usage: run-live-audio-parallel-experiment.sh --build-dir DIR [options] + + --phase 1|2|3|all Default: all + --repeats-soak N Full-suite passes per soak (serial then -j3). Default: 20 + --repeats-pair N Full-suite passes per pairwise set. Default: 10 + --smoke Validate the script and ctest listing; do not run GUI tests +EOF +} + +build_dir="" +phase="all" +repeats_soak=20 +repeats_pair=10 +smoke=0 +audio_re='test_wsjtx_live_audio_ft8|test_wsjtx_live_audio_jtty|test_wsjtx_jtty_tx_loopback|test_wsjtx_ft8_tx_loopback' +gui_audio_re="test_wsjtx_startup|${audio_re}" +canary_re='test_q65_decode_pipeline|test_tci_transceiver_characterization' +experiment_re="${gui_audio_re}|${canary_re}" +experiment_tests=( + test_wsjtx_startup + test_wsjtx_live_audio_ft8 + test_wsjtx_live_audio_jtty + test_wsjtx_jtty_tx_loopback + test_wsjtx_ft8_tx_loopback + test_q65_decode_pipeline + test_tci_transceiver_characterization +) +xvfb=(xvfb-run -a -s '-screen 0 1280x1024x24') +failures=0 +ran=0 + +while [[ $# -gt 0 ]]; do + case "$1" in + --build-dir) build_dir=$2; shift 2 ;; + --phase) phase=$2; shift 2 ;; + --repeats-soak) repeats_soak=$2; shift 2 ;; + --repeats-pair) repeats_pair=$2; shift 2 ;; + --smoke) smoke=1; shift ;; + -h|--help) usage; exit 0 ;; + *) echo "unknown argument: $1" >&2; usage; exit 2 ;; + esac +done + +if [[ -z "${build_dir}" || ! -d "${build_dir}" ]]; then + echo "--build-dir must be an existing CMake build directory" >&2 + exit 2 +fi + +if ! command -v xvfb-run >/dev/null 2>&1; then + echo "xvfb-run is required" >&2 + exit 2 +fi + +if ! command -v ctest >/dev/null 2>&1; then + echo "ctest is required" >&2 + exit 2 +fi + +listed=$(ctest --test-dir "${build_dir}" -N -R "${experiment_re}" | awk '/Test #/{print $3}') +for expected in "${experiment_tests[@]}"; do + if [[ $'\n'"${listed}"$'\n' != *$'\n'"${expected}"$'\n'* ]]; then + echo "ctest did not list ${expected}:" >&2 + echo "${listed}" >&2 + exit 2 + fi +done +listed_count=$(printf '%s\n' "${listed}" | awk 'NF { count++ } END { print count + 0 }') +if [[ "${listed_count}" -ne "${#experiment_tests[@]}" ]]; then + echo "ctest listed unexpected experiment tests:" >&2 + echo "${listed}" >&2 + exit 2 +fi + +if [[ "${smoke}" -eq 1 ]]; then + echo "smoke: xvfb-run and ctest listing ok" + echo "smoke: tests:" + printf ' %s\n' "${experiment_tests[@]}" + echo "smoke: would run phase=${phase} soak=${repeats_soak} pair=${repeats_pair}" + echo "======== 3 load start/stop ========" + pids=() + for ((i = 0; i < 2; i++)); do + sleep 30 & + pids+=($!) + done + kill "${pids[@]}" 2>/dev/null || true + wait "${pids[@]}" 2>/dev/null || true + echo "smoke: harness ok" + exit 0 +fi + +run_ctest () { + local label=$1 + shift + echo + echo "======== ${label} ========" + printf '+' + printf ' %q' "${xvfb[@]}" ctest --test-dir "${build_dir}" "$@" + echo + ran=$((ran + 1)) + if "${xvfb[@]}" ctest --test-dir "${build_dir}" "$@"; then + echo "RESULT ${label}: pass" + else + echo "RESULT ${label}: fail (exit $?)" + failures=$((failures + 1)) + fi +} + +# Repeat whole matching suites N times. Do not use --repeat-until-fail: +# one flaky FT8 case must not skip later phases or later passes. +run_suite_repeats () { + local label=$1 + local n=$2 + shift 2 + local i + for ((i = 1; i <= n; i++)); do + run_ctest "${label} pass ${i}/${n}" "$@" + done +} + +phase1 () { + run_suite_repeats "1 serial" "${repeats_soak}" \ + -R "${experiment_re}" --output-on-failure + run_suite_repeats "1 parallel -j3" "${repeats_soak}" \ + -j3 -R "${experiment_re}" --output-on-failure +} + +phase2 () { + run_suite_repeats "2 FT8 live || JTTY live" "${repeats_pair}" \ + -j2 -R 'test_wsjtx_live_audio_ft8|test_wsjtx_live_audio_jtty' \ + --output-on-failure + run_suite_repeats "2 FT8 live || JTTY TX loopback" "${repeats_pair}" \ + -j2 -R 'test_wsjtx_live_audio_ft8|test_wsjtx_jtty_tx_loopback' \ + --output-on-failure + run_suite_repeats "2 JTTY live || JTTY TX loopback" "${repeats_pair}" \ + -j2 -R 'test_wsjtx_live_audio_jtty|test_wsjtx_jtty_tx_loopback' \ + --output-on-failure + run_suite_repeats "2 FT8 TX || FT8 live" "${repeats_pair}" \ + -j3 -R 'test_wsjtx_ft8_tx_loopback|test_wsjtx_live_audio_ft8' \ + --output-on-failure + run_suite_repeats "2 FT8 TX || JTTY live" "${repeats_pair}" \ + -j3 -R 'test_wsjtx_ft8_tx_loopback|test_wsjtx_live_audio_jtty' \ + --output-on-failure + run_suite_repeats "2 FT8 TX || JTTY TX loopback" "${repeats_pair}" \ + -j3 -R 'test_wsjtx_ft8_tx_loopback|test_wsjtx_jtty_tx_loopback' \ + --output-on-failure + run_suite_repeats "2 FT8 TX || canaries" "${repeats_pair}" \ + -j3 -R "test_wsjtx_ft8_tx_loopback|${canary_re}" \ + --output-on-failure + run_suite_repeats "2 startup || audio tests -j3" "${repeats_pair}" \ + -j3 -R "${gui_audio_re}" --output-on-failure + run_suite_repeats "2 all four audio tests -j3" "${repeats_pair}" \ + -j3 -R "${audio_re}" --output-on-failure +} + +phase3 () { + echo + echo "======== 3 contended: background gzip load ========" + local pids=() + local i + for ((i = 0; i < 4; i++)); do + (while true; do dd if=/dev/zero bs=1M count=64 2>/dev/null | gzip -1 >/dev/null; done) & + pids+=($!) + done + run_suite_repeats "3 parallel -j3 under load" "${repeats_pair}" \ + -j3 -R "${experiment_re}" --output-on-failure + kill "${pids[@]}" 2>/dev/null || true + wait "${pids[@]}" 2>/dev/null || true +} + +case "${phase}" in + 1) phase1 ;; + 2) phase2 ;; + 3) phase3 ;; + all) phase1; phase2; phase3 ;; + *) echo "phase must be 1, 2, 3, or all" >&2; exit 2 ;; +esac + +echo +echo "======== summary ========" +echo "suites_run=${ran} suites_failed=${failures}" +if [[ "${failures}" -ne 0 ]]; then + exit 1 +fi +exit 0 diff --git a/tests/integration/wsprd/compare_wsprd_output.cmake b/tests/integration/wsprd/compare_wsprd_output.cmake new file mode 100644 index 00000000..63e37ed0 --- /dev/null +++ b/tests/integration/wsprd/compare_wsprd_output.cmake @@ -0,0 +1,41 @@ +foreach (required_variable WSPRD SAMPLE EXPECTED WORK_DIR) + if (NOT DEFINED ${required_variable} OR "${${required_variable}}" STREQUAL "") + message (FATAL_ERROR "${required_variable} is required") + endif () +endforeach () + +file (MAKE_DIRECTORY "${WORK_DIR}") +set (actual_file "${WORK_DIR}/actual.txt") +set (stderr_file "${WORK_DIR}/stderr.txt") + +execute_process ( + COMMAND "${WSPRD}" + -a "${WORK_DIR}" + "${SAMPLE}" + WORKING_DIRECTORY "${WORK_DIR}" + RESULT_VARIABLE decoder_result + OUTPUT_VARIABLE decoder_stdout + ERROR_VARIABLE decoder_stderr) + +file (WRITE "${actual_file}" "${decoder_stdout}") +file (WRITE "${stderr_file}" "${decoder_stderr}") + +if (NOT "${decoder_result}" STREQUAL "0") + message (FATAL_ERROR + "wsprd exited with ${decoder_result}\n" + "stdout:\n${decoder_stdout}\n" + "stderr:\n${decoder_stderr}") +endif () + +if (NOT "${decoder_stderr}" STREQUAL "") + message (FATAL_ERROR "wsprd wrote to stderr:\n${decoder_stderr}") +endif () + +file (READ "${EXPECTED}" expected_output) +if (NOT "${decoder_stdout}" STREQUAL "${expected_output}") + message (FATAL_ERROR + "wsprd output differs from ${EXPECTED}\n" + "expected:\n${expected_output}\n" + "actual:\n${decoder_stdout}\n" + "preserved output: ${actual_file}") +endif () |
