TRUC
This commit is contained in:
parent
7d9e3d63b7
commit
89ef66a694
19 changed files with 461 additions and 64 deletions
91
test.sh
Executable file
91
test.sh
Executable file
|
|
@ -0,0 +1,91 @@
|
|||
#! /usr/bin/env bash
|
||||
|
||||
help() {
|
||||
echo "test.sh [SERVER]"
|
||||
echo "Start the rustible test suite on a certain machine (localhost by default)"
|
||||
echo "Requires lxc-ramdisk to be installed: https://kl.netlib.re/gitea/selfhoster1312/lxc-ramdisk"
|
||||
}
|
||||
|
||||
build() {
|
||||
if cargo build --release 2>&1 >/dev/null; then
|
||||
echo "$(pwd)"/target/release/rustible
|
||||
ret=0
|
||||
else
|
||||
echo "BUILD FAILED."
|
||||
ret=1
|
||||
fi
|
||||
|
||||
return $ret
|
||||
}
|
||||
|
||||
gen_rand_name() {
|
||||
echo rustible-"$RANDOM"
|
||||
}
|
||||
|
||||
execute_localhost() {
|
||||
while true; do
|
||||
TEST_NAME="$(gen_rand_name)"
|
||||
TEST_PATH=/tmp/"$TEST_NAME"
|
||||
if [ ! -e "$TEST_PATH" ]; then
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
echo "Start test $TEST_NAME"
|
||||
cp target/release/rustible "$TEST_PATH"
|
||||
}
|
||||
|
||||
execute_on_server() {
|
||||
SERVER="$1"
|
||||
if ssh "$SERVER" true >/dev/null 2>&1; then
|
||||
echo "Connection to "$1" successful"
|
||||
else
|
||||
echo "ERROR: Connection failed to "$1""
|
||||
return 1
|
||||
fi
|
||||
|
||||
while true; do
|
||||
TEST_NAME="$(gen_rand_name)"
|
||||
TEST_PATH=/tmp/"$TEST_NAME"
|
||||
if ! ssh "$1" ls "$TEST_PATH" >/dev/null 2>&1; then
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
echo "Start test "$TEST_NAME" ("$TEST_PATH")"
|
||||
if ! scp target/release/rustible "$SERVER":"$TEST_PATH"; then
|
||||
echo "ERROR: Copy to "$SERVER" failed"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Move to crate directory
|
||||
OLDDIR="$(pwd)"
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
# Figure out rustible test binary path
|
||||
BIN_PATH="$(build)"
|
||||
if [ ! $? -eq 0 ]; then
|
||||
# Compilation failed, abort
|
||||
echo "$BIN_PATH"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ "$1" = "" ]]; then
|
||||
execute_localhost
|
||||
ret=$?
|
||||
else
|
||||
case "$1" in
|
||||
"help" | "-h" | "--help")
|
||||
help
|
||||
ret=0
|
||||
;;
|
||||
*)
|
||||
execute_on_server "$1"
|
||||
ret=$?
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
cd "$OLDDIR"
|
||||
exit $ret
|
||||
Loading…
Reference in a new issue