# this is a trick to avoid to more complication # because configure_file() is done a configuration time set(CUSTOM_TEST_BINARY_DIR "${CMAKE_BINARY_DIR}/test") set(GEN_PACKETS_BIN "${CMAKE_BINARY_DIR}/src/gen_packets${CMAKE_EXECUTABLE_SUFFIX}") set(ATEST_BIN "${CMAKE_BINARY_DIR}/src/atest${CMAKE_EXECUTABLE_SUFFIX}") if(WIN32) set(CUSTOM_SCRIPT_SUFFIX ".bat") else() set(CUSTOM_SCRIPT_SUFFIX "") endif() set(TEST_CHECK-MODEM1200_FILE "check-modem1200") set(TEST_CHECK-MODEM300_FILE "check-modem300") set(TEST_CHECK-MODEM9600_FILE "check-modem9600") set(TEST_CHECK-MODEM19200_FILE "check-modem19200") set(TEST_CHECK-MODEM2400-a_FILE "check-modem2400-a") set(TEST_CHECK-MODEM2400-b_FILE "check-modem2400-b") set(TEST_CHECK-MODEM2400-g_FILE "check-modem2400-g") set(TEST_CHECK-MODEM4800_FILE "check-modem4800") # generate the scripts that run the tests configure_file( "${CUSTOM_TEST_SCRIPTS_DIR}/${TEST_CHECK-MODEM1200_FILE}" "${CUSTOM_TEST_BINARY_DIR}/${TEST_CHECK-MODEM1200_FILE}${CUSTOM_SCRIPT_SUFFIX}" @ONLY ) configure_file( "${CUSTOM_TEST_SCRIPTS_DIR}/${TEST_CHECK-MODEM300_FILE}" "${CUSTOM_TEST_BINARY_DIR}${CUSTOM_SCRIPT_SUFFIX}" @ONLY ) configure_file( "${CUSTOM_TEST_SCRIPTS_DIR}/${TEST_CHECK-MODEM9600_FILE}" "${CUSTOM_TEST_BINARY_DIR}/${TEST_CHECK-MODEM9600_FILE}${CUSTOM_SCRIPT_SUFFIX}" @ONLY ) configure_file( "${CUSTOM_TEST_SCRIPTS_DIR}/${TEST_CHECK-MODEM19200_FILE}" "${CUSTOM_TEST_BINARY_DIR}/${TEST_CHECK-MODEM19200_FILE}${CUSTOM_SCRIPT_SUFFIX}" @ONLY ) configure_file( "${CUSTOM_TEST_SCRIPTS_DIR}/${TEST_CHECK-MODEM2400-a_FILE}" "${CUSTOM_TEST_BINARY_DIR}/${TEST_CHECK-MODEM2400-a_FILE}${CUSTOM_SCRIPT_SUFFIX}" @ONLY ) configure_file( "${CUSTOM_TEST_SCRIPTS_DIR}/${TEST_CHECK-MODEM2400-b_FILE}" "${CUSTOM_TEST_BINARY_DIR}/${TEST_CHECK-MODEM2400-b_FILE}${CUSTOM_SCRIPT_SUFFIX}" @ONLY ) configure_file( "${CUSTOM_TEST_SCRIPTS_DIR}/${TEST_CHECK-MODEM2400-g_FILE}" "${CUSTOM_TEST_BINARY_DIR}/${TEST_CHECK-MODEM2400-g_FILE}${CUSTOM_SCRIPT_SUFFIX}" @ONLY ) configure_file( "${CUSTOM_TEST_SCRIPTS_DIR}/${TEST_CHECK-MODEM4800_FILE}" "${CUSTOM_TEST_BINARY_DIR}/${TEST_CHECK-MODEM4800_FILE}${CUSTOM_SCRIPT_SUFFIX}" @ONLY ) # global includes # not ideal but not so slow # otherwise use target_include_directories include_directories( ${CUSTOM_SRC_DIR} ${GPSD_INCLUDE_DIRS} ${HAMLIB_INCLUDE_DIRS} ${ALSA_INCLUDE_DIRS} ${UDEV_INCLUDE_DIRS} ${PORTAUDIO_INCLUDE_DIRS} ${CUSTOM_GEOTRANZ_DIR} ${CMAKE_BINARY_DIR}/src ) # Unit test for demodulators list(APPEND atest9_SOURCES ${CUSTOM_SRC_DIR}/atest.c ${CUSTOM_SRC_DIR}/demod.c ${CUSTOM_SRC_DIR}/dsp.c ${CUSTOM_SRC_DIR}/demod_afsk.c ${CUSTOM_SRC_DIR}/demod_psk.c ${CUSTOM_SRC_DIR}/demod_9600.c ${CUSTOM_SRC_DIR}/hdlc_rec.c ${CUSTOM_SRC_DIR}/hdlc_rec2.c ${CUSTOM_SRC_DIR}/multi_modem.c ${CUSTOM_SRC_DIR}/rrbb.c ${CUSTOM_SRC_DIR}/fcs_calc.c ${CUSTOM_SRC_DIR}/ax25_pad.c ${CUSTOM_SRC_DIR}/decode_aprs.c ${CUSTOM_SRC_DIR}/dwgpsnmea.c ${CUSTOM_SRC_DIR}/dwgps.c ${CUSTOM_SRC_DIR}/dwgpsd.c ${CUSTOM_SRC_DIR}/serial_port.c ${CUSTOM_SRC_DIR}/latlong.c ${CUSTOM_SRC_DIR}/symbols.c ${CUSTOM_SRC_DIR}/textcolor.c ${CUSTOM_SRC_DIR}/telemetry.c ${CUSTOM_SRC_DIR}/dtime_now.c ${CUSTOM_SRC_DIR}/tt_text.c ) add_executable(atest9 ${atest9_SOURCES} ) add_dependencies(atest9 gen_fff) target_link_libraries(atest9 ${MISC_LIBRARIES} ${GPSD_LIBRARIES} Threads::Threads ) # Unit test for inner digipeater algorithm list(APPEND dtest_SOURCES ${CUSTOM_SRC_DIR}/digipeater.c ${CUSTOM_SRC_DIR}/dedupe.c ${CUSTOM_SRC_DIR}/pfilter.c ${CUSTOM_SRC_DIR}/ax25_pad.c ${CUSTOM_SRC_DIR}/fcs_calc.c ${CUSTOM_SRC_DIR}/tq.c ${CUSTOM_SRC_DIR}/textcolor.c ${CUSTOM_SRC_DIR}/decode_aprs.c ${CUSTOM_SRC_DIR}/dwgpsnmea.c ${CUSTOM_SRC_DIR}/dwgps.c ${CUSTOM_SRC_DIR}/dwgpsd.c ${CUSTOM_SRC_DIR}/serial_port.c ${CUSTOM_SRC_DIR}/latlong.c ${CUSTOM_SRC_DIR}/telemetry.c ${CUSTOM_SRC_DIR}/symbols.c ${CUSTOM_SRC_DIR}/tt_text.c ) add_executable(dtest ${dtest_SOURCES} ) set_target_properties(dtest PROPERTIES COMPILE_FLAGS "-DDIGITEST" ) target_link_libraries(dtest ${MISC_LIBRARIES} ${REGEX_LIBRARIES} ${GPSD_LIBRARIES} Threads::Threads ) # Unit test for APRStt tone seqence parsing. list(APPEND ttest_SOURCES ${CUSTOM_SRC_DIR}/aprs_tt.c ${CUSTOM_SRC_DIR}/tt_text.c ${CUSTOM_SRC_DIR}/latlong.c ${CUSTOM_SRC_DIR}/textcolor.c ) add_executable(ttest ${ttest_SOURCES} ) set_target_properties(ttest PROPERTIES COMPILE_FLAGS "-DTT_MAIN" ) target_link_libraries(ttest ${MISC_LIBRARIES} ${GEOTRANZ_LIBRARIES} ) # Unit test for APRStt tone sequence / text conversions. list(APPEND tttexttest_SOURCES ${CUSTOM_SRC_DIR}/tt_text.c ${CUSTOM_SRC_DIR}/textcolor.c ) add_executable(tttexttest ${tttexttest_SOURCES} ) set_target_properties(tttexttest PROPERTIES COMPILE_FLAGS "-DTTT_TEST" ) target_link_libraries(tttexttest ${MISC_LIBRARIES} ) # Unit test for Packet Filtering. list(APPEND pftest_SOURCES ${CUSTOM_SRC_DIR}/pfilter.c ${CUSTOM_SRC_DIR}/ax25_pad.c ${CUSTOM_SRC_DIR}/textcolor.c ${CUSTOM_SRC_DIR}/fcs_calc.c ${CUSTOM_SRC_DIR}/decode_aprs.c ${CUSTOM_SRC_DIR}/dwgpsnmea.c ${CUSTOM_SRC_DIR}/dwgps.c ${CUSTOM_SRC_DIR}/dwgpsd.c ${CUSTOM_SRC_DIR}/serial_port.c ${CUSTOM_SRC_DIR}/latlong.c ${CUSTOM_SRC_DIR}/symbols.c ${CUSTOM_SRC_DIR}/telemetry.c ${CUSTOM_SRC_DIR}/tt_text.c ) add_executable(pftest ${pftest_SOURCES} ) set_target_properties(pftest PROPERTIES COMPILE_FLAGS "-DPFTEST" ) target_link_libraries(pftest ${MISC_LIBRARIES} ${REGEX_LIBRARIES} ${GPSD_LIBRARIES} Threads::Threads ) # Unit test for telemetry decoding. list(APPEND tlmtest_SOURCES ${CUSTOM_SRC_DIR}/telemetry.c ${CUSTOM_SRC_DIR}/ax25_pad.c ${CUSTOM_SRC_DIR}/fcs_calc.c ${CUSTOM_SRC_DIR}/textcolor.c ) add_executable(tlmtest ${tlmtest_SOURCES} ) set_target_properties(tlmtest PROPERTIES COMPILE_FLAGS "-DTEST" ) target_link_libraries(tlmtest ${MISC_LIBRARIES} ${REGEX_LIBRARIES} ) # Unit test for location coordinate conversion. list(APPEND lltest_SOURCES ${CUSTOM_SRC_DIR}/latlong.c ${CUSTOM_SRC_DIR}/textcolor.c ) add_executable(lltest ${lltest_SOURCES} ) set_target_properties(lltest PROPERTIES COMPILE_FLAGS "-DLLTEST" ) target_link_libraries(lltest ${MISC_LIBRARIES} ) # Unit test for encoding position & object report. list(APPEND enctest_SOURCES ${CUSTOM_SRC_DIR}/encode_aprs.c ${CUSTOM_SRC_DIR}/latlong.c ${CUSTOM_SRC_DIR}/textcolor.c ) add_executable(enctest ${enctest_SOURCES} ) set_target_properties(enctest PROPERTIES COMPILE_FLAGS "-DEN_MAIN" ) target_link_libraries(enctest ${MISC_LIBRARIES} ) # Unit test for KISS encapsulation. list(APPEND kisstest_SOURCES ${CUSTOM_SRC_DIR}/kiss_frame.c ) add_executable(kisstest ${kisstest_SOURCES} ) set_target_properties(kisstest PROPERTIES COMPILE_FLAGS "-DKISSTEST" ) # Unit test for constructing frames besides UI. list(APPEND pad2test_SOURCES ${CUSTOM_SRC_DIR}/ax25_pad2.c ${CUSTOM_SRC_DIR}/ax25_pad.c ${CUSTOM_SRC_DIR}/fcs_calc.c ${CUSTOM_SRC_DIR}/textcolor.c ) add_executable(pad2test ${pad2test_SOURCES} ) set_target_properties(pad2test PROPERTIES COMPILE_FLAGS "-DPAD2TEST" ) target_link_libraries(pad2test ${MISC_LIBRARIES} ${REGEX_LIBRARIES} ) # Unit Test for XID frame encode/decode. list(APPEND xidtest_SOURCES ${CUSTOM_SRC_DIR}/xid.c ${CUSTOM_SRC_DIR}/textcolor.c ) add_executable(xidtest ${xidtest_SOURCES} ) set_target_properties(xidtest PROPERTIES COMPILE_FLAGS "-DXIDTEST" ) target_link_libraries(xidtest ${MISC_LIBRARIES} ) # Unit Test for DTMF encode/decode. list(APPEND dtmftest_SOURCES ${CUSTOM_SRC_DIR}/dtmf.c ${CUSTOM_SRC_DIR}/textcolor.c ) add_executable(dtmftest ${dtmftest_SOURCES} ) set_target_properties(dtmftest PROPERTIES COMPILE_FLAGS "-DDTMF_TEST" ) # doing ctest on previous programs add_test(dtest dtest) add_test(ttest ttest) add_test(tttexttest tttexttest) add_test(pftest pftest) add_test(tlmtest tlmtest) add_test(lltest lltest) add_test(enctest enctest) add_test(kisstest kisstest) add_test(pad2test pad2test) add_test(xidtest xidtest) add_test(dtmftest dtmftest) add_test(check-modem1200 "${CUSTOM_TEST_BINARY_DIR}/${TEST_CHECK-MODEM1200_FILE}${CUSTOM_SCRIPT_SUFFIX}") add_test(check-modem300 "${CUSTOM_TEST_BINARY_DIR}/${TEST_CHECK-MODEM300_FILE}${CUSTOM_SCRIPT_SUFFIX}") add_test(check-modem9600 "${CUSTOM_TEST_BINARY_DIR}/${TEST_CHECK-MODEM9600_FILE}${CUSTOM_SCRIPT_SUFFIX}") add_test(check-modem19200 "${CUSTOM_TEST_BINARY_DIR}/${TEST_CHECK-MODEM19200_FILE}${CUSTOM_SCRIPT_SUFFIX}") add_test(check-modem2400-a "${CUSTOM_TEST_BINARY_DIR}/${TEST_CHECK-MODEM2400-a_FILE}${CUSTOM_SCRIPT_SUFFIX}") add_test(check-modem2400-b "${CUSTOM_TEST_BINARY_DIR}/${TEST_CHECK-MODEM2400-b_FILE}${CUSTOM_SCRIPT_SUFFIX}") add_test(check-modem2400-g "${CUSTOM_TEST_BINARY_DIR}/${TEST_CHECK-MODEM2400-g_FILE}${CUSTOM_SCRIPT_SUFFIX}") add_test(check-modem4800 "${CUSTOM_TEST_BINARY_DIR}/${TEST_CHECK-MODEM4800_FILE}${CUSTOM_SCRIPT_SUFFIX}") # TODO miss the audio file # ./atest9 -B 9600 ../walkabout9600.wav | grep "packets decoded in" >atest.out # ----------------------------- Manual tests and experiments --------------------------- if(OPTIONAL_TEST) # Unit test for IGate list(APPEND itest_SOURCES ${CUSTOM_SRC_DIR}/igate.c ${CUSTOM_SRC_DIR}/ax25_pad.c ${CUSTOM_SRC_DIR}/fcs_calc.c ${CUSTOM_SRC_DIR}/mheard.c ${CUSTOM_SRC_DIR}/pfilter.c ${CUSTOM_SRC_DIR}/telemetry.c ${CUSTOM_SRC_DIR}/decode_aprs.c ${CUSTOM_SRC_DIR}/dwgpsnmea.c ${CUSTOM_SRC_DIR}/dwgps.c ${CUSTOM_SRC_DIR}/dwgpsd.c ${CUSTOM_SRC_DIR}/serial_port.c ${CUSTOM_SRC_DIR}/textcolor.c ${CUSTOM_SRC_DIR}/dtime_now.c ${CUSTOM_SRC_DIR}/latlong.c ${CUSTOM_SRC_DIR}/tt_text.c ${CUSTOM_SRC_DIR}/symbols.c ) add_executable(itest ${itest_SOURCES} ) set_target_properties(itest PROPERTIES COMPILE_FLAGS "-DITEST" ) target_link_libraries(itest ${MISC_LIBRARIES} ${GPSD_LIBRARIES} Threads::Threads ) # For demodulator tweaking experiments. list(APPEND testagc_SOURCES ${CUSTOM_SRC_DIR}/atest.c ${CUSTOM_SRC_DIR}/demod.c ${CUSTOM_SRC_DIR}/dsp.c ${CUSTOM_SRC_DIR}/demod_afsk.c ${CUSTOM_SRC_DIR}/demod_psk.c ${CUSTOM_SRC_DIR}/demod_9600.c ${CUSTOM_SRC_DIR}/hdlc_rec.c ${CUSTOM_SRC_DIR}/hdlc_rec2.c ${CUSTOM_SRC_DIR}/multi_modem.c ${CUSTOM_SRC_DIR}/rrbb.c ${CUSTOM_SRC_DIR}/fcs_calc.c ${CUSTOM_SRC_DIR}/ax25_pad.c ${CUSTOM_SRC_DIR}/decode_aprs.c ${CUSTOM_SRC_DIR}/dwgpsnmea.c ${CUSTOM_SRC_DIR}/dwgps.c ${CUSTOM_SRC_DIR}/dwgpsd.c ${CUSTOM_SRC_DIR}/serial_port.c ${CUSTOM_SRC_DIR}/telemetry.c ${CUSTOM_SRC_DIR}/dtime_now.c ${CUSTOM_SRC_DIR}/latlong.c ${CUSTOM_SRC_DIR}/tt_text.c ${CUSTOM_SRC_DIR}/symbols.c ${CUSTOM_SRC_DIR}/textcolor.c ) add_executable(testagc ${testagc_SOURCES} ) add_dependencies(testagc gen_fff) target_link_libraries(testagc ${MISC_LIBRARIES} ${GPSD_LIBRARIES} Threads::Threads ) # Send GPS location to KISS TNC each second. list(APPEND walk96_SOURCES ${CUSTOM_SRC_DIR}/walk96.c ${CUSTOM_SRC_DIR}/dwgps.c ${CUSTOM_SRC_DIR}/dwgpsnmea.c ${CUSTOM_SRC_DIR}/dwgpsd.c ${CUSTOM_SRC_DIR}/kiss_frame.c ${CUSTOM_SRC_DIR}/latlong.c ${CUSTOM_SRC_DIR}/encode_aprs.c ${CUSTOM_SRC_DIR}/serial_port.c ${CUSTOM_SRC_DIR}/textcolor.c ${CUSTOM_SRC_DIR}/ax25_pad.c ${CUSTOM_SRC_DIR}/fcs_calc.c ${CUSTOM_SRC_DIR}/xmit.c ${CUSTOM_SRC_DIR}/xid.c ${CUSTOM_SRC_DIR}/hdlc_send.c ${CUSTOM_SRC_DIR}/gen_tone.c ${CUSTOM_SRC_DIR}/ptt.c ${CUSTOM_SRC_DIR}/tq.c ${CUSTOM_SRC_DIR}/hdlc_rec.c ${CUSTOM_SRC_DIR}/hdlc_rec2.c ${CUSTOM_SRC_DIR}/rrbb.c ${CUSTOM_SRC_DIR}/dsp.c ${CUSTOM_SRC_DIR}/multi_modem.c ${CUSTOM_SRC_DIR}/demod.c ${CUSTOM_SRC_DIR}/demod_afsk.c ${CUSTOM_SRC_DIR}/demod_psk.c ${CUSTOM_SRC_DIR}/demod_9600.c ${CUSTOM_SRC_DIR}/rdq.c ${CUSTOM_SRC_DIR}/server.c ${CUSTOM_SRC_DIR}/morse.c ${CUSTOM_SRC_DIR}/dtmf.c ${CUSTOM_SRC_DIR}/audio_stats.c ${CUSTOM_SRC_DIR}/dtime_now.c ${CUSTOM_SRC_DIR}/dlq.c ) if(LINUX) list(APPEND walk96_SOURCES ${CUSTOM_SRC_DIR}/audio.c ) if(UDEV_FOUND) list(APPEND walk96_SOURCES ${CUSTOM_SRC_DIR}/cm108.c ) endif() elseif(WIN32) # windows list(APPEND walk96_SOURCES ${CUSTOM_SRC_DIR}/audio_win.c ) else() # macOS freebsd openbsd list(APPEND walk96_SOURCES ${CUSTOM_SRC_DIR}/audio_portaudio.c ) endif() add_executable(walk96 ${walk96_SOURCES} ) set_target_properties(walk96 PROPERTIES COMPILE_FLAGS "-DWALK96" ) target_link_libraries(walk96 ${MISC_LIBRARIES} ${REGEX_LIBRARIES} ${GPSD_LIBRARIES} ${HAMLIB_LIBRARIES} ${ALSA_LIBRARIES} ${PORTAUDIO_LIBRARIES} ${UDEV_LIBRARIES} Threads::Threads ) # TODO miss the audio file # testagc # ./atest -P H+ -F 0 ../01_Track_1.wav ../02_Track_2.wav | grep "packets decoded in" >atest.out # testagc3 # ./gen_packets -B 300 -n 100 -o noisy3.wav # ./atest3 -B 300 -P D -D 3 noisy3.wav | grep "packets decoded in" >atest.out # testagc96 # ./gen_packets -B 9600 -n 100 -o noisy96.wav # ./atest96 -B 9600 ../walkabout9600c.wav noisy96.wav zzz16.wav zzz16.wav zzz16.wav zzz8.wav zzz8.wav zzz8.wav | grep "packets decoded in" >atest.out # testagc24 # ./atest24 -B 2400 test2400.wav | grep "packets decoded in" >atest.out # testagc24mfj # ./atest24mfj -F 1 -B 2400 ../ref-doc/MFJ-2400-PSK/2k4_short.wav # testagc48 # ./atest48 -B 4800 test4800.wav | grep "packets decoded in" >atest.out endif() # OPTIONAL_TEST