Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Build dump978-fa

on: [ push, pull_request ]

jobs:
build:
name: Build dump978-fa
strategy:
fail-fast: false
matrix:
image:
- ubuntu-24.04
- ubuntu-24.04-arm
cc:
- gcc-10
- gcc-12
- gcc-14
include:
- cc: gcc-10
cxx: g++-10
- cc: gcc-12
cxx: g++-12
- cc: gcc-14
cxx: g++-14
runs-on: ${{ matrix.image }}
env:
CC: ${{ matrix.cc }}
CXX: ${{ matrix.cxx }}
steps:
- name: Check out repository
uses: actions/checkout@v6
- name: Install build prerequisites
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends debhelper libboost-system-dev libboost-program-options-dev libboost-regex-dev libboost-filesystem-dev libsoapysdr-dev ${{ matrix.cc }} ${{ matrix.cxx }}
- name: Build it
run: |
make all
- name: Run tests
run: |
make test
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ faup978: faup978_main.o socket_input.o uat_message.o track.o faup978_reporter.o
skyaware978: skyaware978_main.o socket_input.o uat_message.o track.o skyaware_writer.o
$(CXX) $(CXXFLAGS) $(LDFLAGS) $^ -o $@ $(LIBS)

test: fec_tests
./fec_tests

fec_tests: fec_tests.o libs/fec/init_rs_char.o libs/fec/decode_rs_char.o libs/fec/encode_rs_char.o
$(CXX) $(CXXFLAGS) $(LDFLAGS) $^ -o $@

Expand Down
70 changes: 41 additions & 29 deletions fec_tests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@ extern "C" {
#include "fec/rs.h"
}

void test_rs_decode(unsigned seed, int trials, int symsize, int gfpoly, int fcr, int prim, int nroots, int pad) {
bool test_rs_decode(unsigned seed, int trials, int symsize, int gfpoly, int fcr, int prim, int nroots, int pad)
{
srand(seed);

void *rs = ::init_rs_char(symsize, gfpoly, fcr, prim, nroots, pad);

int NN = (1 << symsize) - 1;
int blocklen = NN - pad;
int datalen = blocklen - nroots;
bool success = true;

std::vector<unsigned char> test_block(blocklen, 0);
std::vector<unsigned char> working_block(blocklen, 0);
Expand Down Expand Up @@ -61,22 +63,26 @@ void test_rs_decode(unsigned seed, int trials, int symsize, int gfpoly, int fcr,
if (n_corrected >= 0) {
std::cerr << "RS(" << blocklen << "," << datalen << ") (seed: " << seed << " trial: " << trial << " errors: " << n_errors << ")"
<< " returned success, but should have failed" << std::endl;
success = false;
}
} else {
if (n_corrected != n_errors) {
std::cerr << "RS(" << blocklen << "," << datalen << ") (seed: " << seed << " trial: " << trial << " errors: " << n_errors << ")"
<< " claimed to correct " << n_corrected << " errors" << std::endl;
success = false;
}
if (working_block != test_block) {
std::cerr << "RS(" << blocklen << "," << datalen << ") (seed: " << seed << " trial: " << trial << " errors: " << n_errors << ")"
<< " data wasn't corrected correctly" << std::endl;
success = false;
}

for (int i = 0; i < n_corrected; ++i) {
auto found = std::find(error_pos.begin(), error_pos.end(), corrected_pos[i]);
if (found == error_pos.end()) {
std::cerr << "RS(" << blocklen << "," << datalen << ") (seed: " << seed << " trial: " << trial << " errors: " << n_errors << ")"
<< " corrected symbol at position " << corrected_pos[i] << " which was not in error" << std::endl;
success = false;
} else {
error_pos.erase(found);
}
Expand All @@ -88,40 +94,46 @@ void test_rs_decode(unsigned seed, int trials, int symsize, int gfpoly, int fcr,
for (int pos : error_pos)
std::cerr << pos;
std::cerr << "]" << std::endl;
success = false;
}
}
}
}

::free_rs_char(rs);
return success;
}

int main(int argc, char **argv) {

test_rs_decode(/* seed */ 1,
/* trials */ 10000,
/* symsize */ 8,
/* gfpoly */ flightaware::uat::fec::DOWNLINK_SHORT_POLY,
/* fcr */ 120,
/* prim */ 1,
/* nroots */ flightaware::uat::fec::DOWNLINK_SHORT_ROOTS,
/* pad */ flightaware::uat::fec::DOWNLINK_SHORT_PAD);

test_rs_decode(/* seed */ 1,
/* trials */ 10000,
/* symsize */ 8,
/* gfpoly */ flightaware::uat::fec::DOWNLINK_LONG_POLY,
/* fcr */ 120,
/* prim */ 1,
/* nroots */ flightaware::uat::fec::DOWNLINK_LONG_ROOTS,
/* pad */ flightaware::uat::fec::DOWNLINK_LONG_PAD);

test_rs_decode(/* seed */ 1,
/* trials */ 10000,
/* symsize */ 8,
/* gfpoly */ flightaware::uat::fec::UPLINK_BLOCK_POLY,
/* fcr */ 120,
/* prim */ 1,
/* nroots */ flightaware::uat::fec::UPLINK_BLOCK_ROOTS,
/* pad */ flightaware::uat::fec::UPLINK_BLOCK_PAD);
int main(int argc, char **argv)
{
bool success = true;

success = test_rs_decode(/* seed */ 1,
/* trials */ 10000,
/* symsize */ 8,
/* gfpoly */ flightaware::uat::fec::DOWNLINK_SHORT_POLY,
/* fcr */ 120,
/* prim */ 1,
/* nroots */ flightaware::uat::fec::DOWNLINK_SHORT_ROOTS,
/* pad */ flightaware::uat::fec::DOWNLINK_SHORT_PAD) && success;

success = test_rs_decode(/* seed */ 1,
/* trials */ 10000,
/* symsize */ 8,
/* gfpoly */ flightaware::uat::fec::DOWNLINK_LONG_POLY,
/* fcr */ 120,
/* prim */ 1,
/* nroots */ flightaware::uat::fec::DOWNLINK_LONG_ROOTS,
/* pad */ flightaware::uat::fec::DOWNLINK_LONG_PAD) && success;

success = test_rs_decode(/* seed */ 1,
/* trials */ 10000,
/* symsize */ 8,
/* gfpoly */ flightaware::uat::fec::UPLINK_BLOCK_POLY,
/* fcr */ 120,
/* prim */ 1,
/* nroots */ flightaware::uat::fec::UPLINK_BLOCK_ROOTS,
/* pad */ flightaware::uat::fec::UPLINK_BLOCK_PAD) && success;

return success ? EXIT_SUCCESS : EXIT_FAILURE;
}