forked from 0815employee/codec2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
1410 lines (1204 loc) · 75 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#
# Codec2 - Next-Generation Digital Voice for Two-Way Radio
#
# CMake configuration contributed by Richard Shaw (KF5OIM)
# Please report questions, comments, problems, or patches to the freetel
# mailing list: https://lists.sourceforge.net/lists/listinfo/freetel-codec2
#
# Note: this has to be at the beginning of the file in order for CMake to
# actually recognize this override (vs. simply telling the macOS build toolchain
# to mandate the current release).
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.9" CACHE STRING "Minimum OS X deployment version")
cmake_minimum_required(VERSION 3.13)
project(CODEC2
VERSION 1.2.0
DESCRIPTION "Next-Generation Digital Voice for Two-Way Radio"
HOMEPAGE_URL "https://www.rowetel.com/codec2.html"
LANGUAGES C
)
include(GNUInstallDirs)
mark_as_advanced(CLEAR
CMAKE_INSTALL_BINDIR
CMAKE_INSTALL_INCLUDEDIR
CMAKE_INSTALL_LIBDIR
)
#
# Prevent in-source builds
# If an in-source build is attempted, you will still need to clean up a few
# files manually.
#
set(CMAKE_DISABLE_SOURCE_CHANGES ON)
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)
if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
message(FATAL_ERROR "In-source builds in ${CMAKE_BINARY_DIR} are not "
"allowed, please remove ./CMakeCache.txt and ./CMakeFiles/, create a "
"separate build directory and run cmake from there.")
endif("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
# Set default build type
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Debug")
endif()
# Build universal ARM64 and x86_64 binaries on Mac.
if(BUILD_OSX_UNIVERSAL)
set(CMAKE_OSX_ARCHITECTURES "x86_64;arm64")
endif(BUILD_OSX_UNIVERSAL)
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.9" CACHE STRING "Minimum OS X deployment version")
#
# Find the git hash if this is a working copy.
#
if(EXISTS ${CMAKE_SOURCE_DIR}/.git)
find_package(Git)
if(Git_FOUND)
execute_process(
COMMAND "${GIT_EXECUTABLE}" rev-parse --short HEAD
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
RESULT_VARIABLE res
OUTPUT_VARIABLE CODEC2_HASH
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
message(STATUS "Codec2 current git hash: ${CODEC2_HASH}")
add_definitions(-DGIT_HASH="${CODEC2_HASH}")
else()
message(WARNING "Git not found. Can not determine current commit hash.")
add_definitions(-DGIT_HASH="Unknown")
endif()
else()
add_definitions(-DGIT_HASH="None")
endif()
set(ARCHIVE_NAME "codec2-${CODEC2_VERSION_MAJOR}.${CODEC2_VERSION_MINOR}.${CODEC2_VERSION_PATCH}")
add_custom_target(dist
COMMAND git archive --prefix=${ARCHIVE_NAME}/ HEAD
| bzip2 > ${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}.tar.bz2
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
# Set default C flags.
if(NOT MSVC)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wno-strict-overflow")
else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
endif()
# Check for what C standard is supported.
if(NOT WIN32)
include(CheckCCompilerFlag)
CHECK_C_COMPILER_FLAG("-std=gnu11" COMPILER_SUPPORTS_GNU11)
CHECK_C_COMPILER_FLAG("-std=gnu99" COMPILER_SUPPORTS_GNU99)
if(COMPILER_SUPPORTS_GNU11)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu11")
elseif(COMPILER_SUPPORTS_GNU99)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99")
else()
message(SEND_ERROR "Compiler doesn't seem to support at least gnu99, might cause problems" )
endif()
endif(NOT WIN32)
# -fPIC is implied on MinGW...
if((NOT WIN32) AND (NOT MICROCONTROLLER_BUILD))
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
endif()
if(NOT MSVC)
set(CMAKE_C_FLAGS_DEBUG "-g -O2 -DDUMP")
set(CMAKE_C_FLAGS_RELEASE "-O3")
else()
set(CMAKE_C_FLAGS_DEBUG "/Zi")
set(CMAKE_C_FLAGS_RELEASE "/O2")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4244 /wd4305 /wd5045")
endif()
#
# Setup Windows/MinGW specifics here.
#
if(MINGW)
message(STATUS "System is MinGW.")
endif(MINGW)
#
# Default options
#
option(BUILD_SHARED_LIBS
"Build shared library. Set to OFF for static library." ON)
option(UNITTEST "Build unittest binaries." OFF)
# LPCNet needs to be bootstrapped because codec2 and freedvlpcnet are
# cross dependent.
option(LPCNET "Build codec2 with LPCNet support." OFF)
set(LPCNET_BUILD_DIR FALSE CACHE PATH "Location of lpcnet build tree.")
# Setting LPCNET_BUILD_DIR implies LPCNET=ON
if(${LPCNET_BUILD_DIR})
set(LPCNET ON)
endif()
include(CheckIncludeFiles)
check_include_files("stdlib.h" HAVE_STDLIB_H)
check_include_files("string.h" HAVE_STRING_H)
include(CheckSymbolExists)
# Check if _GNU_SOURCE is available.
if (NOT DEFINED _GNU_SOURCE)
check_symbol_exists(__GNU_LIBRARY__ "features.h" _GNU_SOURCE)
if (NOT _GNU_SOURCE)
unset(_GNU_SOURCE CACHE)
check_symbol_exists(_GNU_SOURCE "features.h" _GNU_SOURCE)
endif()
endif()
if (_GNU_SOURCE)
add_definitions(-D_GNU_SOURCE=1)
endif()
check_symbol_exists(floor math.h HAVE_FLOOR)
check_symbol_exists(ceil math.h HAVE_CEIL)
check_symbol_exists(pow math.h HAVE_POW)
check_symbol_exists(sqrt math.h HAVE_SQRT)
check_symbol_exists(sin math.h HAVE_SIN)
check_symbol_exists(cos math.h HAVE_COS)
check_symbol_exists(atan2 math.h HAVE_ATAN2)
check_symbol_exists(log10 math.h HAVE_LOG10)
check_symbol_exists(round math.h HAVE_ROUND)
check_symbol_exists(getopt getopt.h HAVE_GETOPT)
configure_file ("${PROJECT_SOURCE_DIR}/cmake/config.h.in"
"${PROJECT_BINARY_DIR}/config.h" )
# Output path is such that #include <codec2/version.h> in codec2.h works
set(CODEC2_VERSION_PATH "${PROJECT_BINARY_DIR}")
configure_file ("${PROJECT_SOURCE_DIR}/cmake/version.h.in"
"${CODEC2_VERSION_PATH}/version.h" )
include_directories(${PROJECT_BINARY_DIR})
# CMake Package setup
#include(CMakePackageConfigHelpers)
#configure_package_config_file(cmake/codec2-config.cmake.in
# ${CMAKE_CURRENT_BINARY_DIR}/codec2-config.cmake
# INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/codec2
# PATH_VARS CMAKE_INSTALL_INCLUDEDIR
#)
#
# Find lpcnet library
#
if(LPCNET)
if(LPCNET_BUILD_DIR)
# Theoretically this shouldn't be needed as we're also defining LPCNET_BUILD_DIR
# in the PATHS section below. But on Fedora 37, CMake can't find LPCNet (at least
# in Docker) without this.
set(lpcnetfreedv_DIR ${LPCNET_BUILD_DIR})
find_package(lpcnetfreedv REQUIRED
PATHS ${LPCNET_BUILD_DIR}
NO_DEFAULT_PATH
# CONFIGS lpcnetfreedv.cmake
)
if(lpcnetfreedv_FOUND)
message(STATUS "liblpcnetfreedv found in build tree.")
add_definitions("-D__LPCNET__")
else()
message(FATAL_ERROR "LPCNet include/library not found in build tree.")
endif()
else()
find_package(lpcnetfreedv REQUIRED)
if(lpcnetfreedv_FOUND)
add_definitions("-D__LPCNET__")
message(STATUS "liblpcnetfreedv found.")
else()
message(FATAL_ERROR "lpcnetfreedv library not found.")
endif()
endif()
endif()
#
# codec2 library and demo apps
#
add_subdirectory(src)
if(NOT MSVC)
add_subdirectory(demo)
endif()
if(UNITTEST)
# Pthread Library
find_package(Threads REQUIRED)
message(STATUS "Threads library flags: ${CMAKE_THREAD_LIBS_INIT}")
add_subdirectory(unittest)
endif(UNITTEST)
message(STATUS "Build type is: " ${CMAKE_BUILD_TYPE})
string(TOUPPER ${CMAKE_BUILD_TYPE} _FLAGS)
if(_FLAGS STREQUAL "NONE")
message(STATUS "Compiler Flags: " ${CMAKE_C_FLAGS})
else()
message(STATUS "Compiler Flags: " ${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${_FLAGS}})
endif()
message(STATUS "Libraries linked: " ${CMAKE_REQUIRED_LIBRARIES})
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Next-Generation Digital Voice for Two-Way Radio")
set(CPACK_PACKAGE_VENDOR "CMake")
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING")
set(CPACK_PACKAGE_VERSION_MAJOR ${CODEC2_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${CODEC2_VERSION_MINOR})
if(CODEC2_VERSION_PATCH)
set(CPACK_PACKAGE_VERSION_PATCH ${CODEC2_VERSION_PATCH})
else()
set(CPACK_PACKAGE_VERSION_PATCH 0)
endif()
# Return the date (yyyy-mm-dd)
string(TIMESTAMP DATE_RESULT "%Y-%m-%d" UTC)
message(STATUS "Compilation date = XX${DATE_RESULT}XX")
set(CPACK_PACKAGE_VERSION_PATCH "${CPACK_PACKAGE_VERSION_PATCH}-${DATE_RESULT}-${CODEC2_HASH}")
if(WIN32 AND NOT MSVC)
#
# Cpack NSIS installer configuration for Windows.
# See: http://nsis.sourceforge.net/Download
#
# Detect if we're doing a 32-bit or 64-bit windows build.
if(${CMAKE_SIZEOF_VOID_P} EQUAL 8)
set(CMAKE_CL_64 TRUE)
endif()
configure_file(cmake/GetDependencies.cmake.in cmake/GetDependencies.cmake
@ONLY
)
install(SCRIPT ${CMAKE_BINARY_DIR}/cmake/GetDependencies.cmake)
set(CPACK_PACKAGE_INSTALL_DIRECTORY "Codec2")
set(CPACK_CREATE_DESKTOP_LINKS "")
set(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY}")
set(CPACK_NSIS_URL_INFO_ABOUT "http://rowetel.com/codec2.html")
set(CPACK_NSIS_MODIFY_PATH ON)
include(CPack)
elseif(UNIX AND NOT APPLE)
# Linux packaging
SET(CPACK_GENERATOR "DEB")
SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "Mooneer Salem <[email protected]>") #required
SET(CPACK_DEB_COMPONENT_INSTALL ON)
SET(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT)
SET(CPACK_DEBIAN_ENABLE_COMPONENT_DEPENDS ON)
SET(CPACK_DEBIAN_LIB_PACKAGE_NAME "codec2")
SET(CPACK_DEBIAN_PACKAGE_DEPENDS "lpcnet (>= 0.3.0)")
include(CPack)
cpack_add_component(lib REQUIRED)
cpack_add_component(dev DEPENDS lib)
endif()
########################################################################
# Create Pkg Config File
########################################################################
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/codec2.pc.in
${CMAKE_CURRENT_BINARY_DIR}/codec2.pc
@ONLY
)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/codec2.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
COMPONENT "codec2_devel"
)
##################################################################
# Tests
##################################################################
if(UNITTEST)
include(CTest)
enable_testing()
add_test(NAME test_clang_format
COMMAND sh -c "cd ${CMAKE_CURRENT_SOURCE_DIR};
clang-format --dry-run --Werror src/*.c src/*.h unittest/*.c demo/*.c")
add_test(NAME test_freedv_get_hash
COMMAND sh -c "${CMAKE_CURRENT_BINARY_DIR}/unittest/thash")
if(UNIX) # Uses pthreads
add_test(NAME test_fifo
COMMAND $<TARGET_FILE:tfifo>
)
endif()
# 16<->8 kHz float resamplers
add_test(NAME test_fdmdv_16to8
COMMAND sh -c "cd ${CMAKE_CURRENT_SOURCE_DIR}/octave;
${CMAKE_CURRENT_BINARY_DIR}/unittest/t16_8;
DISPLAY=\"\" echo \"diff_fft_mag('in8.raw','out8.raw'); quit;\" | octave-cli -qf
")
set_tests_properties(test_fdmdv_16to8 PROPERTIES PASS_REGULAR_EXPRESSION "PASS")
# 16<->8 kHz short (int16) resamplers
add_test(NAME test_fdmdv_16to8_short
COMMAND sh -c "cd ${CMAKE_CURRENT_SOURCE_DIR}/octave;
${CMAKE_CURRENT_BINARY_DIR}/unittest/t16_8_short;
DISPLAY=\"\" echo \"diff_fft_mag('in8_short.raw','out8_short.raw'); quit;\" | octave-cli -qf
")
set_tests_properties(test_fdmdv_16to8_short PROPERTIES PASS_REGULAR_EXPRESSION "PASS")
# 48<->8 kHz float resamplers
add_test(NAME test_fdmdv_48to8_short
COMMAND sh -c "cd ${CMAKE_CURRENT_SOURCE_DIR}/octave;
${CMAKE_CURRENT_BINARY_DIR}/unittest/t48_8_short;
DISPLAY=\"\" echo \"diff_fft_mag('in8.raw','out8.raw'); quit;\" | octave-cli -qf
")
set_tests_properties(test_fdmdv_48to8_short PROPERTIES PASS_REGULAR_EXPRESSION "PASS")
# 48<->8 kHz short resamplers
add_test(NAME test_fdmdv_48to8
COMMAND sh -c "cd ${CMAKE_CURRENT_SOURCE_DIR}/octave;
${CMAKE_CURRENT_BINARY_DIR}/unittest/t48_8;
DISPLAY=\"\" echo \"diff_fft_mag('in8.raw','out8.raw'); quit;\" | octave-cli -qf
")
set_tests_properties(test_fdmdv_48to8 PROPERTIES PASS_REGULAR_EXPRESSION "PASS")
# Basic sanity check of Quisk complex band pass filter. Note complex filtering cosw(wn) gives
# just the +ve freq exp(jwn) so output power is 0.5 input power
add_test(NAME test_quisk_filter
COMMAND sh -c "cd ${CMAKE_CURRENT_SOURCE_DIR}/octave;
${CMAKE_CURRENT_BINARY_DIR}/unittest/mksine in.raw 1500 1;
cat in.raw | ${CMAKE_CURRENT_BINARY_DIR}/unittest/tquisk_filter |
sox -t .s16 -r 8000 -c 1 - -t .s16 out.raw vol 2;
cd ${CMAKE_CURRENT_SOURCE_DIR}/octave;
DISPLAY=\"\" echo \"diff_fft_mag('in.raw','out.raw'); quit;\" | octave-cli -qf
")
set_tests_properties(test_quisk_filter PROPERTIES PASS_REGULAR_EXPRESSION "PASS")
add_test(NAME test_CML_ldpcut
COMMAND sh -c "cd ${CMAKE_CURRENT_SOURCE_DIR}/octave; CTEST_SINGLE=1 octave-cli -qf ldpcut.m")
set_tests_properties(test_CML_ldpcut PROPERTIES PASS_REGULAR_EXPRESSION "Nerr: 0")
add_test(NAME test_CML_ldpcut_one_stuffing
COMMAND sh -c "cd ${CMAKE_CURRENT_SOURCE_DIR}/octave; CTEST_ONE_STUFFING=1 octave-cli -qf ldpcut.m")
set_tests_properties(test_CML_ldpcut_one_stuffing PROPERTIES PASS_REGULAR_EXPRESSION "Ferrs: 0")
# Golay (23,11) unit tests
add_test(NAME test_golay23 COMMAND sh -c "${CMAKE_CURRENT_BINARY_DIR}/unittest/golay23")
add_test(NAME test_golay23_runtime_tables COMMAND sh -c "${CMAKE_CURRENT_BINARY_DIR}/unittest/golay23_runtime_tables")
# check channel simulator measures correct Peak to Average Power Ratio (about 0dB) with a sine wave input signal
add_test(NAME test_ch_papr
COMMAND sh -c "cd ${CMAKE_CURRENT_BINARY_DIR};
./unittest/mksine - 1000 10 | ./src/ch - /dev/null --ctest")
add_test(NAME test_codec2_700c_octave_port
COMMAND sh -c "
cd ${CMAKE_CURRENT_BINARY_DIR}/src;
./c2sim ${CMAKE_CURRENT_SOURCE_DIR}/raw/hts1a.raw --phase0 --postfilter --dump hts1a --lpc 10 --dump_pitch_e hts1a_pitche.txt;
cd ${CMAKE_CURRENT_BINARY_DIR}/unittest; ./tnewamp1 ${CMAKE_CURRENT_SOURCE_DIR}/raw/hts1a.raw;
cd ${CMAKE_CURRENT_SOURCE_DIR}/octave;
DISPLAY=\"\" octave-cli -qf --eval 'tnewamp1(\"${CMAKE_CURRENT_BINARY_DIR}/src/hts1a\", \"${CMAKE_CURRENT_BINARY_DIR}/unittest\")'")
set_tests_properties(test_codec2_700c_octave_port PROPERTIES PASS_REGULAR_EXPRESSION "fails: 0")
# -------------------------------------------------------------------------
# FDMDV Modem
# -------------------------------------------------------------------------
add_test(NAME test_FDMDV_modem_octave_ut
COMMAND sh -c "
cd ${CMAKE_CURRENT_SOURCE_DIR}/octave/;
DISPLAY=\"\" octave-cli -qf fdmdv_ut.m")
set_tests_properties(test_FDMDV_modem_octave_ut PROPERTIES PASS_REGULAR_EXPRESSION "errors......: 0")
add_test(NAME test_FDMDV_modem_octave_mod_demod
COMMAND sh -c "
cd ${CMAKE_CURRENT_SOURCE_DIR}/octave/;
echo \"fdmdv_mod('test.raw',1400); fdmdv_demod('test.raw',1400); quit\" | DISPLAY=\"\" octave-cli")
set_tests_properties(test_FDMDV_modem_octave_mod_demod PROPERTIES PASS_REGULAR_EXPRESSION "0 errors")
add_test(NAME test_FDMDV_modem_octave_port
COMMAND sh -c "$<TARGET_FILE:tfdmdv> && DISPLAY=\"\" octave-cli --no-gui -qf ${CMAKE_CURRENT_SOURCE_DIR}/octave/tfdmdv.m"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/octave)
set_tests_properties(test_FDMDV_modem_octave_port PROPERTIES PASS_REGULAR_EXPRESSION "fails: 0")
add_test(NAME test_FDMDV_modem_octave_c
COMMAND sh -c "
cd ${CMAKE_CURRENT_BINARY_DIR}/src;
./fdmdv_get_test_bits - 14000 | ./fdmdv_mod - - |
./fdmdv_demod - - 14 demod_dump.txt | ./fdmdv_put_test_bits - ;
cd ${CMAKE_CURRENT_SOURCE_DIR}/octave/;
DISPLAY=\"\" octave-cli -qf fdmdv_ut.m")
set_tests_properties(test_FDMDV_modem_octave_c PROPERTIES PASS_REGULAR_EXPRESSION "errors......: 0")
# -------------------------------------------------------------------------
# COHPSK Modem
# -------------------------------------------------------------------------
add_test(NAME test_COHPSK_modem_octave_port
COMMAND sh -c "$<TARGET_FILE:tcohpsk> && DISPLAY=\"\" octave-cli --no-gui -qf ${CMAKE_CURRENT_SOURCE_DIR}/octave/tcohpsk.m"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/octave)
set_tests_properties(test_COHPSK_modem_octave_port PROPERTIES PASS_REGULAR_EXPRESSION "fails: 0")
add_test(NAME test_COHPSK_modem_AWGN_BER
COMMAND sh -c "cd ${CMAKE_CURRENT_BINARY_DIR}/src;
./cohpsk_get_test_bits - 5600 |
./cohpsk_mod - - |
./ch - - --No -30 --Fs 7500 |
./cohpsk_demod - - |
./cohpsk_put_test_bits -"
)
add_test(NAME test_COHPSK_modem_freq_offset
COMMAND sh -c "cd ${CMAKE_CURRENT_BINARY_DIR}/src;
./cohpsk_get_test_bits - 5600 |
./cohpsk_mod - - |
./ch - - --No -40 -f -30 --Fs 7500 |
./cohpsk_demod - - |
./cohpsk_put_test_bits -"
)
# -------------------------------------------------------------------------
# OFDM Modem
# -------------------------------------------------------------------------
add_test(NAME test_OFDM_qam16
COMMAND sh -c "${CMAKE_CURRENT_BINARY_DIR}/unittest/tqam16")
add_test(NAME test_OFDM_modem_octave_port
COMMAND sh -c "PATH_TO_TOFDM=${CMAKE_CURRENT_BINARY_DIR}/unittest/tofdm DISPLAY=\"\" octave-cli --no-gui -qf ${CMAKE_CURRENT_SOURCE_DIR}/octave/tofdm.m"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/octave)
set_tests_properties(test_OFDM_modem_octave_port PROPERTIES PASS_REGULAR_EXPRESSION "fails: 0")
add_test(NAME test_OFDM_modem_octave_port_Nc_31
COMMAND sh -c "NC=31 PATH_TO_TOFDM=${CMAKE_CURRENT_BINARY_DIR}/unittest/tofdm DISPLAY=\"\" octave-cli --no-gui -qf ${CMAKE_CURRENT_SOURCE_DIR}/octave/tofdm.m"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/octave)
set_tests_properties(test_OFDM_modem_octave_port_Nc_31 PROPERTIES PASS_REGULAR_EXPRESSION "fails: 0")
add_test(NAME test_OFDM_modem_octave_qam16_uncoded
COMMAND sh -c "cd ${CMAKE_CURRENT_SOURCE_DIR}/octave;
echo \"ofdm_tx('test_qam16.raw','qam16c1',3,12,'awgn','bursts',3); ofdm_rx('test_qam16.raw','qam16c1', 'passber', 0.05, 'packetsperburst', 1); quit\" |
DISPLAY=\"\" octave-cli")
set_tests_properties(test_OFDM_modem_octave_qam16_uncoded PROPERTIES PASS_REGULAR_EXPRESSION "Pass")
add_test(NAME test_OFDM_modem_esno_est_octave
COMMAND sh -c "cd ${CMAKE_CURRENT_SOURCE_DIR}/octave;
echo 'pkg load signal; esno_est; esno_est_tests_octave' |
PATH_TO_UNITEST=${CMAKE_CURRENT_BINARY_DIR}/unittest/ DISPLAY=\"\" octave-cli")
set_tests_properties(test_OFDM_modem_esno_est_octave PROPERTIES PASS_REGULAR_EXPRESSION "AWGN Pass.*MPP Pass")
add_test(NAME test_OFDM_modem_esno_est_c
COMMAND sh -c "cd ${CMAKE_CURRENT_SOURCE_DIR}/octave;
echo 'pkg load signal; esno_est; esno_est_tests_c' |
PATH_TO_UNITEST=${CMAKE_CURRENT_BINARY_DIR}/unittest/ DISPLAY=\"\" octave-cli")
set_tests_properties(test_OFDM_modem_esno_est_c PROPERTIES PASS_REGULAR_EXPRESSION "AWGN Pass.*MPP Pass")
# ---------------------------------- Data Mode burst acquisition tests ----------------------------------
add_test(NAME test_OFDM_modem_octave_burst_acq
COMMAND sh -c "cd ${CMAKE_CURRENT_SOURCE_DIR}/octave;
echo \"ctest=1; ofdm_acquisition; quit\" | DISPLAY=\"\" octave-cli")
set_tests_properties(test_OFDM_modem_octave_burst_acq PROPERTIES PASS_REGULAR_EXPRESSION "P.acq. = 1.00")
add_test(NAME test_OFDM_modem_octave_datac0_postamble
COMMAND sh -c "cd ${CMAKE_CURRENT_SOURCE_DIR}/octave;
echo \"ofdm_tx('test_datac0.raw','datac0',1,100,'awgn','bursts',3); ofdm_rx('test_datac0.raw','datac0','packetsperburst',1,'postambletest','passber', 1E-6); quit\" |
DISPLAY=\"\" octave-cli")
set_tests_properties(test_OFDM_modem_octave_datac0_postamble PROPERTIES PASS_REGULAR_EXPRESSION "Pass")
# Check C port of burst acquisition
add_test(NAME test_OFDM_modem_burst_acq_port
COMMAND sh -c "cd ${CMAKE_CURRENT_SOURCE_DIR}/octave;
echo \"tofdm_acq; quit\" | PATH_TO_UNITTEST=${CMAKE_CURRENT_BINARY_DIR}/unittest DISPLAY=\"\" octave-cli")
set_tests_properties(test_OFDM_modem_burst_acq_port PROPERTIES PASS_REGULAR_EXPRESSION "PASS")
# Give uncoded Octave burst data modem a workout on a poor channel (0dB SNR MPP)
add_test(NAME test_OFDM_modem_octave_datac0_mpp
COMMAND sh -c "cd ${CMAKE_CURRENT_SOURCE_DIR}/octave;
echo \"ofdm_tx('test_datac0.raw','datac0',1,0,'mpp','bursts',10); \
ofdm_rx('test_datac0.raw','datac0','packetsperburst',1,'passpacketcount',9);\
quit\" |
DISPLAY=\"\" octave-cli")
set_tests_properties(test_OFDM_modem_octave_datac0_mpp PROPERTIES PASS_REGULAR_EXPRESSION "Pass")
# Same for coded Octave burst data modem - look out for bit rot as simulations evolve ....
add_test(NAME test_OFDM_modem_octave_datac0_mpp_coded
COMMAND sh -c "cd ${CMAKE_CURRENT_SOURCE_DIR}/octave;
echo \"ofdm_ldpc_tx('test_datac0.raw','datac0',1,0,'mpp','bursts',10); \
ofdm_ldpc_rx('test_datac0.raw','datac0','packetsperburst',1,'passpacketcount',9);\
quit\" |
DISPLAY=\"\" octave-cli")
set_tests_properties(test_OFDM_modem_octave_datac0_mpp_coded PROPERTIES PASS_REGULAR_EXPRESSION "Pass")
# Check Octave and C compressed waveforms are about the same
add_test(NAME test_OFDM_modem_datac0_compression
COMMAND sh -c "cd ${CMAKE_CURRENT_SOURCE_DIR}/unittest;
./check_comp.sh ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/src")
# ---------------------------------- ofdm_mod/demod level C modem tests ----------------------------------
# noise free uncoded 700D test, including reading and writing payload bits
add_test(NAME test_OFDM_modem_700D
COMMAND sh -c "cd ${CMAKE_CURRENT_BINARY_DIR}/src;
./ofdm_get_test_bits - |
./ofdm_mod |
./ofdm_demod --testframes > /dev/null")
# noise free coded 700D test, including reading and writing payload bits
add_test(NAME test_OFDM_modem_700D_ldpc
COMMAND sh -c "cd ${CMAKE_CURRENT_BINARY_DIR}/src;
./ofdm_get_test_bits - --length 112 |
./ofdm_mod --ldpc |
./ofdm_demod --ldpc --testframes > /dev/null")
# noise free 2020 test, including reading and writing payload bits. fsk_*_test_bits
# used as it does it's own frame sync
add_test(NAME test_OFDM_modem_2020_ldpc
COMMAND sh -c "cd ${CMAKE_CURRENT_BINARY_DIR}/src;
./fsk_get_test_bits - 5000 |
./ofdm_mod --ldpc --mode 2020 |
./ofdm_demod --ldpc --mode 2020 |
./fsk_put_test_bits - -q")
add_test(NAME test_OFDM_modem_AWGN_BER
COMMAND sh -c "cd ${CMAKE_CURRENT_BINARY_DIR}/src;
./ofdm_mod --in /dev/zero --ldpc --testframes 60 --txbpf |
./ch - - --No -20 -f -50 |
./ofdm_demod --out /dev/null --testframes --ldpc --verbose 1"
)
add_test(NAME test_OFDM_modem_fading_BER
COMMAND sh -c "cd ${CMAKE_CURRENT_SOURCE_DIR}/unittest;
PATH=$PATH:${CMAKE_CURRENT_BINARY_DIR}/src ./ofdm_fade.sh ${CMAKE_CURRENT_BINARY_DIR}/unittest")
add_test(NAME test_OFDM_modem_phase_est_bw
COMMAND sh -c "cd ${CMAKE_CURRENT_SOURCE_DIR}/unittest;
PATH=$PATH:${CMAKE_CURRENT_BINARY_DIR}/src ./ofdm_phase_est_bw.sh ${CMAKE_CURRENT_BINARY_DIR}/unittest")
add_test(NAME test_OFDM_modem_time_sync_700D
COMMAND sh -c "cd ${CMAKE_CURRENT_SOURCE_DIR}/unittest;
PATH=$PATH:${CMAKE_CURRENT_BINARY_DIR}/src ./ofdm_time_sync.sh 700D")
if(LPCNET)
add_test(NAME test_OFDM_modem_time_sync_2020
COMMAND sh -c "cd ${CMAKE_CURRENT_SOURCE_DIR}/unittest;
PATH=$PATH:${CMAKE_CURRENT_BINARY_DIR}/src ./ofdm_time_sync.sh 2020")
endif()
# 700E at a little above AWGN operating point
add_test(NAME test_OFDM_modem_700E_AWGN
COMMAND sh -c "cd ${CMAKE_CURRENT_BINARY_DIR}/src;
./ofdm_mod --in /dev/zero --testframes 10 --ldpc --mode 700E |
./ch - - --No -22 |
./ofdm_demod --mode 700E --ldpc --testframes -v 2 > /dev/null")
# 2020B AWGN test
add_test(NAME test_OFDM_modem_2020B_AWGN
COMMAND sh -c "cd ${CMAKE_CURRENT_BINARY_DIR}/src;
./ofdm_mod --in /dev/zero --testframes 10 --mode 2020B --ldpc --clip --txbpf |
./ch - - --No -19 |
./ofdm_demod --mode 2020B --testframes --ldpc -v 2 > /dev/null")
# -------------------------------------------------------------------------
# OFDM Data modes
# -------------------------------------------------------------------------
# To integrate a new mode/waveform we prototype in Octave, get the core OFDM modem
# running in C (ofdm_mod & ofdm_demod), then the FreeDV API (frredv_tx & freedv_rx).
# Here we test Octave and the C versions of the OFDM modem working together, to help
# prevent any bit rot between them
# DATAC0 burst mode Octave Tx, C Rx
add_test(NAME test_OFDM_modem_datac0_octave_burst
COMMAND sh -c "cd ${CMAKE_CURRENT_SOURCE_DIR}/octave;
DISPLAY=\"\" octave-cli -qf --eval \"ofdm_ldpc_tx('${CMAKE_CURRENT_BINARY_DIR}/test.raw','datac0',1,100,'awgn','bursts',3)\";
cd ${CMAKE_CURRENT_BINARY_DIR};
cat test.raw | ./src/ofdm_demod --mode datac0 --out /dev/null --testframes --ldpc --verbose 1 --packetsperburst 1")
set_tests_properties(test_OFDM_modem_datac0_octave_burst PROPERTIES PASS_REGULAR_EXPRESSION "Coded PER: 0.0000 Tpkts: 3")
# DATAC1 C Tx, Octave Rx
add_test(NAME test_OFDM_modem_datac1_octave
COMMAND sh -c "cd ${CMAKE_CURRENT_BINARY_DIR};
./src/ofdm_mod --mode datac1 --in /dev/zero --testframes 20 --verbose 1 --ldpc > test.raw;
cd ${CMAKE_CURRENT_SOURCE_DIR}/octave;
DISPLAY=\"\" octave-cli -qf --eval 'ofdm_ldpc_rx(\"${CMAKE_CURRENT_BINARY_DIR}/test.raw\",\"datac1\")'")
set_tests_properties(test_OFDM_modem_datac1_octave PROPERTIES PASS_REGULAR_EXPRESSION "Coded PER: 0.0000 Pckts: 4")
# DATAC3 C Tx, Octave Rx
add_test(NAME test_OFDM_modem_datac3_octave
COMMAND sh -c "cd ${CMAKE_CURRENT_BINARY_DIR};
./src/ofdm_mod --mode datac3 --in /dev/zero --testframes 20 --verbose 1 --ldpc > test.raw;
cd ${CMAKE_CURRENT_SOURCE_DIR}/octave;
DISPLAY=\"\" octave-cli -qf --eval 'ofdm_ldpc_rx(\"${CMAKE_CURRENT_BINARY_DIR}/test.raw\",\"datac3\")'")
set_tests_properties(test_OFDM_modem_datac3_octave PROPERTIES PASS_REGULAR_EXPRESSION "Coded PER: 0.0000 Pckts: 5")
# DATAC1 C Tx, C Rx, uncoded
add_test(NAME test_OFDM_modem_datac1
COMMAND sh -c "cd ${CMAKE_CURRENT_BINARY_DIR}/src;
./ofdm_mod --mode datac1 --in /dev/zero --testframes 10 --verbose 1 |
./ofdm_demod --mode datac1 --out /dev/null --testframes --verbose 1")
# DATAC1 C Tx, C Rx, coded
add_test(NAME test_OFDM_modem_datac1_ldpc
COMMAND sh -c "cd ${CMAKE_CURRENT_BINARY_DIR}/src;
./ofdm_mod --mode datac1 --in /dev/zero --testframes 10 --ldpc --verbose 1 |
./ofdm_demod --mode datac1 --out /dev/null --testframes --ldpc --verbose 1")
# DATAC0 C Tx, C Rx, coded, burst mode
add_test(NAME test_OFDM_modem_datac0_ldpc_burst
COMMAND sh -c "cd ${CMAKE_CURRENT_BINARY_DIR}/src;
./ofdm_mod --mode datac0 --in /dev/zero --testframes 1 --verbose 1 --ldpc --bursts 3 |
./ch - - --No -17 |
./ofdm_demod --mode datac0 --out /dev/null --testframes --ldpc --verbose 2 --packetsperburst 1")
# DATAC4 C Tx, Octave Rx, burst mode
add_test(NAME test_OFDM_modem_datac4_octave
COMMAND sh -c "cd ${CMAKE_CURRENT_BINARY_DIR};
./src/ofdm_mod --mode datac4 --in /dev/zero --testframes 1 --verbose 1 --ldpc --bursts 5 > test.raw;
cd ${CMAKE_CURRENT_SOURCE_DIR}/octave;
DISPLAY=\"\" octave-cli -qf --eval 'ofdm_ldpc_rx(\"${CMAKE_CURRENT_BINARY_DIR}/test.raw\",\"datac4\",\"packetsperburst\",1)'")
set_tests_properties(test_OFDM_modem_datac3_octave PROPERTIES PASS_REGULAR_EXPRESSION "Coded PER: 0.0000 Pckts: 5")
# DATAC13 Octave Tx, C Rx, burst mode
add_test(NAME test_OFDM_modem_datac13_octave
COMMAND sh -c "cd ${CMAKE_CURRENT_SOURCE_DIR}/octave;
DISPLAY=\"\" octave-cli -qf --eval 'ofdm_ldpc_tx(\"${CMAKE_CURRENT_BINARY_DIR}/src/test.raw\",\"datac13\",1,3,\"awgn\",\"bursts\",5)';
cd ${CMAKE_CURRENT_BINARY_DIR}/src;
cat test.raw | ./ofdm_demod --mode datac13 --out /dev/null --testframes --ldpc --verbose 2 --packetsperburst 1")
# DATAC4 C Tx, C Rx, burst mode
add_test(NAME test_OFDM_modem_datac4_ldpc_burst
COMMAND sh -c "cd ${CMAKE_CURRENT_BINARY_DIR}/src;
./ofdm_mod --mode datac4 --in /dev/zero --testframes 1 --verbose 1 --ldpc --bursts 10 |
./ch - - --No -17 |
./ofdm_demod --mode datac4 --out /dev/null --testframes --ldpc --verbose 2 --packetsperburst 1")
# DATAC13 C Tx, C Rx, burst mode
add_test(NAME test_OFDM_modem_datac13_ldpc_burst
COMMAND sh -c "cd ${CMAKE_CURRENT_BINARY_DIR}/src;
./ofdm_mod --mode datac13 --in /dev/zero --testframes 1 --verbose 1 --ldpc --bursts 10 |
./ch - - --No -17 |
./ofdm_demod --mode datac13 --out /dev/null --testframes --ldpc --verbose 2 --packetsperburst 1")
# -------------------------------------------------------------------------
# LDPC
# -------------------------------------------------------------------------
# tests ldpc_enc/ldpc_noise/ldpc_dec
add_test(NAME test_ldpc_enc_dec
COMMAND sh -c "cd ${CMAKE_CURRENT_BINARY_DIR}/src;
./ldpc_enc /dev/zero - --sd --code HRA_112_112 --testframes 200 |
./ldpc_noise - - 0.5 |
./ldpc_dec - /dev/null --code HRA_112_112 --sd --testframes"
)
add_test(NAME test_ldpc_enc_dec_HRA_56_56
COMMAND sh -c "cd ${CMAKE_CURRENT_BINARY_DIR}/src;
./ldpc_enc /dev/zero - --sd --code HRA_56_56 --testframes 200 |
./ldpc_noise - - 0.5 |
./ldpc_dec - /dev/null --code HRA_56_56 --sd --testframes"
)
add_test(NAME test_ldpc_enc_dec_H_212_158
COMMAND sh -c "cd ${CMAKE_CURRENT_BINARY_DIR}/src;
./ldpc_enc /dev/zero - --sd --code H_212_158 --testframes 200 |
./ldpc_noise - - -2.0 |
./ldpc_dec - /dev/null --code H_212_158 --sd --testframes"
)
add_test(NAME test_ldpc_enc_dec_HRAb_396_504
COMMAND sh -c "cd ${CMAKE_CURRENT_BINARY_DIR}/src;
./ldpc_enc /dev/zero - --sd --code HRAb_396_504 --testframes 200 |
./ldpc_noise - - -2.0 |
./ldpc_dec - /dev/null --code HRAb_396_504 --sd --testframes"
)
add_test(NAME test_ldpc_enc_dec_H_256_768_22
COMMAND sh -c "cd ${CMAKE_CURRENT_BINARY_DIR}/src;
./ldpc_enc /dev/zero - --sd --code H_256_768_22 --testframes 200 |
./ldpc_noise - - 3.0 |
./ldpc_dec - /dev/null --code H_256_768_22 --sd --testframes"
)
add_test(NAME test_ldpc_enc_dec_H_256_512_4
COMMAND sh -c "cd ${CMAKE_CURRENT_BINARY_DIR}/src;
./ldpc_enc /dev/zero - --sd --code H_256_512_4 --testframes 200 |
./ldpc_noise - - 0.5 |
./ldpc_dec - /dev/null --code H_256_512_4 --sd --testframes"
)
add_test(NAME test_ldpc_enc_dec_HRAa_1536_512
COMMAND sh -c "cd ${CMAKE_CURRENT_BINARY_DIR}/src;
./ldpc_enc /dev/zero - --sd --code HRAa_1536_512 --testframes 200 |
./ldpc_noise - - -2 |
./ldpc_dec - /dev/null --code HRAa_1536_512 --sd --testframes"
)
add_test(NAME test_ldpc_enc_dec_H_128_256_5
COMMAND sh -c "cd ${CMAKE_CURRENT_BINARY_DIR}/src;
./ldpc_enc /dev/zero - --sd --code H_128_256_5 --testframes 200 |
./ldpc_noise - - 0.5 |
./ldpc_dec - /dev/null --code H_128_256_5 --sd --testframes"
)
add_test(NAME test_ldpc_enc_dec_H_4096_8192_3d
COMMAND sh -c "cd ${CMAKE_CURRENT_BINARY_DIR}/src;
./ldpc_enc /dev/zero - --sd --code H_4096_8192_3d --testframes 100 |
./ldpc_noise - - 0.0 |
./ldpc_dec - /dev/null --code H_4096_8192_3d --sd --testframes"
)
add_test(NAME test_ldpc_enc_dec_H_16200_9720
COMMAND sh -c "cd ${CMAKE_CURRENT_BINARY_DIR}/src;
./ldpc_enc /dev/zero - --sd --code H_16200_9720 --testframes 10 |
./ldpc_noise - - 0.5 |
./ldpc_dec - /dev/null --code H_16200_9720 --sd --testframes"
)
add_test(NAME test_ldpc_enc_dec_H_1024_2048_4f
COMMAND sh -c "cd ${CMAKE_CURRENT_BINARY_DIR}/src;
./ldpc_enc /dev/zero - --sd --code H_1024_2048_4f --testframes 100 |
./ldpc_noise - - 0.0 |
./ldpc_dec - /dev/null --code H_1024_2048_4f --sd --testframes"
)
add_test(NAME test_ldpc_enc_dec_H_2064_516_sparse
COMMAND sh -c "cd ${CMAKE_CURRENT_BINARY_DIR}/src;
./ldpc_enc /dev/zero - --sd --code H_2064_516_sparse --testframes 100 |
./ldpc_noise - - -2.0 |
./ldpc_dec - /dev/null --code H_2064_516_sparse --sd --testframes"
)
# -------------------------------------------------------------------------
# FreeDV API
# -------------------------------------------------------------------------
# Test 1600 using number of frames decoded and correct rx txt channel output
add_test(NAME test_freedv_api_1600
COMMAND sh -c "cd ${CMAKE_CURRENT_BINARY_DIR}/src;
./freedv_tx 1600 ../../raw/ve9qrp_10s.raw - | ./freedv_rx 1600 - /dev/null --txtrx 1600.txt;
cat 1600.txt")
set_tests_properties(test_freedv_api_1600 PROPERTIES PASS_REGULAR_EXPRESSION "frames decoded: 503 .*cq cq hello")
add_test(NAME test_freedv_api_700C
COMMAND sh -c "cd ${CMAKE_CURRENT_BINARY_DIR}/src;
./freedv_tx 700C ../../raw/ve9qrp_10s.raw - | ./freedv_rx 700C - /dev/null")
set_tests_properties(test_freedv_api_700C PROPERTIES PASS_REGULAR_EXPRESSION "frames decoded: 125")
add_test(NAME test_freedv_api_700D_backwards_compatability
COMMAND sh -c "$<TARGET_FILE:freedv_rx> 700D ${CMAKE_CURRENT_SOURCE_DIR}/raw/testframes_700d.raw /dev/null --testframes --discard"
)
# speech output on valid signal (at least 70000 samples), to exercise freedv_bits_to_speech() speech output logic
add_test(NAME test_freedv_api_700D_speech
COMMAND sh -c "cd ${CMAKE_CURRENT_BINARY_DIR}/src;
./freedv_tx 700D ../../raw/ve9qrp_10s.raw - |
./ch - - --No -20 |
./freedv_rx 700D - /dev/null --squelch -2 -vv")
set_tests_properties(test_freedv_api_700D_speech PROPERTIES PASS_REGULAR_EXPRESSION "frames decoded: 62 output speech samples: 7")
# no random speech output due to trial sync when listening to noise
add_test(NAME test_freedv_api_700D_burble
COMMAND sh -c "cd ${CMAKE_CURRENT_BINARY_DIR}/src;
./freedv_tx 700D ../../raw/ve9qrp.raw - |
./ch - - --No -8 |
./freedv_rx 700D - /dev/null --squelch -2 -vv")
set_tests_properties(test_freedv_api_700D_burble PROPERTIES PASS_REGULAR_EXPRESSION "output speech samples: 0")
add_test(NAME test_freedv_api_700D_AWGN_BER
COMMAND sh -c "dd bs=2560 count=120 if=/dev/zero | $<TARGET_FILE:freedv_tx> 700D - - --testframes | $<TARGET_FILE:ch> - - --No -20 -f -10 | $<TARGET_FILE:freedv_rx> 700D - /dev/null --testframes --discard"
)
# exercises complex rx codepath, albeit with just real samples
add_test(NAME test_freedv_api_700D_AWGN_BER_USECOMPLEX
COMMAND sh -c "dd bs=2560 count=120 if=/dev/zero | $<TARGET_FILE:freedv_tx> 700D - - --testframes | $<TARGET_FILE:ch> - - --No -20 -f -10 | $<TARGET_FILE:freedv_rx> 700D - /dev/null --testframes --discard --usecomplex"
)
# check real part of freedv_comptx() matches freedv_tx()
add_test(NAME test_freedv_api_700D_real_comp
COMMAND sh -c "cd ${CMAKE_CURRENT_SOURCE_DIR}/unittest;
PATH=$PATH:${CMAKE_CURRENT_BINARY_DIR}/demo:${CMAKE_CURRENT_BINARY_DIR}/unittest;
./check_real_comp.sh"
)
# exercises freedv_comptx()
add_test(NAME test_freedv_api_700D_comptx
COMMAND sh -c "cd ${CMAKE_CURRENT_BINARY_DIR}/unittest;
cat ${CMAKE_CURRENT_SOURCE_DIR}/raw/ve9qrp_10s.raw |
./freedv_700d_comptx |
./freedv_700d_comprx tx > /dev/null"
)
# exercises freedv_comprx()
add_test(NAME test_freedv_api_700D_comprx
COMMAND sh -c "cd ${CMAKE_CURRENT_BINARY_DIR}/unittest;
cat ${CMAKE_CURRENT_SOURCE_DIR}/raw/ve9qrp_10s.raw |
./freedv_700d_comptx |
./freedv_700d_comprx rx > /dev/null"
)
if(LPCNET)
add_test(NAME test_freedv_api_2020_to_ofdm_demod
COMMAND sh -c "cd ${CMAKE_CURRENT_BINARY_DIR}/src;
./freedv_tx 2020 ../../wav/wia_16kHz.wav - --testframes |
./ofdm_demod --mode 2020 --verbose 1 --ldpc --testframes > /dev/null"
)
add_test(NAME test_freedv_api_2020_from_ofdm_mod
COMMAND sh -c "cd ${CMAKE_CURRENT_BINARY_DIR}/src;
./ofdm_mod --in /dev/zero --mode 2020 --verbose 1 --ldpc --testframes 10 |
./freedv_rx 2020 - /dev/null --testframes"
)
add_test(NAME test_freedv_api_2020_awgn
COMMAND sh -c "cd ${CMAKE_CURRENT_BINARY_DIR}/src;
dd bs=32000 count=10 if=/dev/zero |
./freedv_tx 2020 - - --testframes |
./ch - - --No -24 |
./freedv_rx 2020 - /dev/null --testframes"
)
add_test(NAME test_freedv_api_2020B_mpp
COMMAND sh -c "cd ${CMAKE_CURRENT_BINARY_DIR}/src;
dd bs=32000 count=60 if=/dev/zero |
./freedv_tx 2020B - - --testframes --clip 1 |
./ch - - --No -25 --mpp --fading_dir ../unittest |
./freedv_rx 2020B - /dev/null --testframes"
)
endif()
add_test(NAME test_freedv_api_2400A
COMMAND sh -c "cd ${CMAKE_CURRENT_BINARY_DIR}/src;
./freedv_tx 2400A ../../raw/ve9qrp_10s.raw - | ./freedv_rx 2400A - /dev/null")
set_tests_properties(test_freedv_api_2400A PROPERTIES PASS_REGULAR_EXPRESSION "frames decoded: 250")
add_test(NAME test_freedv_api_2400B
COMMAND sh -c "cd ${CMAKE_CURRENT_BINARY_DIR}/src;
./freedv_tx 2400B ../../raw/ve9qrp_10s.raw - | ./freedv_rx 2400B - /dev/null")
set_tests_properties(test_freedv_api_2400B PROPERTIES PASS_REGULAR_EXPRESSION "frames decoded: 250")
add_test(NAME test_freedv_api_800XA
COMMAND sh -c "cd ${CMAKE_CURRENT_BINARY_DIR}/src;
./freedv_tx 800XA ../../raw/ve9qrp_10s.raw - | ./freedv_rx 800XA - /dev/null")
set_tests_properties(test_freedv_api_800XA PROPERTIES PASS_REGULAR_EXPRESSION "frames decoded: 125")
add_test(NAME test_freedv_api_rawdata_800XA
COMMAND sh -c "./tfreedv_800XA_rawdata"
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/unittest
)
add_test(NAME test_freedv_api_rawdata_2400A
COMMAND sh -c "./tfreedv_2400A_rawdata"
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/unittest
)
add_test(NAME test_freedv_api_rawdata_2400B
COMMAND sh -c "./tfreedv_2400B_rawdata"
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/unittest
)
add_test(NAME test_peak_levels
COMMAND sh -c "cd ${CMAKE_CURRENT_SOURCE_DIR}/unittest;
PATH=$PATH:${CMAKE_CURRENT_BINARY_DIR}/src ./check_peak.sh")
set_tests_properties(test_peak_levels PROPERTIES FAIL_REGULAR_EXPRESSION "FAIL")
if(LPCNET)
add_test(NAME test_peak_levels_lpcnet
COMMAND sh -c "cd ${CMAKE_CURRENT_SOURCE_DIR}/unittest;
PATH=$PATH:${CMAKE_CURRENT_BINARY_DIR}/src ./check_peak.sh LPCNet")
set_tests_properties(test_peak_levels_lpcnet PROPERTIES FAIL_REGULAR_EXPRESSION "FAIL")
endif()
# -------------------------------------------------------------------------
# Reliable Text
# -------------------------------------------------------------------------
add_test(NAME test_freedv_reliable_text_truncate_string
COMMAND sh -c "cd ${CMAKE_CURRENT_BINARY_DIR}/src;
./freedv_tx 1600 ../../raw/ve9qrp.raw - --reliabletext AB1CDEFGH > 1600_reliable.raw 2>/dev/null;
./freedv_rx 1600 1600_reliable.raw /dev/null --txtrx 1600_reliable.txt --reliabletext 2>/dev/null;
grep 'AB1CDEFG' 1600_reliable.txt | wc -l")
set_tests_properties(test_freedv_reliable_text_truncate_string PROPERTIES PASS_REGULAR_EXPRESSION "20")
add_test(NAME test_freedv_reliable_text_ideal_1600
COMMAND sh -c "cd ${CMAKE_CURRENT_BINARY_DIR}/src;
./freedv_tx 1600 ../../raw/ve9qrp.raw - --reliabletext AB1CDEF > 1600_reliable.raw 2>/dev/null;
./freedv_rx 1600 1600_reliable.raw /dev/null --txtrx 1600_reliable.txt --reliabletext 2>/dev/null;
cat 1600_reliable.txt | wc -l")
set_tests_properties(test_freedv_reliable_text_ideal_1600 PROPERTIES PASS_REGULAR_EXPRESSION "20")
add_test(NAME test_freedv_reliable_text_ideal_700D
COMMAND sh -c "cd ${CMAKE_CURRENT_BINARY_DIR}/src;
./freedv_tx 700D ../../raw/ve9qrp.raw - --reliabletext AB1CDEF --txbpf 1 --clip 1 > 700D_reliable.raw 2>/dev/null;
./freedv_rx 700D 700D_reliable.raw /dev/null --txtrx 700D_reliable.txt --reliabletext 2>/dev/null;
cat 700D_reliable.txt | wc -l")
set_tests_properties(test_freedv_reliable_text_ideal_700D PROPERTIES PASS_REGULAR_EXPRESSION "21")
add_test(NAME test_freedv_reliable_text_ideal_700E
COMMAND sh -c "cd ${CMAKE_CURRENT_BINARY_DIR}/src;
./freedv_tx 700E ../../raw/ve9qrp.raw - --reliabletext AB1CDEF --txbpf 1 --clip 1 > 700E_reliable.raw 2>/dev/null;
./freedv_rx 700E 700E_reliable.raw /dev/null --txtrx 700E_reliable.txt --reliabletext 2>/dev/null;
cat 700E_reliable.txt | wc -l")
set_tests_properties(test_freedv_reliable_text_ideal_700E PROPERTIES PASS_REGULAR_EXPRESSION "21")
add_test(NAME test_freedv_reliable_text_awgn_1600
COMMAND sh -c "cd ${CMAKE_CURRENT_BINARY_DIR}/src;
./freedv_tx 1600 ../../raw/ve9qrp.raw - --reliabletext AB1CDEF | ./ch - - --No -25 -f -5 > 1600_reliable.raw 2>/dev/null;
./freedv_rx 1600 1600_reliable.raw /dev/null --txtrx 1600_reliable.txt --reliabletext 2>/dev/null;
if [ `cat 1600_reliable.txt | wc -l` -ge 10 ]; then echo 1; fi")
set_tests_properties(test_freedv_reliable_text_awgn_1600 PROPERTIES PASS_REGULAR_EXPRESSION "1")
add_test(NAME test_freedv_reliable_text_awgn_700D
COMMAND sh -c "cd ${CMAKE_CURRENT_BINARY_DIR}/src;
./freedv_tx 700D ../../raw/ve9qrp.raw - --reliabletext AB1CDEF --txbpf 1 --clip 1 | ./ch - - --No -12 -f -5 > 700D_reliable.raw 2>/dev/null;
./freedv_rx 700D 700D_reliable.raw /dev/null --txtrx 700D_reliable.txt --reliabletext 2>/dev/null;
if [ `cat 700D_reliable.txt | wc -l` -ge 10 ]; then echo 1; fi")
set_tests_properties(test_freedv_reliable_text_awgn_700D PROPERTIES PASS_REGULAR_EXPRESSION "1")
add_test(NAME test_freedv_reliable_text_awgn_700E
COMMAND sh -c "cd ${CMAKE_CURRENT_BINARY_DIR}/src;
./freedv_tx 700E ../../raw/ve9qrp.raw - --reliabletext AB1CDEF --txbpf 1 --clip 1 | ./ch - - --No -15 -f -5 > 700E_reliable.raw 2>/dev/null;
./freedv_rx 700E 700E_reliable.raw /dev/null --txtrx 700E_reliable.txt --reliabletext 2>/dev/null;
if [ `cat 700E_reliable.txt | wc -l` -ge 10 ]; then echo 1; fi")
set_tests_properties(test_freedv_reliable_text_awgn_700E PROPERTIES PASS_REGULAR_EXPRESSION "1")
add_test(NAME test_freedv_reliable_text_fade_1600
COMMAND sh -c "cd ${CMAKE_CURRENT_SOURCE_DIR}/unittest; ./reliable_text_fade.sh 1600 -28 3 0 '${CMAKE_CURRENT_BINARY_DIR}/src'")
add_test(NAME test_freedv_reliable_text_fade_700D
COMMAND sh -c "cd ${CMAKE_CURRENT_SOURCE_DIR}/unittest; ./reliable_text_fade.sh 700D -19 8 1 '${CMAKE_CURRENT_BINARY_DIR}/src'")
add_test(NAME test_freedv_reliable_text_fade_700E
COMMAND sh -c "cd ${CMAKE_CURRENT_SOURCE_DIR}/unittest; ./reliable_text_fade.sh 700E -22 8 1 '${CMAKE_CURRENT_BINARY_DIR}/src'")
if(LPCNET)
add_test(NAME test_freedv_reliable_text_ideal_2020
COMMAND sh -c "cd ${CMAKE_CURRENT_BINARY_DIR}/src;
./freedv_tx 2020 ../../raw/ve9qrp.raw - --reliabletext AB1CDEF > 2020_reliable.raw 2>/dev/null;
./freedv_rx 2020 2020_reliable.raw /dev/null --txtrx 2020_reliable.txt --reliabletext 2>/dev/null;
cat 2020_reliable.txt | wc -l")
set_tests_properties(test_freedv_reliable_text_ideal_2020 PROPERTIES PASS_REGULAR_EXPRESSION "9")
add_test(NAME test_freedv_reliable_text_awgn_2020
COMMAND sh -c "cd ${CMAKE_CURRENT_BINARY_DIR}/src;
./freedv_tx 2020 ../../raw/ve9qrp.raw - --reliabletext AB1CDEF | ./ch - - --No -22 -f -5 > 2020_reliable.raw 2>/dev/null;
./freedv_rx 2020 2020_reliable.raw /dev/null --txtrx 2020_reliable.txt --reliabletext 2>/dev/null;
if [ `cat 2020_reliable.txt | wc -l` -ge 9 ]; then echo 1; fi")
set_tests_properties(test_freedv_reliable_text_awgn_1600 PROPERTIES PASS_REGULAR_EXPRESSION "1")
add_test(NAME test_freedv_reliable_text_fade_2020
COMMAND sh -c "cd ${CMAKE_CURRENT_SOURCE_DIR}/unittest; ./reliable_text_fade.sh 2020 -26 4 0 '${CMAKE_CURRENT_BINARY_DIR}/src'")
endif(LPCNET)
# -------------------------------------------------------------------------
# FreeDV API memory leaks
# -------------------------------------------------------------------------