FreeDATA/test
Paul Kronenwetter 5c6cee1c21
Enhance tests (#185)
* Initial attempt to create unit tests for DATA class (tnc).

* Completed initial set of tests.

* Adding pytest to install packages.

* Corrects issue #173 fix

I didn't look carefully enough at `helpers.check_callsign` to see that it returns a list. The first element of the list is `True`/`False`.

* Making check_callsign evaluation more consistent.

* Update .gitignore

this is more a test commit to see if GitHub Client for MacOS is working,

* mkfifo test prototype

First partially working prototype for testing the full tnc with mkfifo named pipes.

* single tnc test file

moved to a single file for running tnc tests

* fixed typo

* Added parameters to tests.

Make other minor tweaks and documentation.

* Clean up two existing tests.

Adapted both tests to pytest and maintained
compatibility with existing ctest method.
Tweaked CMakeLists.txt .

* Adding pure python  highsnr_stdio_P_P_multi test.

Intended to replace highsnr_stdio_P_P_multi which uses POSIX shell.

* Adding pure python  highsnr_stdio_P_P_datac0 test.

Intended to replace highsnr_stdio_P_P_datac0 which uses POSIX shell.

* Parameterize recent tests.

Renamed datac0 to datacx after including all data codecs in test.

* Parameterize mode as well.

Add ability to run tests from main directory as well as within test/.

* Add list of tests and brief descriptions.

* Add more native python tests conversions.

* Update README with new tests.

* Tweak README again.

* Rename test to be findable by pytest.

* Rename test for ctest.

* Update correct file this time.

* Minor test tweaks.

* Add modem test proof-of-concept.

* Adjustment to ARQ short test.

* Various refactorings.

Type hints, trailing backslash, range usage, etc.

* Ignore unknown arguments in argparse.

* Minor cleanups.

* Update test/README.md.

* Update test_pa to quiet pylint.

* Give up trying to suppress structlog output.

* Correct module comments.

* Remove excess trailing spaces.

* Remove excess newlines.

* Various refactorings.

Type hints, trailing backslash, range usage, etc.

* mkfifo test prototype

First partially working prototype for testing the full tnc with mkfifo named pipes.

* Update test_tnc and tweak IRS/ISS.

* Correct test_modem to detect failures.

* Trying to be less dependent on env variables.

* Add IRS/ISS tests to ctests

* Pin codec2 revision to v1.0.3.

* Correcting git mistake.

* Pin codec2 revision to master.

This should be a specific release, that implements freedv_set_tuning_range.

Co-authored-by: DJ2LS <75909252+DJ2LS@users.noreply.github.com>
2022-05-21 23:04:17 +00:00
..
001_highsnr_stdio_audio changed folder structure 2021-12-20 11:10:41 +01:00
002_highsnr_ping_pong changed folder structure 2021-12-20 11:10:41 +01:00
hamlib-test.py accessed static 2021-12-28 21:25:19 +01:00
in8.raw connection mode, documentation, ... 2022-03-04 16:50:32 +01:00
out8.raw connection mode, documentation, ... 2022-03-04 16:50:32 +01:00
out48.raw connection mode, documentation, ... 2022-03-04 16:50:32 +01:00
ping.py Enhance tests (#185) 2022-05-21 23:04:17 +00:00
pong.py Enhance tests (#185) 2022-05-21 23:04:17 +00:00
README.md Enhance tests (#185) 2022-05-21 23:04:17 +00:00
test_arq_short.py Enhance tests (#185) 2022-05-21 23:04:17 +00:00
test_audiobuffer.py Enhance tests (#185) 2022-05-21 23:04:17 +00:00
test_callback_multimode_rx.py Enhance tests (#185) 2022-05-21 23:04:17 +00:00
test_callback_multimode_rx_outside.py Enhance tests (#185) 2022-05-21 23:04:17 +00:00
test_callback_multimode_tx.py Enhance tests (#185) 2022-05-21 23:04:17 +00:00
test_callback_rx.py Enhance tests (#185) 2022-05-21 23:04:17 +00:00
test_callback_rx_outside.py Enhance tests (#185) 2022-05-21 23:04:17 +00:00
test_callback_tx.py Enhance tests (#185) 2022-05-21 23:04:17 +00:00
test_helpers.py Enhance tests (#185) 2022-05-21 23:04:17 +00:00
test_highsnr_stdio_C_P_datacx.py Enhance tests (#185) 2022-05-21 23:04:17 +00:00
test_highsnr_stdio_P_C_datacx.py Enhance tests (#185) 2022-05-21 23:04:17 +00:00
test_highsnr_stdio_P_P_datacx.py Enhance tests (#185) 2022-05-21 23:04:17 +00:00
test_highsnr_stdio_P_P_multi.py Enhance tests (#185) 2022-05-21 23:04:17 +00:00
test_modem.py Enhance tests (#185) 2022-05-21 23:04:17 +00:00
test_multimode_rx.py Enhance tests (#185) 2022-05-21 23:04:17 +00:00
test_multimode_tx.py Enhance tests (#185) 2022-05-21 23:04:17 +00:00
test_pa.py Enhance tests (#185) 2022-05-21 23:04:17 +00:00
test_resample_48_8.py Enhance tests (#185) 2022-05-21 23:04:17 +00:00
test_rx.py Enhance tests (#185) 2022-05-21 23:04:17 +00:00
test_tnc.py Enhance tests (#185) 2022-05-21 23:04:17 +00:00
test_tnc_IRS.py Enhance tests (#185) 2022-05-21 23:04:17 +00:00
test_tnc_ISS.py Enhance tests (#185) 2022-05-21 23:04:17 +00:00
test_tnc_states.py Enhance tests (#185) 2022-05-21 23:04:17 +00:00
test_tx.py Enhance tests (#185) 2022-05-21 23:04:17 +00:00
test_virtual1.sh changed folder structure 2021-12-20 11:10:41 +01:00
test_virtual1a.sh changed folder structure 2021-12-20 11:10:41 +01:00
test_virtual1b.sh changed folder structure 2021-12-20 11:10:41 +01:00
test_virtual1c.sh changed folder structure 2021-12-20 11:10:41 +01:00
test_virtual2.sh changed folder structure 2021-12-20 11:10:41 +01:00
test_virtual3a.sh changed folder structure 2021-12-20 11:10:41 +01:00
test_virtual3b.sh changed folder structure 2021-12-20 11:10:41 +01:00
test_virtual4a.sh multimode callback tests 2021-12-20 12:15:35 +01:00
test_virtual4b.sh multimode callback tests 2021-12-20 12:15:35 +01:00
test_virtual_mm.sh changed folder structure 2021-12-20 11:10:41 +01:00

Unit Test Menu

The following CTest tests cover some TNC functionality and the interface to codec2:

  1. Name: audio_buffer Tests the thread safety of the audio buffer routines.
  2. Name: resampler Tests FreeDATA audio resampling from 48KHz to 8KHz.
  3. Name: tnc_state_machine Tests TNC transitions between states.
  4. Name: helper_routines Tests various helper routines.
  5. Name: py_highsnr_stdio_P_P_multi Tests a high signal-to-noise ratio (good quality) audio path using multiple codecs. (Pure python.)
  6. Name: py_highsnr_stdio_P_P_datacx Tests a high signal-to-noise ratio audio path using multiple individual codecs.
  7. Name: py_highsnr_stdio_P_C_datacx Tests a high signal-to-noise ratio audio path using multiple individual codecs.
  8. Name: py_highsnr_stdio_C_P_datacx Tests a high signal-to-noise ratio audio path using multiple individual codecs.
  9. Name: highsnr_stdio_P_C_single Tests compatibility with FreeDATA's transmit and freedv's raw data receive.
  10. Name: highsnr_stdio_C_P_single Tests compatibility with freedv's raw data transmit and FreeDATA's receive.
  11. Name: highsnr_stdio_P_P_single Tests a high signal-to-noise ratio audio path using multiple codecs. (Requires POSIX system.)
  12. Name: highsnr_stdio_P_P_multi Tests a high signal-to-noise ratio audio path using multiple codecs. (Requires POSIX system.)

The following tests can not currently be run with GitHub's pipeline as they require the ALSA dummy device kernel module to be installed. They also do not perform reliably. These tests are slowly being replaced with equivalent pipeline-compatible tests.

  1. Name: highsnr_virtual1_P_P_single_alsa Tests a high signal-to-noise ratio audio path using a single codec directly over an ALSA dummy device.
  2. Name: highsnr_virtual2_P_P_single Tests a high signal-to-noise ratio audio path using a single codec over an ALSA dummy device. Not functional due to an incompatibility between the two scripts in the way they determine audio devices.
  3. Name: highsnr_virtual3_P_P_multi Tests a high signal-to-noise ratio audio path using multiple codecs over an ALSA dummy device.
  4. Name: highsnr_virtual4_P_P_single_callback Not functional due to an incompatibility between the two scripts in the way they determine audio devices.
  5. Name: highsnr_virtual4_P_P_single_callback_outside Not functional due to an incompatibility between the two scripts in the way they determine audio devices.
  6. Name: highsnr_virtual5_P_P_multi_callback
  7. Name: highsnr_virtual5_P_P_multi_callback_outside
  8. Name: highsnr_ARQ_short Not functional, it is an obsolete or not yet completed test.

Instructions

  1. Install:
    cd FreeDATA
    mkdir build
    cd build
    cmake -DCODEC2_BUILD_DIR=$HOME/codec2/build_linux ..
    
  2. List available tests:
    ctest -N
    Test project /home/david/FreeDATA/build
    Test #1: 000_audio_tests
    Test #2: 001_highsnr_stdio_audio
    
    Total Tests: 2
    
  3. Run tests:
    ctest --output-on-failure
    
  4. Run tests verbosely:
    ctest -V
    

001_HIGHSNR_STDIO_AUDIO TEST SUITE

  1. Install
    sudo apt update
    sudo apt upgrade
    sudo apt install git cmake build-essential python3-pip portaudio19-dev python3-pyaudio
    pip3 install crcengine
    pip3 install threading
    
  2. Install codec2, and set up the libcodec2.so shared library path, for example
    export LD_LIBRARY_PATH=${HOME}/codec2/build_linux/src
    

STDIO tests

Pipes are used to move audio samples from the Tx to Rx:

python3 test_tx.py --mode datac1 --delay 500 --frames 2 --bursts 1 | python3 test_rx.py --mode datac1 --frames 2 --bursts 1

AUDIO test via virtual audio devices

Important:

The virtual audio devices are great for testing, but they are also a little bit tricky to handle. So there's a high chance, the tests will fail, if you are running them via virtual audio devices. You should run the tests several times, while keeping this in mind. Most time the ctest is working even if it is failing.

  1. Create virtual audio devices. Note: This command needs to be run again after every reboot

    sudo modprobe snd-aloop index=1,2 enable=1,1 pcm_substreams=1,1 id=CHAT1,CHAT2
    
  2. Check if devices have been created

     aplay -l
    
     Karte 0: Intel [HDA Intel], Gerät 0: Generic Analog [Generic Analog]
       Sub-Geräte: 1/1
       Sub-Gerät #0: subdevice #0
     Karte 1: CHAT1 [Loopback], Gerät 0: Loopback PCM [Loopback PCM]
       Sub-Geräte: 1/1
       Sub-Gerät #0: subdevice #0
     Karte 1: CHAT1 [Loopback], Gerät 1: Loopback PCM [Loopback PCM]
       Sub-Geräte: 1/1
       Sub-Gerät #0: subdevice #0
     Karte 2: CHAT2 [Loopback], Gerät 0: Loopback PCM [Loopback PCM]
       Sub-Geräte: 1/1
       Sub-Gerät #0: subdevice #0
     Karte 2: CHAT2 [Loopback], Gerät 1: Loopback PCM [Loopback PCM]
       Sub-Geräte: 1/1
       Sub-Gerät #0: subdevice #0
    
  3. Determine the audio device number you would like to use:

    python3 test_rx.py --list
    <snip>
    audiodev:  0 HDA Intel PCH: ALC269VC Analog (hw:0,0)
    audiodev:  1 HDA Intel PCH: HDMI 0 (hw:0,3)
    audiodev:  2 HDA Intel PCH: HDMI 1 (hw:0,7)
    audiodev:  3 HDA Intel PCH: HDMI 2 (hw:0,8)
    audiodev:  4 Loopback: PCM (hw:1,0)
    audiodev:  5 Loopback: PCM (hw:1,1)
    audiodev:  6 Loopback: PCM (hw:2,0)
    audiodev:  7 Loopback: PCM (hw:2,1)
    

    In this case we choose audiodev 4 for the RX and 5 for the Tx.

  4. Start the Rx first, then Tx in separate consoles:

    python3 test_rx.py --mode datac0 --frames 2 --bursts 1 --audiodev 4 --debug
    python3 test_tx.py --mode datac0 --frames 2 --bursts 1 --audiodev 5