File: multirequest.sh

package info (click to toggle)
protobuf 3.21.12-14
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 43,412 kB
  • sloc: cpp: 179,373; java: 88,098; objc: 60,661; ansic: 37,810; cs: 28,526; python: 22,565; php: 11,464; ruby: 6,127; sh: 3,635; makefile: 3,341; pascal: 2,352; xml: 2,317; javascript: 311; lisp: 87; awk: 17
file content (62 lines) | stat: -rwxr-xr-x 1,374 bytes parent folder | download | duplicates (12)
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
#!/bin/bash

cd $(dirname $0)

set -e

PORT=12345
TIMEOUT=10

./compile_extension.sh

run_test() {
  echo
  echo "Running multirequest test, args: $@"

  RUN_UNDER=""
  EXTRA_ARGS=""
  ARGS="-d xdebug.profiler_enable=0 -d display_errors=on -dextension=../ext/google/protobuf/modules/protobuf.so"

  for i in "$@"; do
    case $i in
      --valgrind)
        RUN_UNDER="valgrind --error-exitcode=1"
        shift
        ;;
      --keep_descriptors)
        EXTRA_ARGS=-dprotobuf.keep_descriptor_pool_after_request=1
        shift
        ;;
    esac
  done

  export ZEND_DONT_UNLOAD_MODULES=1
  export USE_ZEND_ALLOC=0
  rm -f nohup.out
  nohup $RUN_UNDER php $ARGS $EXTRA_ARGS -S localhost:$PORT multirequest.php >nohup.out 2>&1 &
  PID=$!

  if ! timeout $TIMEOUT bash -c "until echo > /dev/tcp/localhost/$PORT; do sleep 0.1; done" > /dev/null 2>&1; then
    echo "Server failed to come up after $TIMEOUT seconds"
    cat nohup.out
    exit 1
  fi

  seq 2 | xargs -I{} wget -nv http://localhost:$PORT/multirequest.result -O multirequest{}.result
  REQUESTS_SUCCEEDED=$?


  if kill $PID > /dev/null 2>&1 && [[ $REQUESTS_SUCCEEDED == "0" ]]; then
    wait
    echo "Multirequest test SUCCEEDED"
  else
    echo "Multirequest test FAILED"
    cat nohup.out
    exit 1
  fi
}

run_test
run_test --keep_descriptors
run_test --valgrind
run_test --valgrind --keep_descriptors