From 401dcb228b426b9457e3e77b50fc32c3a330ea61 Mon Sep 17 00:00:00 2001 From: Chip Morningstar Date: Fri, 4 Sep 2020 18:33:31 -0700 Subject: [PATCH] feat: add swingset-runner bulk demo running tool --- .../demo/exchangeBenchmark/sampleArgs | 1 + .../swingset-runner/demo/megaPong/sampleArgs | 1 + .../demo/swapBenchmark/sampleArgs | 1 + .../demo/vatFailure/sampleArgs | 2 + .../swingset-runner/demo/zoeTests/sampleArgs | 12 +++ packages/swingset-runner/trun | 81 +++++++++++++++++++ 6 files changed, 98 insertions(+) create mode 100644 packages/swingset-runner/demo/exchangeBenchmark/sampleArgs create mode 100644 packages/swingset-runner/demo/megaPong/sampleArgs create mode 100644 packages/swingset-runner/demo/swapBenchmark/sampleArgs create mode 100644 packages/swingset-runner/demo/vatFailure/sampleArgs create mode 100644 packages/swingset-runner/demo/zoeTests/sampleArgs create mode 100755 packages/swingset-runner/trun diff --git a/packages/swingset-runner/demo/exchangeBenchmark/sampleArgs b/packages/swingset-runner/demo/exchangeBenchmark/sampleArgs new file mode 100644 index 00000000000..c86421c8085 --- /dev/null +++ b/packages/swingset-runner/demo/exchangeBenchmark/sampleArgs @@ -0,0 +1 @@ +--prime diff --git a/packages/swingset-runner/demo/megaPong/sampleArgs b/packages/swingset-runner/demo/megaPong/sampleArgs new file mode 100644 index 00000000000..209e3ef4b62 --- /dev/null +++ b/packages/swingset-runner/demo/megaPong/sampleArgs @@ -0,0 +1 @@ +20 diff --git a/packages/swingset-runner/demo/swapBenchmark/sampleArgs b/packages/swingset-runner/demo/swapBenchmark/sampleArgs new file mode 100644 index 00000000000..c86421c8085 --- /dev/null +++ b/packages/swingset-runner/demo/swapBenchmark/sampleArgs @@ -0,0 +1 @@ +--prime diff --git a/packages/swingset-runner/demo/vatFailure/sampleArgs b/packages/swingset-runner/demo/vatFailure/sampleArgs new file mode 100644 index 00000000000..cb8e071ccaa --- /dev/null +++ b/packages/swingset-runner/demo/vatFailure/sampleArgs @@ -0,0 +1,2 @@ +--bestatic +--bedynamic diff --git a/packages/swingset-runner/demo/zoeTests/sampleArgs b/packages/swingset-runner/demo/zoeTests/sampleArgs new file mode 100644 index 00000000000..9e61feb7627 --- /dev/null +++ b/packages/swingset-runner/demo/zoeTests/sampleArgs @@ -0,0 +1,12 @@ +simpleExchangeOk +simpleExchangeNotifier +autoswapOk +automaticRefundOk +coveredCallOk +swapForOptionOk +secondPriceAuctionOk +atomicSwapOk +simpleExchangeOk +simpleExchangeNotifier +autoswapOk +sellTicketsOk diff --git a/packages/swingset-runner/trun b/packages/swingset-runner/trun new file mode 100755 index 00000000000..8e0aa954b20 --- /dev/null +++ b/packages/swingset-runner/trun @@ -0,0 +1,81 @@ +#!/bin/bash + +# Run each demo in the demo directory +# +# If a demo has a swingset config file, use that, else use the default config +# loader. If it has more than one config file, run each one in turn. +# +# If a demo directory contains a file `sampleArgs`, do a run for each line of +# the file, applying the contents of each line in turn as the buildRootObject +# vatParameters.argv value, else just run the demo once. + +shopt -s nullglob + +# output timing data in a usable format +export TIMEFORMAT='%Uu %Ss %R' + +# Process command line args +# --time runs the runner with the Unix `time` command +# --dump applies the runner --dump flag but ensures per-run dump files +# --dryrun outputs the commands but doesn't actually execute them +# all other args are passed to the runner +for arg in "$@"; do + case $arg in + --time) + dotime=1 + ;; + --dump) + dodump=1 + ;; + --dryrun) + dryrun=1 + ;; + *) + arglist="$arglist $arg" + ;; + esac +done + +runct=1 +function runone { + cmd="bin/runner" + if [ $dryrun ]; then + cmd="echo ${cmd}" + fi + cmdargs=$arglist + if [ $dodump ]; then + cmdargs="$cmdargs --dump --dumptag t${runct}-" + fi + cmdline="$cmd $cmdargs $@" + echo "$cmdline" + if [ $dotime ]; then + time $cmdline > rlog-${runct} + else + $cmdline > rlog-${runct} + fi + ((runct=runct+1)) +} + +function rundemo { + dir=$1 + target=$2 + + if [ -f "${dir}/sampleArgs" ]; then + while read line; do + runone $target "-- ${line}" + done < ${dir}/sampleArgs + else + runone $target + fi +} + +for demo in demo/*; do + hadconf=0 + for conf in ${demo}/*.json; do + rundemo $demo "--config $conf run" + hadconf=1 + done + if [ "$hadconf" == "0" ]; then + rundemo $demo "run $demo" + fi +done