summary refs log tree commit diff
path: root/warteraum/test/run
blob: 5b4a4283f54e76aa96dac23c981e882c4b4e15b8 (plain) (blame)
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
#!/bin/sh

set -e
cd "$(dirname "$0")"

redo all

TESTS="queue form routing emitjson"

for t in $TESTS; do

  echo -e "\n# $t tests\n"
  "./test_$t.exe"
done

echo -e "\n# test emitjson validity\n"

if command -v jq > /dev/null; then
  if ./test_emitjson.exe -o | jq; then
    echo -e "\njson validity\tok"
  else
    echo -e "\njson validity\tFAIL"
    exit 1
  fi
else
  echo -e "json validity\tskipped (missing jq)"
fi

echo -e "\n# warteraum integration tests\n"

if command -v pytest > /dev/null; then
  redo ../warteraum

  rm -f valgrind-log.txt

  valgrind \
    --log-file=./valgrind-log.txt \
    --leak-check=full \
    --track-origins=yes \
    --show-leak-kinds=all \
    --show-error-list=yes \
    ../warteraum &
  pid=$!

  sleep 3

  pytest ./test_integration.py

  kill $pid

  sleep 1

  all_freed=0
  no_errors=0

  grep "All heap blocks were freed" valgrind-log.txt || all_freed=$?
  grep "ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)" valgrind-log.txt || no_errors=$?

  if ! (( $all_freed && $no_errors )); then
    echo -e "\nvalgrind test\tokay"
  else
    echo -e "\nvalgrind test\tfail\n"
    cat valgrind-log.txt
    exit 1
  fi
else
  echo "skipped (missing pytest)"
fi