-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.sh
executable file
·132 lines (113 loc) · 3.31 KB
/
test.sh
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#!/bin/bash
DEFAULT_MODULE="tests"
DEFAULT_RELOAD=false
DEFAULT_VERBOSE=false
DEFAULT_SYSTEM=""
DEFAULT_ALGORITHM=""
DEFAULT_NR_SHARES="3"
DEFAULT_NR_THRESHOLD="2"
usage_string="usage: ./$(basename "$0") [options]
Run tests with control over the orthogonal parameters below. For example, in
order to run dealer tests over ed25519 with hash algorithm SHA256 and reload, do
$ ./test.sh -m --dealer sha256 --reload
Groups:
ed25519, ed448, jubjub
Hash algorithms:
sha224, sha256, SHA384, sha512, sha3-224, sha3-256, sha3-384, sha3-512
Options
-m, --module <MODULE> Tests to run. Can be any subfolder or file inside
the ./tests folder. if not provided, all
tests run.
-s, --system <GROUP> Underlying cryptosystem. If not provided, tests run
against all supported groups.
-a, --algorithm <HASH> Hash algorithm to be used. This affects challenge
computation for NIZK proofs (Fiat-Shamir transform).
If not provided, related tests run against all
supported hash algorithms.
-n, --nr-shares <NR> Number of shareholders for tests involving
Shamir sharing (default: 3).
-t, --threshold <THRESHOLD> Threshold parameter for tests involving
Shamir sharing (default: 2).
-r, --reload Reload and run tests when saving changes.
-v, --verbose Be verbose.
-h, --help Display this help message and exit.
"
set -e
usage() { echo -n "$usage_string" 1>&2; }
MODULE="$DEFAULT_MODULE"
SYSTEM="$DEFAULT_SYSTEM"
ALGORITHM="$DEFAULT_ALGORITHM"
NR_SHARES="$DEFAULT_NR_SHARES"
THRESHOLD="$DEFAULT_THRESHOLD"
RELOAD="$DEFAULT_RELOAD"
VERBOSE="$DEFAULT_VERBOSE"
opts=()
while [[ $# -gt 0 ]]
do
arg="$1"
case $arg in
-m|--module)
MODULE="$2"
shift
shift
;;
-s|--system)
SYSTEM="$2"
shift
shift
;;
-a|--algorithm)
ALGORITHM="$2"
shift
shift
;;
-n|--nr-shares)
NR_SHARES="$2"
shift
shift
;;
-t|--threshold)
TRHESHOLD="$2"
shift
shift
;;
-r|--reload)
RELOAD=true
shift
;;
-v|--verbose)
VERBOSE=true
shift
;;
-h|--help)
usage
exit 0
;;
*)
opts+=($arg)
shift
;;
esac
done
export SYSTEM="${SYSTEM}"
export ALGORITHM="${ALGORITHM}"
export NR_SHARES="${NR_SHARES}"
export THRESHOLD="${THRESHOLD}"
TARGET=$MODULE
if [[ $TARGET != "tests"* ]]; then
TARGET="tests/$TARGET"
fi
opts="--maxWorkers=1"
if [[ $RELOAD == "true" ]]; then
opts+=" --watch"
fi
if [[ $VERBOSE == "true" ]]; then
opts+=" --verbose"
fi
npm test -- --clearCache
# NOTE: npm test -- --help
if [[ $TARGET == *"spec.ts" ]]; then
npm test -- $opts --findRelatedTests "$TARGET"
else
npm test -- $opts --findRelatedTests "$TARGET"/*
fi