mirror of
https://github.com/DJ2LS/FreeDATA
synced 2024-05-14 08:04:33 +00:00
5c6cee1c21
* 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>
126 lines
3.5 KiB
Python
126 lines
3.5 KiB
Python
"""
|
|
Tests a high signal-to-noise ratio path with codec2 data formats using codec2 to receive.
|
|
"""
|
|
|
|
# pylint: disable=global-statement, invalid-name, unused-import
|
|
|
|
import os
|
|
import subprocess
|
|
import sys
|
|
|
|
import pytest
|
|
|
|
try:
|
|
BURSTS = int(os.environ["BURSTS"])
|
|
FRAMESPERBURST = int(os.environ["FRAMESPERBURST"])
|
|
TESTFRAMES = int(os.environ["TESTFRAMES"])
|
|
except KeyError:
|
|
BURSTS = 1
|
|
FRAMESPERBURST = 1
|
|
TESTFRAMES = 3
|
|
|
|
|
|
@pytest.mark.parametrize("bursts", [BURSTS, 2, 3])
|
|
@pytest.mark.parametrize("frames_per_burst", [FRAMESPERBURST, 2, 3])
|
|
@pytest.mark.parametrize("mode", ["datac0", "datac1", "datac3"])
|
|
def test_HighSNR_P_P_DATACx(bursts: int, frames_per_burst: int, mode: str):
|
|
"""
|
|
Test a high signal-to-noise ratio path with DATAC0.
|
|
|
|
:param bursts: Number of bursts
|
|
:type bursts: str
|
|
:param frames_per_burst: Number of frames transmitted per burst
|
|
:type frames_per_burst: str
|
|
:param testframes: Number of test frames to transmit
|
|
:type testframes: str
|
|
"""
|
|
|
|
# Facilitate running from main directory as well as inside test/
|
|
tx_side = "test_tx.py"
|
|
if os.path.exists("test") and os.path.exists(os.path.join("test", tx_side)):
|
|
tx_side = os.path.join("test", tx_side)
|
|
os.environ["PYTHONPATH"] += ":."
|
|
rx_side = "freedv_data_raw_rx"
|
|
|
|
with subprocess.Popen(
|
|
args=[
|
|
"python3",
|
|
tx_side,
|
|
"--mode",
|
|
mode,
|
|
"--delay",
|
|
"500",
|
|
"--framesperburst",
|
|
f"{frames_per_burst}",
|
|
"--bursts",
|
|
f"{bursts}",
|
|
],
|
|
stdout=subprocess.PIPE,
|
|
stderr=subprocess.PIPE,
|
|
) as transmit:
|
|
|
|
with subprocess.Popen(
|
|
args=[
|
|
"sox",
|
|
"-t",
|
|
".s16",
|
|
"-r",
|
|
"48000",
|
|
"-c",
|
|
"1",
|
|
"-",
|
|
"-t",
|
|
".s16",
|
|
"-r",
|
|
"8000",
|
|
"-c",
|
|
"1",
|
|
"-",
|
|
],
|
|
stdin=transmit.stdout,
|
|
stdout=subprocess.PIPE,
|
|
stderr=subprocess.STDOUT,
|
|
) as sox_filter:
|
|
|
|
with subprocess.Popen(
|
|
args=[
|
|
rx_side,
|
|
mode,
|
|
"-",
|
|
"-",
|
|
"--framesperburst",
|
|
str(frames_per_burst),
|
|
],
|
|
stdin=sox_filter.stdout,
|
|
stdout=subprocess.PIPE,
|
|
stderr=subprocess.STDOUT,
|
|
) as receive:
|
|
|
|
with subprocess.Popen(
|
|
args=[
|
|
"hexdump",
|
|
"-C",
|
|
],
|
|
stdin=receive.stdout,
|
|
stdout=subprocess.PIPE,
|
|
stderr=subprocess.STDOUT,
|
|
) as hexdump:
|
|
assert hexdump.stdout
|
|
lastline = "".join(
|
|
[
|
|
str(line, "UTF-8")
|
|
for line in hexdump.stdout.readlines()
|
|
if "HELLO" in str(line, "UTF-8")
|
|
]
|
|
)
|
|
assert "HELLO WORLD!" in lastline
|
|
print(lastline)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
# Run pytest with the current script as the filename.
|
|
ecode = pytest.main(["-v", "-s", sys.argv[0]])
|
|
if ecode == 0:
|
|
print("errors: 0")
|
|
else:
|
|
print(ecode)
|