Debian Codegraph @

third_party/rust/glean/tests/test-thread-crashing.sh

raw
1 #!/bin/bash
2
3 # Test harness for testing the RLB processes from the outside.
4 #
5 # Some behavior can only be observed when properly exiting the process running Glean,
6 # e.g. when an uploader runs in another thread.
7 # On exit the threads will be killed, regardless of their state.
8
9 # Remove the temporary data path on all exit conditions
10 cleanup() {
11 if [ -n "$datapath" ]; then
12 rm -r "$datapath"
13 fi
14 }
15 trap cleanup INT ABRT TERM EXIT
16
17 tmp="${TMPDIR:-/tmp}"
18 datapath=$(mktemp -d "${tmp}/crashing_threads.XXXX")
19
20 RUSTFLAGS="-C panic=abort" \
21 RUST_LOG=debug \
22 cargo run -p glean --example crashing-threads -- "$datapath"
23 ret=$?
24 count=$(ls -1q "$datapath/pending_pings" | wc -l)
25
26 # We expect 1 `prototype` ping:
27 if [[ $ret -eq 0 ]] && [[ "$count" -eq 1 ]]; then
28 echo "test result: ok."
29 exit 0
30 else
31 echo "Assertions:"
32 echo " ret - expected: 0, was: $ret"
33 echo " count - expected: 1, was: $count"
34 echo "test result: FAILED."
35 exit 101
36 fi