aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore4
-rwxr-xr-xreference/snowcast_controlbin1815928 -> 1860760 bytes
-rwxr-xr-xreference/snowcast_listenerbin1491352 -> 1514808 bytes
-rwxr-xr-xreference/snowcast_serverbin2005080 -> 2050008 bytes
-rwxr-xr-xutil/run_tests171
-rwxr-xr-xutil/tester/control_testerbin0 -> 7031352 bytes
-rw-r--r--util/tester/data/short_filebin0 -> 20480 bytes
-rw-r--r--util/tester/data/test.txt12
-rwxr-xr-xutil/tester/server_testerbin0 -> 7055960 bytes
9 files changed, 187 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index fe83c75..440b509 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,3 +3,7 @@
*.o
.DS_Store
+
+# Created by tester
+/stations
+/reference/stations
diff --git a/reference/snowcast_control b/reference/snowcast_control
index f64b016..866cead 100755
--- a/reference/snowcast_control
+++ b/reference/snowcast_control
Binary files differ
diff --git a/reference/snowcast_listener b/reference/snowcast_listener
index 34a542c..6033d3f 100755
--- a/reference/snowcast_listener
+++ b/reference/snowcast_listener
Binary files differ
diff --git a/reference/snowcast_server b/reference/snowcast_server
index d61d179..8107323 100755
--- a/reference/snowcast_server
+++ b/reference/snowcast_server
Binary files differ
diff --git a/util/run_tests b/util/run_tests
new file mode 100755
index 0000000..22f1d54
--- /dev/null
+++ b/util/run_tests
@@ -0,0 +1,171 @@
+#!/bin/bash
+set -euo pipefail
+
+SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
+TESTER_DIR=${SCRIPT_DIR}/tester
+DATA_DIR=${TESTER_DIR}/data
+MP3_DIR=${SCRIPT_DIR}/../mp3
+
+# Set automatically
+arch="`uname -m`"
+platform=
+
+verbose=true
+fail_fast=false
+bin_dir=$(realpath ${SCRIPT_DIR}/..)
+
+__check_platform()
+{
+ if test -z "$platform" -a \( "$arch" = "arm64" -o "$arch" = "aarch64" \); then
+ platform=linux/arm64
+ elif test -z "$platform"; then
+ platform=linux/amd64
+ fi
+}
+
+do_help() {
+ echo "$0 --bin-dir . server"
+}
+
+check_exists() {
+ bin="$1"
+ if [[ ! -e ${bin} ]]; then
+ echo "Binary ${bin} not found! Exiting"
+ exit 1
+ fi
+}
+
+run_tester() {
+ tester_name=$1
+ shift
+
+ case $platform in
+ linux/amd64)
+ tester_path=${TESTER_DIR}/
+ ;;
+ linux/arm64)
+ tester_path=${TESTER_DIR}/arm64
+ ;;
+ *)
+ echo "Unsupported platform ${platform}"
+ exit 1
+ esac
+
+ vflag=""
+ if $verbose; then
+ vflag="-test.v"
+ fi
+
+ failflag=""
+ if $fail_fast; then
+ failflag="-test.failfast"
+ fi
+
+ export BIN_DIR=${bin_dir}
+ export MP3_DIR=$MP3_DIR
+ export DATA_DIR=$DATA_DIR
+ ${tester_path}/${tester_name} $vflag $failflag $@
+}
+
+do_server() {
+ check_exists "${bin_dir}/snowcast_server"
+ run_tester server_tester $@
+}
+
+do_control() {
+ check_exists "${bin_dir}/snowcast_server"
+ run_tester server_tester $@
+}
+
+do_milestone() {
+ do_control -test.run="Test.+?/Test(ConnectsToServer|AcceptsClientConnection|CompletesHandshake)"
+ do_server -test.v -test.run="Test.+?/Test(ConnectsToServer|AcceptsClientConnection|CompletesHandshake)"
+}
+
+
+do_all() {
+ do_server $@
+ do_control $@
+}
+
+main() {
+ POSITIONAL=()
+ while [[ $# -gt 0 ]]; do
+ key=$1
+ case $key in
+ --fail-fast|-f)
+ shift
+ fail_fast=true
+ ;;
+ --quiet|-q)
+ shift
+ verbose=false
+ ;;
+ -a|--arm|--arm64|--aarch64)
+ shift
+ if [[ ( "${arch}" == "arm64" ) || ( "${arch}" == "aarch64" ) ]]; then
+ platform=linux/arm64
+ else
+ echo "$0 --arm only works on arm64 hosts (platform is ${arch})" 1>&2
+ exit 1
+ fi
+ ;;
+ -x|--x86-64)
+ shift
+ platform=linux/amd64
+ ;;
+ --bin-dir)
+ bin_dir="$2"
+ shift
+ shift
+ ;;
+ --help)
+ shift
+ do_help
+ exit 0
+ ;;
+ *)
+ POSITIONAL+=("$1")
+ shift
+ esac
+ done
+ set -- "${POSITIONAL[@]}"
+
+ __check_platform
+
+ # Default subcommand
+ if [[ $# == 0 ]]; then
+ do_all
+ exit 0
+ fi
+
+ # Subcommands
+ case $1 in
+ help)
+ do_help
+ exit 0
+ ;;
+ server)
+ shift
+ do_server $@
+ ;;
+ control)
+ shift
+ do_control $@
+ ;;
+ milestone)
+ shift
+ do_milestone $@
+ ;;
+ all)
+ shift
+ do_all $@
+ ;;
+ *)
+ echo "Unrecognized command $1"
+ exit 1
+ ;;
+ esac
+}
+
+main $@
diff --git a/util/tester/control_tester b/util/tester/control_tester
new file mode 100755
index 0000000..942e960
--- /dev/null
+++ b/util/tester/control_tester
Binary files differ
diff --git a/util/tester/data/short_file b/util/tester/data/short_file
new file mode 100644
index 0000000..cc198a1
--- /dev/null
+++ b/util/tester/data/short_file
Binary files differ
diff --git a/util/tester/data/test.txt b/util/tester/data/test.txt
new file mode 100644
index 0000000..e4f841e
--- /dev/null
+++ b/util/tester/data/test.txt
@@ -0,0 +1,12 @@
+1234567
+1234567
+1234567
+1234567
+1234567
+1234567
+1234567
+1234567
+1234567
+1234567
+1234567
+1234567 \ No newline at end of file
diff --git a/util/tester/server_tester b/util/tester/server_tester
new file mode 100755
index 0000000..13063ec
--- /dev/null
+++ b/util/tester/server_tester
Binary files differ