move scripts directory

This commit is contained in:
Roman Zeyde
2014-08-07 17:04:39 +03:00
parent 0b91ef76c5
commit e4ba6cf232
3 changed files with 6 additions and 6 deletions

57
scripts/test.sh Executable file
View File

@@ -0,0 +1,57 @@
#!/bin/bash
set -u
set -e
run() {
echo "SRC $HOST ($DIR): $*" 1>&2
if [ "$HOST" == "localhost" ]; then
echo "$*" | bash
else
ssh $HOST "cd $DIR; $*"
fi
}
run_src() {
DIR=${SRC_DIR:-"$PWD"}
HOST=${SRC_HOST:-localhost}
run "$*"
}
run_dst() {
DIR=${DST_DIR:-"$PWD"}
HOST=${DST_HOST:-localhost}
run "$*"
}
TEST_DIR=test_results
run_src mkdir -p $TEST_DIR
run_dst mkdir -p $TEST_DIR
## generate 1Mbit of random data
run_src dd if=/dev/urandom of=$TEST_DIR/data.send bs=125kB count=1 status=none
SRC_HASH=`run_src sha256sum $TEST_DIR/data.send`
# modulate data into audio file
run_src "python -m amodem.send -i $TEST_DIR/data.send -o $TEST_DIR/audio.send"
# stop old recording and start a new one
run_src killall -q aplay || true
run_dst killall -q arecord || true
run_dst "python -m amodem.wave record $TEST_DIR/audio.recv" &
sleep 1 # let audio.recv be filled
# play the modulated data
run_src "python -m amodem.wave play $TEST_DIR/audio.send" &
# start the receiever
run_dst "python -m amodem.recv -i $TEST_DIR/audio.recv -o $TEST_DIR/data.recv"
# stop recording after playing is over
run_src killall -q aplay || true
run_dst killall -q arecord || true
# verify transmittion
DST_HASH=`run_dst sha256sum $TEST_DIR/data.recv`
echo -e "$SRC_HASH\n$DST_HASH"