divide_tests.sh 2.06 KB
Newer Older
1 2 3 4
#!/bin/bash

# Sorts .rpl tests into several categories.
# Takes a diretory with the tests as an argument and moves the test to its subdirectories.
5
# Env variable SCRIPT= sets *_run.sh script for finding working tests, default script is kresd_run.sh
6
# Env variable DEST= sets output directory where the tests will be copied and divided into subfolders. Default value is working directory.
7

8 9 10 11
set -o nounset
set -o errexit

SOURCE="$1"
12

13
SCRIPT=${SCRIPT:-"./../kresd_run.sh"}
14 15 16 17 18 19 20 21
DEST=${DEST:-"."}

rm -rf "$DEST/sorted_tests"
mkdir "$DEST/sorted_tests"
for TEST in "$SOURCE/"*.rpl
do
    cp "$TEST" "$DEST/sorted_tests"
done
22 23 24

# Test with the same name is already imported in deckard/sets/resolver
echo Already imported:
25 26
mkdir -p "$DEST/sorted_tests/imported"
for TEST in `comm -12 <(ls -F ../sets/resolver/*.rpl | xargs -n 1 basename) <(ls -F "$DEST/sorted_tests" | xargs -n 1 basename)`
27
do
28
    echo -e '\t' "$TEST"
29
    mv "$DEST/sorted_tests/$TEST" "$DEST/sorted_tests/imported"
30 31 32 33
done

# Parse failed
echo Parse failed:
34 35
mkdir -p "$DEST/sorted_tests/parsefail"
for TEST in "$DEST/sorted_tests/"*.rpl
36
do
37
    if ! python3 parse.py "$TEST" >/dev/null 2>/dev/null
38
    then
39
        echo -e '\t' $(basename "$TEST")
40
        mv "$TEST" "$DEST/sorted_tests/parsefail"
41 42 43 44 45 46
    fi
done


# Invalid DSA signatures (common in old testbound tests)
echo Invalid DSA signatures:
47 48
mkdir -p "$DEST/sorted_tests/invaliddsa"
for TEST in "$DEST/sorted_tests/"*.rpl
49
do
50
    if ! python3 invalid_dsa.py "$TEST" >/dev/null 2>/dev/null
51
    then 
52
        echo -e '\t' $(basename "$TEST")
53
        mv "$TEST" "$DEST/sorted_tests/invaliddsa"
54 55 56 57
    fi
done


58 59
# Working in selected script 
echo Working in $SCRIPT:
60 61
mkdir -p "$DEST/sorted_tests/working"
for TEST in "$DEST/sorted_tests/"*.rpl
62
do
63
    if TESTS="$(readlink -m $TEST)" $SCRIPT >/dev/null 2>/dev/null
64
    then 
65
        echo -e '\t' $(basename "$TEST")
66
        mv "$TEST" "$DEST/sorted_tests/working"
67 68 69 70
    fi
done

echo Others:
71 72
mkdir -p "$DEST/sorted_tests/others"
for TEST in "$DEST/sorted_tests/"*.rpl
73
do
74
    echo -e '\t' $(basename "$TEST")
75
    mv "$TEST" "$DEST/sorted_tests/others"
76 77
done