From cb9b7c0b14a7f0af7fb3359470ab912c46cc2341 Mon Sep 17 00:00:00 2001 From: Michael Ossmann Date: Wed, 28 Sep 2022 18:32:08 -0400 Subject: [PATCH 1/2] CI: add single-device hackrf_transfer tests --- Jenkinsfile | 1 + ci-scripts/test-transfer-single.sh | 54 ++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100755 ci-scripts/test-transfer-single.sh diff --git a/Jenkinsfile b/Jenkinsfile index 3d5ea101..150eca89 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -25,6 +25,7 @@ pipeline { sh './ci-scripts/test-firmware-program.sh' } sh './ci-scripts/test-firmware-flash.sh' + sh './ci-scripts/test-transfer-single.sh' } } } diff --git a/ci-scripts/test-transfer-single.sh b/ci-scripts/test-transfer-single.sh new file mode 100755 index 00000000..4dc6b656 --- /dev/null +++ b/ci-scripts/test-transfer-single.sh @@ -0,0 +1,54 @@ +#!/bin/bash +echo "Single-device hackrf_transfer tests:" +echo "Testing single sample transmit: -c0" +timeout -s2 -k1 2 hackrf_transfer -a0 -x0 -c0 -n1 >/tmp/stdout.$$ 2>/tmp/stderr.$$ +EXIT_CODE="$?" +if [ "$EXIT_CODE" == "124" ] +then + cat /tmp/stderr.$$ + echo "Command timed out (SIGINT after 2 seconds)." + exit $EXIT_CODE +elif [ "$EXIT_CODE" == "137" ] +then + cat /tmp/stderr.$$ + echo "Command timed out (SIGKILL after 3 seconds)." + exit $EXIT_CODE +elif [ "$EXIT_CODE" != "0" ] +then + cat /tmp/stderr.$$ + echo "unexpected exit code" + exit $EXIT_CODE +else + echo "hackrf_transfer command completed." +fi + +grep -q "Couldn't transfer any bytes for one second." /tmp/stderr.$$ +if [ "$?" == "0" ] +then + cat /tmp/stderr.$$ + exit 1 +fi + +grep -q "average power -inf dBfs" /tmp/stderr.$$ +if [ "$?" != "0" ] +then + cat /tmp/stderr.$$ + "unexpected power level" + exit 2 +fi + +grep -q "^ 0.0 MiB" /tmp/stderr.$$ +if [ "$?" != "0" ] +then + cat /tmp/stderr.$$ + "unexpected total data transferred" + exit 3 +fi + +if [ -s "/tmp/stdout.$$" ] +then + cat /tmp/stderr.$$ + "unexpected stdout:" + cat /tmp/stdout.$$ + exit 4 +fi From 0299f70a367f86d3b058de4135d547962102a5e7 Mon Sep 17 00:00:00 2001 From: Michael Ossmann Date: Wed, 28 Sep 2022 18:36:16 -0400 Subject: [PATCH 2/2] add full path --- ci-scripts/test-transfer-single.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ci-scripts/test-transfer-single.sh b/ci-scripts/test-transfer-single.sh index 4dc6b656..3d39aed3 100755 --- a/ci-scripts/test-transfer-single.sh +++ b/ci-scripts/test-transfer-single.sh @@ -1,7 +1,8 @@ #!/bin/bash echo "Single-device hackrf_transfer tests:" echo "Testing single sample transmit: -c0" -timeout -s2 -k1 2 hackrf_transfer -a0 -x0 -c0 -n1 >/tmp/stdout.$$ 2>/tmp/stderr.$$ +COMMAND=host/build/hackrf-tools/src/hackrf_transfer +timeout -s2 -k1 2 ${COMMAND} -a0 -x0 -c0 -n1 >/tmp/stdout.$$ 2>/tmp/stderr.$$ EXIT_CODE="$?" if [ "$EXIT_CODE" == "124" ] then