Skip to content

Commit dfe0669

Browse files
authored
Merge pull request #702 from nnethercote/test-profile_local
Add testing of `collector profile_local`.
2 parents 0680323 + 028747a commit dfe0669

File tree

3 files changed

+71
-6
lines changed

3 files changed

+71
-6
lines changed

.github/workflows/ci.yml

+30
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ jobs:
3232
aws_access_key_id: "${{ env.AWS_ACCESS_KEY_ID }}"
3333
aws_secret_access_key: "${{ secrets.AWS_SECRET_ACCESS_KEY }}"
3434
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/deploy'
35+
3536
test_benchmarks:
3637
name: Test benchmarks
3738
runs-on: ubuntu-latest
@@ -60,6 +61,7 @@ jobs:
6061
run: sh -x -c "ci/check-benchmarks.sh"
6162
env:
6263
BENCH_INCLUDE_EXCLUDE_OPTS: "--exclude script-servo"
64+
6365
test_script_servo:
6466
name: Test benchmark script-servo
6567
runs-on: ubuntu-latest
@@ -92,3 +94,31 @@ jobs:
9294
env:
9395
BENCH_INCLUDE_EXCLUDE_OPTS: "--include script-servo"
9496
SHELL: "/bin/bash"
97+
98+
test_profiling:
99+
name: Test profiling
100+
runs-on: ubuntu-latest
101+
steps:
102+
- name: Checkout the source code
103+
uses: actions/checkout@v2
104+
with:
105+
fetch-depth: 1
106+
107+
- name: Install latest beta
108+
uses: actions-rs/toolchain@v1
109+
with:
110+
toolchain: beta
111+
override: true
112+
113+
- name: Configure environment
114+
run: |
115+
sudo apt-get update
116+
sudo apt-get install -y linux-tools-common linux-tools-generic linux-tools-`uname -r`
117+
echo -1 | sudo tee /proc/sys/kernel/perf_event_paranoid
118+
119+
- name: Build collector
120+
run: cargo build -p collector
121+
122+
- name: Check benchmarks
123+
run: sh -x -c "ci/check-profiling.sh"
124+

ci/check-benchmarks.sh

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
#!/bin/bash
22

3-
set -x;
3+
set -e -x;
44

55
bash -c "while true; do sleep 30; echo \$(date) - running ...; done" &
66
PING_LOOP_PID=$!
7-
trap - ERR
7+
trap 'kill $PING_LOOP_PID' ERR
8+
9+
# Install a toolchain.
810
RUST_BACKTRACE=1 RUST_LOG=collector_raw_cargo=trace,collector=debug,rust_sysroot=debug \
9-
bindir=`cargo run -p collector --bin collector install_next` \
10-
&& \
11+
bindir=`cargo run -p collector --bin collector install_next`
12+
13+
# Do some benchmarking.
1114
RUST_BACKTRACE=1 RUST_LOG=collector_raw_cargo=trace,collector=debug,rust_sysroot=debug \
1215
cargo run -p collector --bin collector -- \
1316
bench_local $bindir/rustc Test \
@@ -16,6 +19,6 @@ RUST_BACKTRACE=1 RUST_LOG=collector_raw_cargo=trace,collector=debug,rust_sysroot
1619
--runs All \
1720
--rustdoc $bindir/rustdoc \
1821
$BENCH_INCLUDE_EXCLUDE_OPTS
19-
code=$?
22+
2023
kill $PING_LOOP_PID
21-
exit $code
24+
exit 0

ci/check-profiling.sh

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
#
3+
# This script is basically just a smoke test. It only tests `eprintln`
4+
# profiling because setting up the other profilers is something of a hassle.
5+
6+
set -e -x;
7+
8+
bash -c "while true; do sleep 30; echo \$(date) - running ...; done" &
9+
PING_LOOP_PID=$!
10+
trap 'kill $PING_LOOP_PID' ERR
11+
12+
# Install a toolchain.
13+
RUST_BACKTRACE=1 RUST_LOG=collector_raw_cargo=trace,collector=debug,rust_sysroot=debug \
14+
bindir=`cargo run -p collector --bin collector install_next`
15+
16+
# Profile with eprintln.
17+
RUST_BACKTRACE=1 RUST_LOG=collector_raw_cargo=trace,collector=debug,rust_sysroot=debug \
18+
cargo run -p collector --bin collector -- \
19+
profile_local eprintln $bindir/rustc Test \
20+
--cargo $bindir/cargo \
21+
--include helloworld \
22+
--runs Full
23+
24+
# Check that Check/Debug/Opt files are present, and that Doc files aren't
25+
# present, becuase they're not done by default.
26+
test -f results/eprintln-Test-helloworld-Check-Full
27+
test -f results/eprintln-Test-helloworld-Debug-Full
28+
test -f results/eprintln-Test-helloworld-Opt-Full
29+
test ! -e results/eprintln-Test-helloworld-Doc-Full
30+
31+
kill $PING_LOOP_PID
32+
exit 0

0 commit comments

Comments
 (0)