Skip to content

Commit bc8b049

Browse files
authored
Merge pull request drowe67#267 from drowe67/ms-unittest-disable
Build CML as part of CMake build if UNITTEST is enabled.
2 parents d6baa25 + fa6d6db commit bc8b049

30 files changed

+125
-816
lines changed

.github/workflows/cmake.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,8 @@ jobs:
3030
- name: Configure codec2 CMake
3131
shell: bash
3232
working-directory: ${{github.workspace}}/build_linux
33-
run: cmake $GITHUB_WORKSPACE
33+
run: cmake -DUNITTEST=1 $GITHUB_WORKSPACE
3434

35-
- name: Setup CML Support
36-
shell: bash
37-
run: cd $HOME && $GITHUB_WORKSPACE/script/build_cml.sh
38-
3935
- name: Build codec2
4036
working-directory: ${{github.workspace}}/build_linux
4137
shell: bash
@@ -57,7 +53,7 @@ jobs:
5753
shell: bash
5854
# Second pass build of codec2 with LPCNet
5955
run: |
60-
cmake -DLPCNET_BUILD_DIR=$HOME/LPCNet/build_linux $GITHUB_WORKSPACE
56+
cmake -DLPCNET_BUILD_DIR=$HOME/LPCNet/build_linux -DUNITTEST=1 $GITHUB_WORKSPACE
6157
make -j4
6258
6359
- name: Run ctests

CMakeLists.txt

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#
88
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.9" CACHE STRING "Minimum OS X deployment version")
99

10-
project(codec2 C)
10+
project(codec2)
1111

1212
cmake_minimum_required(VERSION 3.0)
1313

@@ -152,12 +152,7 @@ endif()
152152
#
153153
option(BUILD_SHARED_LIBS
154154
"Build shared library. Set to OFF for static library." ON)
155-
# Unittest should be on for dev builds and off for releases.
156-
if(CMAKE_BUILD_TYPE MATCHES "Release")
157-
option(UNITTEST "Build unittest binaries." OFF)
158-
else()
159-
option(UNITTEST "Build unittest binaries." ON)
160-
endif()
155+
option(UNITTEST "Build unittest binaries." OFF)
161156
option(INSTALL_EXAMPLES "Install example code." OFF)
162157
if(INSTALL_EXAMPLES)
163158
install(DIRECTORY octave raw script wav
@@ -399,14 +394,12 @@ if(UNITTEST)
399394
add_test(NAME test_FDMDV_modem_octave_port
400395
COMMAND sh -c "$<TARGET_FILE:tfdmdv> && DISPLAY=\"\" octave-cli --no-gui -qf ${CMAKE_CURRENT_SOURCE_DIR}/octave/tfdmdv.m"
401396
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/octave)
402-
set_tests_properties(test_FDMDV_modem_octave_port PROPERTIES
403-
PASS_REGULAR_EXPRESSION "fails: 0")
397+
set_tests_properties(PROPERTIES PASS_REGULAR_EXPRESSION "fails: 0")
404398

405399
add_test(NAME test_COHPSK_modem_octave_port
406400
COMMAND sh -c "$<TARGET_FILE:tcohpsk> && DISPLAY=\"\" octave-cli --no-gui -qf ${CMAKE_CURRENT_SOURCE_DIR}/octave/tcohpsk.m"
407401
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/octave)
408-
set_tests_properties(test_COHPSK_modem_octave_port PROPERTIES
409-
PASS_REGULAR_EXPRESSION "fails: 0")
402+
set_tests_properties(test_COHPSK_modem_octave_port PROPERTIES PASS_REGULAR_EXPRESSION "fails: 0")
410403

411404
add_test(NAME test_COHPSK_modem_AWGN_BER
412405
COMMAND sh -c "$<TARGET_FILE:cohpsk_get_test_bits> - 5600 | $<TARGET_FILE:cohpsk_mod> - - | $<TARGET_FILE:cohpsk_ch> - - -30 | $<TARGET_FILE:cohpsk_demod> - - | $<TARGET_FILE:cohpsk_put_test_bits> -"
@@ -426,14 +419,12 @@ if(UNITTEST)
426419
add_test(NAME test_OFDM_modem_octave_port
427420
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"
428421
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/octave)
429-
set_tests_properties(test_OFDM_modem_octave_port PROPERTIES
430-
PASS_REGULAR_EXPRESSION "fails: 0")
422+
set_tests_properties(test_OFDM_modem_octave_port PROPERTIES PASS_REGULAR_EXPRESSION "fails: 0")
431423

432424
add_test(NAME test_OFDM_modem_octave_port_Nc_31
433425
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"
434426
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/octave)
435-
set_tests_properties(test_OFDM_modem_octave_port_Nc_31 PROPERTIES
436-
PASS_REGULAR_EXPRESSION "fails: 0")
427+
set_tests_properties(test_OFDM_modem_octave_port_Nc_31 PROPERTIES PASS_REGULAR_EXPRESSION "fails: 0")
437428

438429
add_test(NAME test_OFDM_modem_octave_qam16_uncoded
439430
COMMAND sh -c "cd ${CMAKE_CURRENT_SOURCE_DIR}/octave;
@@ -521,15 +512,15 @@ if(UNITTEST)
521512

522513
add_test(NAME test_OFDM_modem_fading_BER
523514
COMMAND sh -c "cd ${CMAKE_CURRENT_SOURCE_DIR}/unittest;
524-
PATH=$PATH:${CMAKE_CURRENT_BINARY_DIR}/src ./ofdm_fade.sh")
515+
PATH=$PATH:${CMAKE_CURRENT_BINARY_DIR}/src ./ofdm_fade.sh ${CMAKE_CURRENT_BINARY_DIR}/unittest")
525516

526517
add_test(NAME test_OFDM_modem_phase_est_bw
527518
COMMAND sh -c "cd ${CMAKE_CURRENT_SOURCE_DIR}/unittest;
528-
PATH=$PATH:${CMAKE_CURRENT_BINARY_DIR}/src ./ofdm_phase_est_bw.sh")
519+
PATH=$PATH:${CMAKE_CURRENT_BINARY_DIR}/src ./ofdm_phase_est_bw.sh ${CMAKE_CURRENT_BINARY_DIR}/unittest")
529520

530521
add_test(NAME test_OFDM_modem_fading_DPSK_BER
531522
COMMAND sh -c "cd ${CMAKE_CURRENT_SOURCE_DIR}/unittest;
532-
PATH=$PATH:${CMAKE_CURRENT_BINARY_DIR}/src ./ofdm_fade_dpsk.sh")
523+
PATH=$PATH:${CMAKE_CURRENT_BINARY_DIR}/src ./ofdm_fade_dpsk.sh ${CMAKE_CURRENT_BINARY_DIR}/unittest")
533524

534525
add_test(NAME test_OFDM_modem_time_sync_700D
535526
COMMAND sh -c "cd ${CMAKE_CURRENT_SOURCE_DIR}/unittest;
@@ -1224,4 +1215,17 @@ endif(NOT APPLE)
12241215
diff binaryIn.bin binaryOut.bin")
12251216

12261217

1218+
# Set common properties for tests that need Octave/CML
1219+
set_tests_properties(
1220+
test_CML_ldpcut
1221+
test_OFDM_modem_octave_port
1222+
test_OFDM_modem_octave_port_Nc_31
1223+
test_OFDM_modem_octave_datac0_mpp_coded
1224+
test_OFDM_modem_datac0_octave_burst
1225+
test_OFDM_modem_datac1_octave
1226+
test_OFDM_modem_datac3_octave
1227+
test_fsk_lib_4fsk_ldpc
1228+
PROPERTIES
1229+
ENVIRONMENT "CML_PATH=${CMAKE_CURRENT_BINARY_DIR}/cml"
1230+
)
12271231
endif(UNITTEST)

README.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,15 +123,13 @@ CTest is used as a test framework, with support from [GNU Octave](https://www.gn
123123
```
124124
sudo apt install octave octave-common octave-signal liboctave-dev gnuplot python3-numpy sox valgrind
125125
```
126-
1. Install CML library with instructions at the top of [```octave/ldpc.m```](octave/ldpc.m)
127-
128126
1. To build and run the tests:
129127
```
130128
cd ~/codec2
131129
rm -Rf build_linux && mkdir build_linux
132130
cd build_linux
133-
cmake -DCMAKE_BUILD_TYPE=Debug ..
134-
make all test
131+
cmake -DUNITTEST=1 ..
132+
make
135133
```
136134

137135
1. To just run tests without rebuilding:
@@ -154,6 +152,13 @@ CTest is used as a test framework, with support from [GNU Octave](https://www.gn
154152
ctest -N
155153
```
156154

155+
1. Many Octave scripts rely on the CML LDPC library. To run these from the Octave CLI, you need to set
156+
the `CML_PATH` environment variable. A convenient way to do this is using a `.octaverc` file
157+
in your `codec/octave` directory. For example on a Linux machine, create a `.octaverc` file:
158+
```
159+
setenv("CML_PATH","../build_linux/cml")
160+
```
161+
157162
## Directories
158163
```
159164
cmake - cmake support files

README_data.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ Clipping works by introducing controlled distortion, which affects the SNR estim
336336

337337
This command line demonstrates the effect:
338338
```
339-
/src/freedv_data_raw_tx datac3 /dev/zero - --testframes 10 --bursts 10 --clip 1 | ./src/cohpsk_ch - - -100 --raw_dir ../raw --Fs 8000 | ./src/freedv_data_raw_rx datac3 - /dev/null --testframes --framesperburst 1 -v
339+
./src/freedv_data_raw_tx datac3 /dev/zero - --testframes 10 --bursts 10 --clip 1 | ./src/cohpsk_ch - - -100 --fading_dir unittest --Fs 8000 | ./src/freedv_data_raw_rx datac3 - /dev/null --testframes --framesperburst 1 -v
340340
```
341341
Try adjusting `--clip` and third argument of `cohpsk_ch` (noise level) for different modes. Note the SNR estimates returned from `freedv_data_raw_rx` compared to the SNR from the channel simulator `cohpsh_ch`. You will notice clipping also increases the RMS power and reduces the PER for a given noise level.
342342

README_freedv.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,11 +185,11 @@ $ ./freedv_tx 2020 ~/LPCNet/wav/all.wav - | ./cohpsk_ch - - -22 --Fs 8000 | ./fr
185185

186186
AWGN:
187187
```
188-
$ ./src/freedv_tx 700D ../raw/ve9qrp.raw - --clip 0 --testframes | ./src/cohpsk_ch - - -16 --raw_dir ../raw/ --Fs 8000 | ./src/freedv_rx 700D - /dev/null --testframes
188+
$ ./src/freedv_tx 700D ../raw/ve9qrp.raw - --clip 0 --testframes | ./src/cohpsk_ch - - -16 --Fs 8000 | ./src/freedv_rx 700D - /dev/null --testframes
189189
```
190190
MultiPath Poor (MPP):
191191
```
192-
$ ./src/freedv_tx 700D ../raw/ve9qrp.raw - --clip 0 --testframes | ./src/cohpsk_ch - - -24 --fast --raw_dir ../raw/ --Fs 8000 | ./src/freedv_rx 700D - /dev/null --testframes
192+
$ ./src/freedv_tx 700D ../raw/ve9qrp.raw - --clip 0 --testframes | ./src/cohpsk_ch - - -24 --mpp --fading_dir unittest --Fs 8000 | ./src/freedv_rx 700D - /dev/null --testframes
193193
```
194194

195195
Adjust `--clip [0|1]` and 3rd argument of `cohpsk_ch` to obtain a PER of just less than 0.1, and note the SNR and PAPR reported by `cohpsk_ch`. The use of the `ve9qrp` samples makes the test run for a few minutes, in order to get reasonable multipath channel results.

0 commit comments

Comments
 (0)