Skip to content

Commit 2176c45

Browse files
committed
Add log-to-file option to run-proofs.sh script
When `-l FILE` is given, all output will be written to FILE.<PID> instead of stdout/stderr. This allows for running proofs in parallel with `xargs ./run-proofs.sh -l log-name -P 0 -n <PARALLELISM>` while retaining ordered output.
1 parent 9116be5 commit 2176c45

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

p-token/test-properties/run-proofs.sh

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
# -a : run all start symbols from first table in `proofs.md` (1st column)
99
# -m : run all start symbols from multisig table in `proofs.md` (2nd column)
1010
# -c : continue existing proofs instead of reloading (which is default)
11+
# -l FILE : log output to file "$NAME.PID" instead of stdout
1112
#
1213
# Always runs verbosely, always uses artefacts/proof
1314
# as proof directory
@@ -25,15 +26,19 @@ MULTISIG_NAMES=$(sed -n -e 's/^| m | \(test_p[a-zA-Z0-9:_]*\) *|.*/\1/p' proofs.
2526
TIMEOUT=3600
2627
PROVE_OPTS="--max-iterations 500 --max-depth 2000"
2728
RELOAD_OPT="--reload"
29+
LOG_FILE=""
2830

29-
while getopts ":t:o:amc" opt; do
31+
while getopts ":t:o:l:amc" opt; do
3032
case $opt in
3133
t)
3234
TIMEOUT=$OPTARG
3335
;;
3436
o)
3537
PROVE_OPTS=$OPTARG
3638
;;
39+
l)
40+
LOG_FILE="$OPTARG.$$"
41+
;;
3742
a)
3843
TESTS=${ALL_NAMES}
3944
;;
@@ -55,13 +60,18 @@ shift $((OPTIND-1))
5560

5661
# Collect tests
5762
if [ -z "$TESTS" ]; then
58-
if [ -z "$@" ]; then
63+
if [ "$#" -eq 0 ]; then
5964
echo "[ERROR] No test function names given. Use -a or provide at least one name." 1>&2
6065
exit 2
6166
fi
6267
TESTS=$@
6368
fi
6469

70+
if [ ! -z "$LOG_FILE" ]; then
71+
echo "[INFO] Logging output to file $LOG_FILE instead of stdout"
72+
exec &> $LOG_FILE
73+
fi
74+
6575
set -u
6676

6777
REPO_COMMIT=$(git rev-parse --short HEAD 2>/dev/null || echo "unknown")

0 commit comments

Comments
 (0)