aboutsummaryrefslogtreecommitdiffstats
path: root/checker/test.sh
diff options
context:
space:
mode:
Diffstat (limited to 'checker/test.sh')
-rw-r--r--checker/test.sh115
1 files changed, 0 insertions, 115 deletions
diff --git a/checker/test.sh b/checker/test.sh
deleted file mode 100644
index d1c4e04..0000000
--- a/checker/test.sh
+++ /dev/null
@@ -1,115 +0,0 @@
-#!/bin/bash
-
-ipstr="$1"
-
-SCRIPTPATH="$(dirname $(readlink -f "$0"))"
-cd "$SCRIPTPATH"
-export REVHASH_PATH="$SCRIPTPATH/src/revhash/revhash"
-
-nop() { :; }
-
-splitmsg() {
- python3 -c "
-import json,sys
-
-try:
- instr = sys.stdin.read().strip()
- jres = json.loads(instr)
- print(jres['result'])
- print(jres['message'])
-except:
- print('INVALID')
- print('INVALID')
- print('FAIL:', instr, file=sys.stderr)
- " || nop
-}
-
-taskid=""
-try() {
- cmd="$1"
- pid=$BASHPID
- tmpfile="/tmp/checker-log-$pid"
- [ -e "$tmpfile" ] && rm "$tmpfile"
- if [ $# -lt 2 ]; then
- variant=0
- else
- variant=$2
- fi
- taskid="$pid"
- if [ ! -z "$REMOTE" ]; then
- python3 enoreq.py -j True -A http://localhost:9091 -a $REMOTE \
- --flag ENOTESTFLAG123= --flag_regex 'ENO.*=' -i $taskid \
- -v "$variant" -x 4000 ${@:3} "$cmd" > "$tmpfile"
- res="$(cat $tmpfile | splitmsg | head -n1)"
- else
- python3 src/checker.py -j run -v "$variant" -x 4000 \
- --flag ENOTESTFLAG123= --flag_regex 'ENO.*=' -i $taskid \
- ${@:3} "$cmd" > "$tmpfile"
- res="$(cat $tmpfile | grep -a -o 'Result: .*' | tail -n1 | cut -d' ' -f2)"
- fi
- if [ "$res" != "OK" ]; then
- newfile="fails/err-$pid"
- (
- echo "METHOD $@"
- echo "RESULT $res"
- echo "TASK $taskid"
- cat "$tmpfile"
- if [ ! -z "$REMOTE" -a -e "$ENOLOGMESSAGE_PARSER" ]; then
- docker-compose logs --tail=2000 | grep '"taskId": '$taskid | $ENOLOGMESSAGE_PARSER
- fi
- ) > "$newfile"
- echo -ne "Executing $cmd with variant $variant.. $res (TASK: $taskid)\n"
- return 1
- else
- echo -ne "Executing $cmd with variant $variant.. $res (TASK: $taskid)\n"
- return 0
- fi
-}
-
-try-all() {
- set -e
-
- try putflag 0
- try getflag 0
-
- try putflag 1
- try getflag 1
-
- try putnoise 0
- try getnoise 0
-
- try putflag 1
- try getflag 1
-
- for i in $(seq 0 15); do
- try havoc $i
- done
-
- try exploit 0
- try exploit 1
-}
-
-one-of() {
- for arg in ${@:2}; do
- [ "$1" == "$arg" ] && return 0
- done
- return 1
-}
-
-if one-of "$1" putflag getflag putnoise getnoise havoc exploit; then
- try $@
- [ $? -ne 0 -a -e "$EDITOR" ] && "$EDITOR" "/tmp/checker-log-$taskid"
-elif [ "$1" == "test-exploits" ]; then
- try exploit 0
- try exploit 1
-elif [ "$1" == "stress-test" ]; then
- mkdir -p fails
- count=${2:-100}
- for i in $(seq $count); do
- try ${3:-exploit} ${4:-0} &
- done
-else
- try-all
-fi
-
-exit 0