Debian Codegraph @

third_party/rust/glean/tests/test-enabled-pings.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}/glean_enabled_pings.XXXX")
19
20 # Build it once
21 cargo build -p glean --example enabled-pings
22
23 cmd="cargo run -q -p glean --example enabled-pings -- $datapath"
24
25 $cmd default
26 count=$(ls -1q "$datapath/sent_pings" | wc -l)
27 if [[ "$count" -ne 1 ]]; then
28 echo "1: test result: FAILED."
29 exit 101
30 fi
31
32 if ! grep -q "invalid-test-host/submit/glean-enabled-pings/one/" "$datapath/sent_pings"/*; then
33 echo "2: test result: FAILED."
34 exit 101
35 fi
36
37 rm -r $datapath
38 $cmd enable-both
39 count=$(ls -1q "$datapath/sent_pings" | wc -l)
40 if [[ "$count" -ne 2 ]]; then
41 echo "3: test result: FAILED."
42 exit 101
43 fi
44
45 rm -r $datapath
46 $cmd enable-only-two
47 count=$(ls -1q "$datapath/sent_pings" | wc -l)
48 if [[ "$count" -ne 1 ]]; then
49 echo "4: test result: FAILED."
50 exit 101
51 fi
52
53 if ! grep -q "invalid-test-host/submit/glean-enabled-pings/two/" "$datapath/sent_pings"/*; then
54 echo "5: test result: FAILED."
55 exit 101
56 fi
57
58
59 echo "test result: ok."
60 exit 0