aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils/pintos-check-forever
blob: d8223e26fb036c2362766e0b88965b1044f95e7f (plain) (blame)
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
72
73
74
75
76
77
78
79
#!/bin/bash
if [ "$1" = "-h" -o "$1" = "--help" ]; then
    printf "Usage: $0 [-a]\nRun with -a to abort on first error.\n";
    exit;
fi

PWD=`pwd`;
DIR=`basename $PWD`;
ABORT_ON_FAIL="false"
FAIL="true"

for i in $*; do
    if [ "$i" = "-a" ] ; then
        ABORT_ON_FAIL="true"
    fi
done

if [ "_$DIR" != "_userprog" ] ; then
    printf "You must be in userprog directory\n";
    exit;
fi

if expr $(uname -s) : 'Linux.*' > /dev/null; then
    MAKE=make
else
    MAKE=gmake
fi

let i=1;
while (true); do
    
    printf "Test run %2d started ...\n" $i;

    # Clear previous test results
    find ./build -name '*.allput' -exec rm {} \; ;
    find ./build -name '*.output' -exec rm {} \; ;
    find ./build -name '*.errors' -exec rm {} \; ;
    find ./build -name '*.result' -exec rm {} \; ;
    
    # Is it failsafe to run several Pintos concurrently?
    # YES!! tests use different fs.dsk in /tmp !
    FAIL="false"
    if ! nice -n 20 ${MAKE} -j8 check > check.tmp 2> check.err ; then
        cat check.err
        printf "ERROR: '${MAKE} check' failed.\n"
        FAIL="true"
    fi
    
    if grep FAIL check.tmp ; then
        FAIL="true"
        printf "ERROR: 'grep found FAIL in result file'\n"
        printf "ERROR: 'saving result files...'\n"

        for test in $(grep '^FAIL tests/.*$' check.tmp | sort | uniq | cut -d' ' -f2 ) ; do
            printf "mv -f build/${test}.allput build/${test}.allput.${i}\n"
            mv -f build/${test}.allput build/${test}.allput.${i}
            mv -f build/${test}.output build/${test}.output.${i}
            mv -f build/${test}.errors build/${test}.errors.${i}
            mv -f build/${test}.result build/${test}.result.${i}
        done
    fi

    printf "Test run %2d DONE.\n" $i;
    
    if [ "$FAIL" == "true" ] && [ "$ABORT_ON_FAIL" = "true" ] ; then
        break;
    fi
    let ++i;
done

printf "Completed $i test runs.\n";
printf "The result of last run is in 'check.tmp'\n";
printf "The result of failed runs is in respective test result files.\n";

printf "Consider erasing old test failures:\n";
printf "find ./build -name '*.allput.*' -exec rm {} \;\n"
printf "find ./build -name '*.output.*' -exec rm {} \;\n"
printf "find ./build -name '*.errors.*' -exec rm {} \;\n"
printf "find ./build -name '*.result.*' -exec rm {} \;\n"