-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci, sample: add tests for child processes
Testing child processes is a little out-of-scope for `cargo test`, but they need testing all the same. Include a child process test in our existing CI integration tests. The sample recordings are played back through samedec. A bash script for each verifies that the $ENVironment is as expected.
- Loading branch information
Showing
9 changed files
with
101 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
set -e | ||
|
||
# close standard input to ignore it | ||
exec 0>/dev/null | ||
|
||
[[ $SAMEDEC_RATE = "22050" ]] | ||
[[ $SAMEDEC_EVENT = "Practice/Demo Warning" ]] | ||
[[ $SAMEDEC_ORG = "EAS" ]] | ||
[[ $SAMEDEC_SIGNIFICANCE = "W" ]] | ||
[[ $SAMEDEC_LOCATIONS = "372088 091724 919623 645687 745748 175234 039940 955869 091611 304171 931612 334828 179485 569615 809223 830187 611340 014693 472885 084645 977764 466883 406863 390018 701741 058097 752790 311648 820127 255900 581947" ]] | ||
[[ $SAMEDEC_ISSUETIME = "$SAMEDEC_PURGETIME" ]] | ||
|
||
echo "+OK" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
ZCZC-EAS-DMO-372088-091724-919623-645687-745748-175234-039940-955869-091611-304171-931612-334828-179485-569615-809223-830187-611340-014693-472885-084645-977764-466883-406863-390018-701741-058097-752790-311648-820127-255900-581947+0000-0001122-NOCALL00- | ||
+OK |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
set -e | ||
|
||
# close standard input to ignore it | ||
exec 0>/dev/null | ||
|
||
[[ $SAMEDEC_EVENT = "National Periodic Test" ]] | ||
[[ $SAMEDEC_ORG = "PEP" ]] | ||
[[ $SAMEDEC_SIGNIFICANCE = "T" ]] | ||
[[ $SAMEDEC_LOCATIONS = "000000" ]] | ||
|
||
lifetime=$(( $SAMEDEC_PURGETIME - $SAMEDEC_ISSUETIME)) | ||
[[ $lifetime -eq $(( 30*60 )) ]] | ||
|
||
echo "+OK" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
ZCZC-PEP-NPT-000000+0030-2771820-TEST - | ||
+OK |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# Runs integration tests for samedec. | ||
# | ||
# cd sample/ | ||
# ./test.sh | ||
# | ||
# By default, this will build and run a debug-mode samedec | ||
# with cargo. You may also set SAMEDEC to the path to an | ||
# existing executable. | ||
# | ||
# The integration tests ensure that samedec's child process | ||
# spawning and environment variable assignment works. | ||
|
||
set -euo pipefail | ||
|
||
if [ -n "${SAMEDEC:-}" ]; then | ||
RUNARGS=("${SAMEDEC}") | ||
else | ||
RUNARGS=('cargo' 'run' '-q' '-p' 'samedec' '--') | ||
fi | ||
|
||
run_samedec() { | ||
# Usage: run_samedec FILE | ||
# Runs `samedec` on given input file stem | ||
|
||
infile="$1" | ||
|
||
"${RUNARGS[@]}" \ | ||
--rate 22050 \ | ||
--file "${infile}.bin" \ | ||
-- \ | ||
bash \ | ||
"${infile}.bash" | tee /dev/stderr | ||
} | ||
|
||
for file in $(basename -s .bin *.s16le.bin); do | ||
[ -e "${file}.bin" ] || exit 1 | ||
|
||
printf '[%s]\n' "$file" | ||
|
||
cmp <(run_samedec "$file") "$file.txt" || { | ||
printf '[%s]: FAIL\n' "$file" | ||
exit 1 | ||
}; | ||
|
||
printf '[%s]: PASS\n' "$file" | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
set -e | ||
|
||
# close standard input to ignore it | ||
exec 0>/dev/null | ||
|
||
[[ $SAMEDEC_EVENT = "Severe Thunderstorm Warning" ]] | ||
[[ $SAMEDEC_ORIGINATOR = "Weather Service" ]] | ||
[[ $SAMEDEC_SIGNIFICANCE = "W" ]] | ||
|
||
lifetime=$(( $SAMEDEC_PURGETIME - $SAMEDEC_ISSUETIME)) | ||
[[ $lifetime -eq $(( 1*60*60 + 30*60 )) ]] | ||
|
||
echo "+OK" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
NNNN | ||
ZCZC-WXR-SVR-012079-013019-013027-013075-013185-013173+0130-0462024-N0C4LL - | ||
+OK |