summaryrefslogtreecommitdiff
path: root/run-loop.sh
blob: 2c8450bcf8720b51de6e6459014cd35d86cf26bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/bash
set -e

MAX_TOTAL_TIME=1800

export TIMEOUT=1000
# export NO_ASSERT=true
export NO_CRASH=true
export NO_IMMUTABLE_VIEWSTATE=true
export NO_UNDO=true
export RTT_RULES=./rules.js

if [ -f "last_head" ]; then
    LAST_HEAD=`cat last_head`
else
    LAST_HEAD=""
fi

echo "LAST HEAD is $LAST_HEAD"

while true;
do
    echo "------------"
    echo "Updating GIT"
    echo "------------"
    cd paths-of-glory
    git pull --rebase

    # GIT_COMMIT=`git rev-parse --short HEAD`
    GIT_COMMIT=`git --no-pager log --format='%cs-%h' -n 1`

    # echo "--------------------"
    # echo "Compiling Typescript"
    # echo "--------------------"
    # tsc
    cd -

    if [[ "$GIT_COMMIT" != "$LAST_HEAD" ]]
    then
        echo "NEW HEAD is $GIT_COMMIT"
        LAST_HEAD=$GIT_COMMIT
        echo "$GIT_COMMIT" > last_head
        rm -f crash-* slow-unit-* timeout-* errors.txt
    fi

    echo "--------------"
    echo "Running Fuzzer"
    echo "--------------"
    npx jazzer rtt-module.js --sync corpus -- -max_total_time=$MAX_TOTAL_TIME | tee -a errors.txt

    echo "---------"
    echo "Reporting"
    echo "---------"
    ../errors2csv.py
    mv errors.csv errors-${GIT_COMMIT}.csv

    echo "--------------"
    echo "Merging Corpus"
    echo "--------------"
    mkdir -p corpus.new
    npx jazzer rtt-module.js --sync corpus.new corpus -- -merge=1

    echo "-------------"
    echo "Moving Corpus"
    echo "-------------"
    rm -rf corpus.old
    mv corpus corpus.old
    mv corpus.new corpus

    sleep 5
done