Skip to content

Commit 1b6d96a

Browse files
authored
Merge pull request #9 from sdr-enthusiasts/unittests
Unittests
2 parents 0981f2d + fe33c2e commit 1b6d96a

File tree

25 files changed

+1183
-468
lines changed

25 files changed

+1183
-468
lines changed

.github/workflows/on_pr.yaml

Lines changed: 29 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -82,39 +82,30 @@ jobs:
8282
- name: Run hadolint against Dockerfiles
8383
run: docker run --rm -i -v "$PWD":/workdir --workdir /workdir --entrypoint hadolint hadolint/hadolint --ignore DL3013 --ignore DL3008 $(find . -type f -iname "Dockerfile*")
8484

85-
# test_rust_functionality:
86-
# name: Build and test rust functionality
87-
# runs-on: ubuntu-latest
88-
89-
# steps:
90-
# - name: Checkout
91-
# uses: actions/[email protected]
92-
# with:
93-
# fetch-depth: 0
94-
95-
# - name: Install Rust and deps
96-
# run: |
97-
# curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
98-
# sudo apt-get update
99-
# sudo apt-get install -y --no-install-recommends libzmq3-dev
100-
# python3 -m pip install zmq
101-
102-
# - name: Get binary version from Cargo.toml
103-
# id: release_version
104-
# run: |
105-
# # Get version from Cargo.toml
106-
# 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)
107-
# echo "$RELEASE_VERSION"
108-
109-
# - name: Run tests
110-
# run: |
111-
# cd test_data
112-
# ./run_acars_ruster_test.sh
85+
test_rust_functionality:
86+
name: Build and test rust functionality
87+
runs-on: ubuntu-latest
88+
89+
steps:
90+
- name: Checkout
91+
uses: actions/[email protected]
92+
with:
93+
fetch-depth: 0
94+
95+
- name: Install Rust and deps
96+
run: |
97+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
98+
sudo apt-get update
99+
sudo apt-get install -y --no-install-recommends libzmq3-dev librtlsdr-dev
100+
101+
- name: Run tests
102+
run: |
103+
env CARGO_NET_GIT_FETCH_WITH_CLI=true cargo test
113104
114105
binary_build_armv7:
115106
name: Build Binary - armv7
116107
runs-on: ubuntu-latest
117-
# needs: test_rust_functionality
108+
needs: test_rust_functionality
118109

119110
steps:
120111
- name: Checkout
@@ -154,7 +145,7 @@ jobs:
154145
binary_build_arm64:
155146
name: Build Binary - arm64
156147
runs-on: ubuntu-latest
157-
# needs: test_rust_functionality
148+
needs: test_rust_functionality
158149

159150
steps:
160151
- name: Checkout
@@ -194,7 +185,7 @@ jobs:
194185
binary_build_amd64:
195186
name: Build Binary - amd64
196187
runs-on: ubuntu-latest
197-
# needs: test_rust_functionality
188+
needs: test_rust_functionality
198189

199190
steps:
200191
- name: Checkout
@@ -234,7 +225,13 @@ jobs:
234225
consolidate_binaries:
235226
name: Consolidate & Cache Binaries
236227
runs-on: ubuntu-latest
237-
needs: [binary_build_amd64, binary_build_arm64, binary_build_armv7]
228+
needs:
229+
[
230+
binary_build_amd64,
231+
binary_build_arm64,
232+
binary_build_armv7,
233+
test_rust_functionality,
234+
]
238235
steps:
239236
- run: mkdir -p ./bin
240237

Cargo.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,17 @@ members = [
33
"rust/oxide-bin",
44
"rust/oxide-config",
55
"rust/oxide-decoders",
6-
"rust/oxide-logging",
6+
"rust/oxide-helpers",
77
"rust/oxide-output",
88
"rust/oxide-rtlsdr",
99
"rust/oxide-scanner",
1010
]
1111

12+
exclude = ["sample-grabber"]
13+
1214
[workspace.package]
1315
edition = "2021"
14-
version = "0.1.2"
16+
version = "0.1.3"
1517
authors = ["Fred Clausen"]
1618
description = "ACARS Oxide. A utility to receive, via librtlsdr and RTL-SDR dongle(s), ACARS and VDLM2 messages."
1719
documentation = "https://github.com/sdr-enthusiasts/acars-oxide"

rust/oxide-bin/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ rust-version.workspace = true
1515
log = "0.4.17"
1616
oxide-rtlsdr = { path = "../oxide-rtlsdr" }
1717
oxide-config = { path = "../oxide-config" }
18-
oxide-logging = { path = "../oxide-logging" }
1918
oxide-scanner = { path = "../oxide-scanner" }
2019
oxide-decoders = { path = "../oxide-decoders" }
20+
sdre-rust-logging = { git = "https://github.com/sdr-enthusiasts/sdre-rust-logging.git" }
2121
tokio = { version = "1.28.1", features = ["full", "tracing"] }
2222
array-init = "2.1.0"

rust/oxide-bin/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ extern crate oxide_rtlsdr;
2121
use oxide_config::clap::Parser;
2222
use oxide_config::OxideInput;
2323
use oxide_decoders::ValidDecoderType;
24-
use oxide_logging::SetupLogging;
2524
use oxide_rtlsdr::RtlSdr;
25+
use sdre_rust_logging::SetupLogging;
2626
use tokio::time::{sleep, Duration};
2727

2828
#[tokio::main]

rust/oxide-config/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ license.workspace = true
1212
rust-version.workspace = true
1313

1414
[dependencies]
15-
clap = { version = "4.2.7", features = ["derive", "env"] }
15+
clap = { version = "4.3.0", features = ["derive", "env"] }
1616
custom_error = "1.9.2"
1717
oxide-decoders = { path = "../oxide-decoders" }

rust/oxide-config/src/lib.rs

Lines changed: 0 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -641,66 +641,3 @@ fn parse_sdr_gain(env: &str) -> Result<i32, OxideInputError> {
641641
}
642642
Ok(gain as i32 * 10)
643643
}
644-
645-
/// A struct encapsulating the configuration for a single SDR
646-
pub struct SDRConfig {
647-
pub gain: Option<u32>,
648-
pub ppm: Option<i32>,
649-
pub bias_tee: Option<bool>,
650-
pub mult: Option<f32>,
651-
pub freq: Option<Vec<String>>,
652-
pub serial: Option<String>,
653-
}
654-
655-
impl SDRConfig {
656-
pub fn new(
657-
gain: Option<u32>,
658-
ppm: Option<i32>,
659-
bias_tee: Option<bool>,
660-
mult: Option<f32>,
661-
freq: Option<Vec<String>>,
662-
serial: Option<String>,
663-
) -> SDRConfig {
664-
SDRConfig {
665-
gain,
666-
ppm,
667-
bias_tee,
668-
mult,
669-
freq,
670-
serial,
671-
}
672-
}
673-
674-
pub fn get_gain(&self) -> Option<u32> {
675-
self.gain
676-
}
677-
678-
pub fn get_ppm(&self) -> Option<i32> {
679-
self.ppm
680-
}
681-
682-
pub fn get_bias_tee(&self) -> Option<bool> {
683-
self.bias_tee
684-
}
685-
686-
pub fn get_mult(&self) -> Option<f32> {
687-
self.mult
688-
}
689-
690-
pub fn get_freq(&self) -> Option<Vec<String>> {
691-
self.freq.clone()
692-
}
693-
694-
pub fn get_serial(&self) -> Option<String> {
695-
self.serial.clone()
696-
}
697-
698-
/// A function to determine if the SDR has been enabled by the user
699-
pub fn is_empty(&self) -> bool {
700-
if self.serial.is_none() && self.freq.is_none() {
701-
return true;
702-
}
703-
704-
false
705-
}
706-
}

rust/oxide-decoders/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@ rust-version.workspace = true
1515
log = "0.4.17"
1616
custom_error = "1.9.2"
1717
num = "0.4.0"
18-
tokio = { version = "1.28.1", features = ["full", "tracing"] }
18+
tokio = { version = "1.28.2", features = ["full", "tracing"] }
19+
oxide-helpers = { path = "../oxide-helpers" }
1920
# num-complex = "0.4.3"

0 commit comments

Comments
 (0)