exchange

Base system with REST service to issue digital coins, run by the payment service provider
Log | Files | Refs | Submodules | README | LICENSE

test_table.sh (1902B)


      1 #!/bin/sh
      2 # This file is in the public domain.
      3 #
      4 # Driver for the per-table src/exchangedb/ tests.  Takes the test binary to
      5 # run as its first argument, provisions a scratch database of its own for it
      6 # and removes the database again afterwards.  No pre-existing database is
      7 # ever touched: the name is derived from the binary and the PID and is
      8 # deliberately *not* taken from the environment.
      9 set -eu
     10 
     11 BINARY="$1"
     12 shift
     13 
     14 # Where the build tree lives; meson passes this, the fallback is for
     15 # running the script by hand from its build directory.
     16 BUILD_ROOT="${TALER_BUILD_ROOT:-$(cd ../../.. && pwd)}"
     17 SQL_DIR="${TALER_SQL_DIR:-${BUILD_ROOT}/src/exchangedb/sql-schema}"
     18 
     19 # Skip (77) rather than fail if there is no usable PostgreSQL around.
     20 command -v createdb > /dev/null 2>&1 || exit 77
     21 command -v dropdb > /dev/null 2>&1 || exit 77
     22 psql -l < /dev/null > /dev/null 2>&1 || exit 77
     23 
     24 # Postgres database names are limited to 63 characters, so use a digest of
     25 # the binary name rather than the name itself.
     26 TAG=$(echo "$BINARY" | cksum | cut -d' ' -f1)
     27 DBNAME="taler_exdb_t${TAG}_$$"
     28 CONF="${BINARY}_$$.conf"
     29 
     30 # The freshly built libraries must outrank any installed copy, as
     31 # LD_LIBRARY_PATH beats the build tree's RUNPATH.
     32 for d in "${BUILD_ROOT}"/src/*/; do
     33     LD_LIBRARY_PATH="${d%/}${LD_LIBRARY_PATH:+:}${LD_LIBRARY_PATH:-}"
     34 done
     35 export LD_LIBRARY_PATH
     36 
     37 cleanup ()
     38 {
     39     dropdb --if-exists "$DBNAME" > /dev/null 2>&1 || true
     40     rm -f "$CONF"
     41 }
     42 trap cleanup EXIT
     43 
     44 cat > "$CONF" <<EOF
     45 [exchange]
     46 CURRENCY = EUR
     47 BASE_URL = http://localhost/
     48 [exchangedb-postgres]
     49 CONFIG = postgres:///${DBNAME}
     50 SQL_DIR = ${SQL_DIR}/
     51 [exchangedb]
     52 MAX_AML_PROGRAM_RUNTIME = 1 minute
     53 IDLE_RESERVE_EXPIRATION_TIME = 4 weeks
     54 LEGAL_RESERVE_EXPIRATION_TIME = 7 years
     55 AGGREGATOR_SHIFT = 1s
     56 DEFAULT_PURSE_LIMIT = 1
     57 EOF
     58 
     59 createdb "$DBNAME" > /dev/null 2>&1 || exit 77
     60 
     61 RET=0
     62 "./$BINARY" -c "$CONF" "$@" || RET=$?
     63 exit $RET