taler-android

Android apps for GNU Taler (wallet, PoS, cashier)
Log | Files | Refs | README | LICENSE

forever.sh (3610B)


      1 #!/bin/bash
      2 # This file is part of GNU Taler
      3 # (C) 2026 Taler Systems S.A.
      4 #
      5 # GNU Taler is free software; you can redistribute it and/or modify it under the
      6 # terms of the GNU General Public License as published by the Free Software
      7 # Foundation; either version 3, or (at your option) any later version.
      8 #
      9 # GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
     10 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
     11 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
     12 #
     13 # You should have received a copy of the GNU General Public License along with
     14 # GNU Taler; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
     15 #
     16 # Keep the campaign running without supervision.
     17 #
     18 # Each round: top the bank accounts up, run every scenario across the
     19 # emulators, then explore at random with fresh seeds.  Coverage is dumped after
     20 # each phase and one line per round is appended to rounds.log, so progress can
     21 # be read at a glance later.
     22 #
     23 # Usage: nohup ./forever.sh [first-round-number] > /opt/taler-sim/run/forever.log 2>&1 &
     24 # Stop:  touch /opt/taler-sim/run/STOP
     25 
     26 set -u
     27 
     28 HERE=$(cd "$(dirname "$0")" && pwd)
     29 RUN=${SIM_RUN_DIR:-/opt/taler-sim/run}
     30 ROUNDS_LOG="$RUN/rounds.log"
     31 STOP="$RUN/STOP"
     32 STEPS=${SIM_EXPLORE_STEPS:-120}
     33 round=${1:-1}
     34 
     35 cd "$HERE"
     36 mkdir -p "$RUN"
     37 
     38 log() { printf '%s round %s: %s\n' "$(date -Is)" "$round" "$*" | tee -a "$ROUNDS_LOG"; }
     39 
     40 while [ ! -e "$STOP" ]; do
     41     log "starting"
     42 
     43     # Registration bonuses do not last; an empty bank account looks exactly
     44     # like a wallet bug in the logs.
     45     python3 stack.py > "$RUN/round$round-provision.log" 2>&1 ||
     46         log "provisioning failed, see round$round-provision.log"
     47 
     48     # Exploration first.  It used to come after the suite, and a suite of 83
     49     # scenarios takes so long that a phase always set the STOP file first --
     50     # which breaks out of the loop here, so the random walks never ran at all.
     51     # They are what found two of the findings, so they go before the queue.
     52     seed=$((1000 + round * 10))
     53     python3 -u campaign.py explore --workers 4 --steps "$STEPS" --seed "$seed" \
     54         --tag "r${round}-explore" > "$RUN/round$round-explore.log" 2>&1
     55     found=$(grep -c '^  \[' "$RUN/round$round-explore.log" 2>/dev/null || echo 0)
     56     log "explore: seed $seed, $STEPS steps/worker, $found finding lines"
     57 
     58     [ -e "$STOP" ] && break
     59 
     60     python3 -u campaign.py suite --workers 4 --tag "r${round}-suite" \
     61         > "$RUN/round$round-suite.log" 2>&1
     62     ok=$(grep -cE '^   [a-z_]+ ' "$RUN/round$round-suite.log" 2>/dev/null || echo 0)
     63     bad=$(grep -cE '^ ! [a-z_]+ ' "$RUN/round$round-suite.log" 2>/dev/null || echo 0)
     64     serious=$(grep -c '^ \*\*\*' "$RUN/round$round-suite.log" 2>/dev/null || echo 0)
     65     log "suite: $ok ok, $bad driver errors, $serious serious findings"
     66 
     67     # Keep the on-device coverage from growing stale in case a later round
     68     # restarts the app process.
     69     python3 - <<'PY' >> "$RUN/round$round-coverage.log" 2>&1
     70 import coverage, time
     71 from pathlib import Path
     72 from device import Device
     73 stamp = int(time.time())
     74 for worker in range(4):
     75     try:
     76         path = coverage.dump(Device(f"emulator-{5554 + 2 * worker}"),
     77                              Path(f"/opt/taler-sim/run/coverage/round-{stamp}-w{worker}.ec"),
     78                              name=f"round{stamp}w{worker}.ec")
     79         print(f"worker {worker}: {path} ({path.stat().st_size} bytes)")
     80     except Exception as e:
     81         print(f"worker {worker}: {e}")
     82 PY
     83     log "coverage dumped"
     84     round=$((round + 1))
     85 done
     86 
     87 log "stopped (STOP file present)"