Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add integration tests #387

Open
wants to merge 8 commits into
base: unstable
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile.ubuntu-20.04
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM ubuntu:20.04

RUN apt-get update && \
apt-get install -y
apt-get upgrade -y

RUN sed -i 's/^# \(.*export LS_OPTIONS.*$\)/\1/g' ~/.bashrc && \
sed -i 's/^# \(.*alias ll.*$\)/\1/g' ~/.bashrc
Expand Down
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile.ubuntu-latest
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM ubuntu:latest

RUN apt-get update && \
apt-get install -y
apt-get upgrade -y

RUN sed -i 's/^# \(.*export LS_OPTIONS.*$\)/\1/g' ~/.bashrc && \
sed -i 's/^# \(.*alias ll.*$\)/\1/g' ~/.bashrc
Expand Down
3 changes: 2 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"ms-vscode.cpptools-extension-pack",
"twxs.cmake",
"streetsidesoftware.code-spell-checker",
"ms-azuretools.vscode-docker"
"ms-azuretools.vscode-docker",
"github.vscode-github-actions"
]
}
},
Expand Down
4 changes: 2 additions & 2 deletions .github/install_dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ case "${unameOut}" in
Linux*)
echo "Installing Linux dependencies"
sudo apt-get update -y
sudo apt-get install -y \
sudo apt-get install -y --no-install-recommends \
build-essential \
cmake \
libmp3lame-dev \
libshout3-dev \
libconfig++-dev \
'libconfig++-dev' \
libfftw3-dev \
librtlsdr-dev \
libsoapysdr-dev \
Expand Down
19 changes: 19 additions & 0 deletions .github/workflows/integration_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Integration Tests

on:
push:
branches: [main, unstable]
pull_request:
schedule:
- cron: '39 13 * * *' # run daily

jobs:
build:
runs-on: [rpi3b]
timeout-minutes: 10
steps:
- name: Checkout repository
uses: actions/checkout@main

- name: Integration Tests
run: integration_tests/run
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ build*/
.cache
compile_commands.json
rtl_airband*.log
integration_tests/rpiv2
integration_tests/native
222 changes: 222 additions & 0 deletions integration_tests/configs/noaa.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,222 @@
fft_size = 512;
devices:
(
{
type = "rtlsdr";
serial = "device1";
gain = 16.6;
centerfreq = 162.00000;
correction = 0;
sample_rate = 2.40;
channels:
(
{
freq = 162.40000;
label = "NOAA 162.400 (162.40000)";
modulation = "nfm";
squelch_snr_threshold = 0.00;
outputs:
(
{
type = "file";
directory = "./";
filename_template = "NOAA_162.400_rtlsdr";
}
);
},
{
freq = 162.42500;
label = "NOAA 162.425 (162.42500)";
modulation = "nfm";
squelch_snr_threshold = 0.00;
outputs:
(
{
type = "file";
directory = "./";
filename_template = "NOAA_162.425_rtlsdr";
}
);
},
{
freq = 162.45000;
label = "NOAA 162.450 (162.45000)";
modulation = "nfm";
squelch_snr_threshold = 0.00;
outputs:
(
{
type = "file";
directory = "./";
filename_template = "NOAA_162.450_rtlsdr";
}
);
},
{
freq = 162.47500;
label = "NOAA 162.475 (162.47500)";
modulation = "nfm";
squelch_snr_threshold = 0.00;
outputs:
(
{
type = "file";
directory = "./";
filename_template = "NOAA_162.475_rtlsdr";
}
);
},
{
freq = 162.50000;
label = "NOAA 162.500 (162.50000)";
modulation = "nfm";
squelch_snr_threshold = 0.00;
outputs:
(
{
type = "file";
directory = "./";
filename_template = "NOAA_162.500_rtlsdr";
}
);
},
{
freq = 162.52500;
label = "NOAA 162.525 (162.52500)";
modulation = "nfm";
squelch_snr_threshold = 0.00;
outputs:
(
{
type = "file";
directory = "./";
filename_template = "NOAA_162.525_rtlsdr";
}
);
},
{
freq = 162.55000;
label = "NOAA 162.550 (162.55000)";
modulation = "nfm";
squelch_snr_threshold = 0.00;
outputs:
(
{
type = "file";
directory = "./";
filename_template = "NOAA_162.550_rtlsdr";
}
);
}
);
},
{
type = "soapysdr";
device_string = "driver=airspy,device_id=0";
gain = 16.6;
centerfreq = 162.00000;
correction = 0;
sample_rate = 3.0;
channels:
(
{
freq = 162.40000;
label = "NOAA 162.400 (162.40000)";
modulation = "nfm";
squelch_snr_threshold = 0.00;
outputs:
(
{
type = "file";
directory = "./";
filename_template = "NOAA_162.400_soapysdr";
}
);
},
{
freq = 162.42500;
label = "NOAA 162.425 (162.42500)";
modulation = "nfm";
squelch_snr_threshold = 0.00;
outputs:
(
{
type = "file";
directory = "./";
filename_template = "NOAA_162.425_soapysdr";
}
);
},
{
freq = 162.45000;
label = "NOAA 162.450 (162.45000)";
modulation = "nfm";
squelch_snr_threshold = 0.00;
outputs:
(
{
type = "file";
directory = "./";
filename_template = "NOAA_162.450_soapysdr";
}
);
},
{
freq = 162.47500;
label = "NOAA 162.475 (162.47500)";
modulation = "nfm";
squelch_snr_threshold = 0.00;
outputs:
(
{
type = "file";
directory = "./";
filename_template = "NOAA_162.475_soapysdr";
}
);
},
{
freq = 162.50000;
label = "NOAA 162.500 (162.50000)";
modulation = "nfm";
squelch_snr_threshold = 0.00;
outputs:
(
{
type = "file";
directory = "./";
filename_template = "NOAA_162.500_soapysdr";
}
);
},
{
freq = 162.52500;
label = "NOAA 162.525 (162.52500)";
modulation = "nfm";
squelch_snr_threshold = 0.00;
outputs:
(
{
type = "file";
directory = "./";
filename_template = "NOAA_162.525_soapysdr";
}
);
},
{
freq = 162.55000;
label = "NOAA 162.550 (162.55000)";
modulation = "nfm";
squelch_snr_threshold = 0.00;
outputs:
(
{
type = "file";
directory = "./";
filename_template = "NOAA_162.550_soapysdr";
}
);
}
);
}
);
81 changes: 81 additions & 0 deletions integration_tests/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#!/bin/bash

set -x
set -e

function run_rtl_airband {
BIN_PATH=$1
CONFIG_PATH=$2
OUTPUT_DIR=$3

mkdir -p ${OUTPUT_DIR}
pushd ${OUTPUT_DIR}

# run for 30 seconds then send kill command
sudo ${BIN_PATH} -c ${CONFIG_PATH} -F -e &
PID=$!
sleep 30
sudo kill -SIGINT $PID

# wait 5 seconds for files to be closed and renamed
sleep 5

# make sure there is at least one NOAA channel that generated an MP3 longer
# than 10 seconds for each rtl and soapy (not 30 seconds because of startup time)
check_length '*_rtlsdr_*.mp3'
check_length '*_soapysdr_*.mp3'

popd

}

function check_length {

for i in $@ ; do

seconds=$(ffmpeg -i $i -f null - 2>&1 | grep time | awk '{print $2}' | cut -d ':' -f 3)
echo "$i is $seconds sec long"
if (( $(echo "$seconds > 10.0" | bc -l) )); then
return 0
fi

done

return -1

}

REPO_DIR=$(readlink -f `dirname ${0}`/../)

INTEGRATION_TESTS_DIR=${REPO_DIR}/integration_tests

# make a work dir
WORK_DIR=${INTEGRATION_TESTS_DIR}/work
rm -rf ${WORK_DIR} || true

cd ${REPO_DIR}

# build a version that uses the Broadcom VideoCore GPU
GPU_BUILD_DIR=${WORK_DIR}/build_rpiv2
cmake -B ${GPU_BUILD_DIR} -DNFM=TRUE -DPLATFORM=rpiv2 -DCMAKE_BUILD_TYPE=Release
VERBOSE=1 cmake --build ${GPU_BUILD_DIR} -j2

# make sure the binary is linking about the GPU library
ldd ${GPU_BUILD_DIR}/src/rtl_airband | grep libbcm_host


# build a version that uses FFTW
FFTW_BUILD_DIR=${WORK_DIR}/build_native
cmake -B ${FFTW_BUILD_DIR} -DNFM=TRUE -DPLATFORM=native -DCMAKE_BUILD_TYPE=Release
VERBOSE=1 cmake --build ${FFTW_BUILD_DIR} -j2

# make sure the binary is linking against the FFTW library
ldd ${FFTW_BUILD_DIR}/src/rtl_airband | grep libfftw3f


# run the noaa config twice, once for each binary
GPU_OUTPUT_DIR=${WORK_DIR}/output_rpiv2/
FFTW_OUTPUT_DIR=${WORK_DIR}/output_native/
run_rtl_airband ${GPU_BUILD_DIR}/src/rtl_airband ${INTEGRATION_TESTS_DIR}/configs/noaa.conf ${GPU_OUTPUT_DIR}
run_rtl_airband ${FFTW_BUILD_DIR}/src/rtl_airband ${INTEGRATION_TESTS_DIR}/configs/noaa.conf ${FFTW_OUTPUT_DIR}