summaryrefslogtreecommitdiffstats
path: root/third_party/rust/glean/tests/test-thread-crashing.sh
blob: 67a0f4099c485756f0e67e1ea36ce4a621e2a545 (plain)
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
#!/bin/bash

# Test harness for testing the RLB processes from the outside.
#
# Some behavior can only be observed when properly exiting the process running Glean,
# e.g. when an uploader runs in another thread.
# On exit the threads will be killed, regardless of their state.

# Remove the temporary data path on all exit conditions
cleanup() {
  if [ -n "$datapath" ]; then
    rm -r "$datapath"
  fi
}
trap cleanup INT ABRT TERM EXIT

tmp="${TMPDIR:-/tmp}"
datapath=$(mktemp -d "${tmp}/glean_long_running.XXXX")

RUSTFLAGS="-C panic=abort" \
RUST_LOG=debug \
cargo run -p glean --example crashing-threads -- "$datapath"
ret=$?
count=$(ls -1q "$datapath/pending_pings" | wc -l)

if [[ $ret -eq 0 ]] && [[ "$count" -eq 1 ]]; then
  echo "test result: ok."
  exit 0
else
  echo "test result: FAILED."
  exit 101
fi