Skip to content

Commit

Permalink
Merge pull request #9 from sdr-enthusiasts/unittests
Browse files Browse the repository at this point in the history
Unittests
  • Loading branch information
fredclausen authored May 28, 2023
2 parents 0981f2d + fe33c2e commit 1b6d96a
Show file tree
Hide file tree
Showing 25 changed files with 1,183 additions and 468 deletions.
61 changes: 29 additions & 32 deletions .github/workflows/on_pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,39 +82,30 @@ jobs:
- name: Run hadolint against Dockerfiles
run: docker run --rm -i -v "$PWD":/workdir --workdir /workdir --entrypoint hadolint hadolint/hadolint --ignore DL3013 --ignore DL3008 $(find . -type f -iname "Dockerfile*")

# test_rust_functionality:
# name: Build and test rust functionality
# runs-on: ubuntu-latest

# steps:
# - name: Checkout
# uses: actions/[email protected]
# with:
# fetch-depth: 0

# - name: Install Rust and deps
# run: |
# curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
# sudo apt-get update
# sudo apt-get install -y --no-install-recommends libzmq3-dev
# python3 -m pip install zmq

# - name: Get binary version from Cargo.toml
# id: release_version
# run: |
# # Get version from Cargo.toml
# RELEASE_VERSION=$(cat ./rust/bin/acars_router/Cargo.toml | grep '\[package\]' -A9999 | grep -m 1 'version = ' | tr -d " " | tr -d '"' | tr -d "'" | cut -d = -f 2)
# echo "$RELEASE_VERSION"

# - name: Run tests
# run: |
# cd test_data
# ./run_acars_ruster_test.sh
test_rust_functionality:
name: Build and test rust functionality
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/[email protected]
with:
fetch-depth: 0

- name: Install Rust and deps
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
sudo apt-get update
sudo apt-get install -y --no-install-recommends libzmq3-dev librtlsdr-dev
- name: Run tests
run: |
env CARGO_NET_GIT_FETCH_WITH_CLI=true cargo test
binary_build_armv7:
name: Build Binary - armv7
runs-on: ubuntu-latest
# needs: test_rust_functionality
needs: test_rust_functionality

steps:
- name: Checkout
Expand Down Expand Up @@ -154,7 +145,7 @@ jobs:
binary_build_arm64:
name: Build Binary - arm64
runs-on: ubuntu-latest
# needs: test_rust_functionality
needs: test_rust_functionality

steps:
- name: Checkout
Expand Down Expand Up @@ -194,7 +185,7 @@ jobs:
binary_build_amd64:
name: Build Binary - amd64
runs-on: ubuntu-latest
# needs: test_rust_functionality
needs: test_rust_functionality

steps:
- name: Checkout
Expand Down Expand Up @@ -234,7 +225,13 @@ jobs:
consolidate_binaries:
name: Consolidate & Cache Binaries
runs-on: ubuntu-latest
needs: [binary_build_amd64, binary_build_arm64, binary_build_armv7]
needs:
[
binary_build_amd64,
binary_build_arm64,
binary_build_armv7,
test_rust_functionality,
]
steps:
- run: mkdir -p ./bin

Expand Down
6 changes: 4 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@ members = [
"rust/oxide-bin",
"rust/oxide-config",
"rust/oxide-decoders",
"rust/oxide-logging",
"rust/oxide-helpers",
"rust/oxide-output",
"rust/oxide-rtlsdr",
"rust/oxide-scanner",
]

exclude = ["sample-grabber"]

[workspace.package]
edition = "2021"
version = "0.1.2"
version = "0.1.3"
authors = ["Fred Clausen"]
description = "ACARS Oxide. A utility to receive, via librtlsdr and RTL-SDR dongle(s), ACARS and VDLM2 messages."
documentation = "https://github.com/sdr-enthusiasts/acars-oxide"
Expand Down
2 changes: 1 addition & 1 deletion rust/oxide-bin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ rust-version.workspace = true
log = "0.4.17"
oxide-rtlsdr = { path = "../oxide-rtlsdr" }
oxide-config = { path = "../oxide-config" }
oxide-logging = { path = "../oxide-logging" }
oxide-scanner = { path = "../oxide-scanner" }
oxide-decoders = { path = "../oxide-decoders" }
sdre-rust-logging = { git = "https://github.com/sdr-enthusiasts/sdre-rust-logging.git" }
tokio = { version = "1.28.1", features = ["full", "tracing"] }
array-init = "2.1.0"
2 changes: 1 addition & 1 deletion rust/oxide-bin/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ extern crate oxide_rtlsdr;
use oxide_config::clap::Parser;
use oxide_config::OxideInput;
use oxide_decoders::ValidDecoderType;
use oxide_logging::SetupLogging;
use oxide_rtlsdr::RtlSdr;
use sdre_rust_logging::SetupLogging;
use tokio::time::{sleep, Duration};

#[tokio::main]
Expand Down
2 changes: 1 addition & 1 deletion rust/oxide-config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ license.workspace = true
rust-version.workspace = true

[dependencies]
clap = { version = "4.2.7", features = ["derive", "env"] }
clap = { version = "4.3.0", features = ["derive", "env"] }
custom_error = "1.9.2"
oxide-decoders = { path = "../oxide-decoders" }
63 changes: 0 additions & 63 deletions rust/oxide-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -641,66 +641,3 @@ fn parse_sdr_gain(env: &str) -> Result<i32, OxideInputError> {
}
Ok(gain as i32 * 10)
}

/// A struct encapsulating the configuration for a single SDR
pub struct SDRConfig {
pub gain: Option<u32>,
pub ppm: Option<i32>,
pub bias_tee: Option<bool>,
pub mult: Option<f32>,
pub freq: Option<Vec<String>>,
pub serial: Option<String>,
}

impl SDRConfig {
pub fn new(
gain: Option<u32>,
ppm: Option<i32>,
bias_tee: Option<bool>,
mult: Option<f32>,
freq: Option<Vec<String>>,
serial: Option<String>,
) -> SDRConfig {
SDRConfig {
gain,
ppm,
bias_tee,
mult,
freq,
serial,
}
}

pub fn get_gain(&self) -> Option<u32> {
self.gain
}

pub fn get_ppm(&self) -> Option<i32> {
self.ppm
}

pub fn get_bias_tee(&self) -> Option<bool> {
self.bias_tee
}

pub fn get_mult(&self) -> Option<f32> {
self.mult
}

pub fn get_freq(&self) -> Option<Vec<String>> {
self.freq.clone()
}

pub fn get_serial(&self) -> Option<String> {
self.serial.clone()
}

/// A function to determine if the SDR has been enabled by the user
pub fn is_empty(&self) -> bool {
if self.serial.is_none() && self.freq.is_none() {
return true;
}

false
}
}
3 changes: 2 additions & 1 deletion rust/oxide-decoders/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ rust-version.workspace = true
log = "0.4.17"
custom_error = "1.9.2"
num = "0.4.0"
tokio = { version = "1.28.1", features = ["full", "tracing"] }
tokio = { version = "1.28.2", features = ["full", "tracing"] }
oxide-helpers = { path = "../oxide-helpers" }
# num-complex = "0.4.3"
Loading

0 comments on commit 1b6d96a

Please sign in to comment.