diff options
author | Nicholas DeMarinis <ndemarinis@wpi.edu> | 2023-09-12 06:43:37 -0400 |
---|---|---|
committer | Nicholas DeMarinis <ndemarinis@wpi.edu> | 2023-09-12 06:43:37 -0400 |
commit | a04193f0149c375f0d4085cade1392c85913f36c (patch) | |
tree | c8ad1911ede1ac9fff849756c92c4c762d4b3610 | |
parent | bdce15783864555d7602cecbcec43c83272b36cf (diff) |
Updated reference binaries; added test runner.
-rw-r--r-- | .gitignore | 4 | ||||
-rwxr-xr-x | reference/snowcast_control | bin | 1815928 -> 1860760 bytes | |||
-rwxr-xr-x | reference/snowcast_listener | bin | 1491352 -> 1514808 bytes | |||
-rwxr-xr-x | reference/snowcast_server | bin | 2005080 -> 2050008 bytes | |||
-rwxr-xr-x | util/run_tests | 171 | ||||
-rwxr-xr-x | util/tester/control_tester | bin | 0 -> 7031352 bytes | |||
-rw-r--r-- | util/tester/data/short_file | bin | 0 -> 20480 bytes | |||
-rw-r--r-- | util/tester/data/test.txt | 12 | ||||
-rwxr-xr-x | util/tester/server_tester | bin | 0 -> 7055960 bytes |
9 files changed, 187 insertions, 0 deletions
@@ -3,3 +3,7 @@ *.o .DS_Store + +# Created by tester +/stations +/reference/stations diff --git a/reference/snowcast_control b/reference/snowcast_control Binary files differindex f64b016..866cead 100755 --- a/reference/snowcast_control +++ b/reference/snowcast_control diff --git a/reference/snowcast_listener b/reference/snowcast_listener Binary files differindex 34a542c..6033d3f 100755 --- a/reference/snowcast_listener +++ b/reference/snowcast_listener diff --git a/reference/snowcast_server b/reference/snowcast_server Binary files differindex d61d179..8107323 100755 --- a/reference/snowcast_server +++ b/reference/snowcast_server 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 Binary files differnew file mode 100755 index 0000000..942e960 --- /dev/null +++ b/util/tester/control_tester diff --git a/util/tester/data/short_file b/util/tester/data/short_file Binary files differnew file mode 100644 index 0000000..cc198a1 --- /dev/null +++ b/util/tester/data/short_file 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 Binary files differnew file mode 100755 index 0000000..13063ec --- /dev/null +++ b/util/tester/server_tester |