From 4c764829da2502cc8f90c5c772bd82efa573b6ba Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Sat, 10 Jul 2021 19:24:23 +0000 Subject: [PATCH] CI: Make BPF test suite a first-class citizen (backport #18535) (#18571) * CI: Extricate BPF tests from stable-perf (cherry picked from commit 1eab0773af14af8adf7f233d120e1347ac8abc49) * CI: Dump BPF assembly listings and upload as artifact (cherry picked from commit f1996ca0f382397eeeea5bf34b5da9517ef70977) Co-authored-by: Trent Nelson --- ci/buildkite-pipeline.sh | 29 ++++++++++++++++++++++++++++- ci/run-local.sh | 1 + ci/test-stable-bpf.sh | 1 + ci/test-stable.sh | 38 +++++++++++++++++++++++++++++++------- 4 files changed, 61 insertions(+), 8 deletions(-) create mode 120000 ci/test-stable-bpf.sh diff --git a/ci/buildkite-pipeline.sh b/ci/buildkite-pipeline.sh index c92426f28a..671d3f0c14 100755 --- a/ci/buildkite-pipeline.sh +++ b/ci/buildkite-pipeline.sh @@ -148,6 +148,33 @@ all_test_steps() { command_step stable ". ci/rust-version.sh; ci/docker-run.sh \$\$rust_stable_docker_image ci/test-stable.sh" 60 wait_step + # BPF test suite + if affects \ + .rs$ \ + Cargo.lock$ \ + Cargo.toml$ \ + ^ci/rust-version.sh \ + ^ci/test-stable-bpf.sh \ + ^ci/test-stable.sh \ + ^ci/test-local-cluster.sh \ + ^core/build.rs \ + ^fetch-perf-libs.sh \ + ^programs/ \ + ^sdk/ \ + ; then + cat >> "$output_file" <<"EOF" + - command: "ci/test-stable-bpf.sh" + name: "stable-bpf" + timeout_in_minutes: 20 + artifact_paths: "bpf-dumps.tar.bz2" + agents: + - "queue=default" +EOF + else + annotate --style info \ + "Stable-BPF skipped as no relevant files were modified" + fi + # Perf test suite if affects \ .rs$ \ @@ -165,7 +192,7 @@ all_test_steps() { cat >> "$output_file" <<"EOF" - command: "ci/test-stable-perf.sh" name: "stable-perf" - timeout_in_minutes: 40 + timeout_in_minutes: 20 artifact_paths: "log-*.txt" agents: - "queue=cuda" diff --git a/ci/run-local.sh b/ci/run-local.sh index 536318145c..092f35f562 100755 --- a/ci/run-local.sh +++ b/ci/run-local.sh @@ -22,6 +22,7 @@ steps+=(shellcheck) steps+=(test-checks) steps+=(test-coverage) steps+=(test-stable) +steps+=(test-stable-bpf) steps+=(test-stable-perf) steps+=(test-downstream-builds) steps+=(test-bench) diff --git a/ci/test-stable-bpf.sh b/ci/test-stable-bpf.sh new file mode 120000 index 0000000000..0c92a5c7bd --- /dev/null +++ b/ci/test-stable-bpf.sh @@ -0,0 +1 @@ +test-stable.sh \ No newline at end of file diff --git a/ci/test-stable.sh b/ci/test-stable.sh index 60264b5a92..80ae2e0622 100755 --- a/ci/test-stable.sh +++ b/ci/test-stable.sh @@ -21,10 +21,6 @@ export RUST_BACKTRACE=1 export RUSTFLAGS="-D warnings" source scripts/ulimit-n.sh -# Clear the C dependency files, if dependency moves these files are not regenerated -test -d target/debug/bpf && find target/debug/bpf -name '*.d' -delete -test -d target/release/bpf && find target/release/bpf -name '*.d' -delete - # Limit compiler jobs to reduce memory usage # on machines with 2gb/thread of memory NPROC=$(nproc) @@ -35,17 +31,25 @@ case $testName in test-stable) _ "$cargo" stable test --jobs "$NPROC" --all --exclude solana-local-cluster ${V:+--verbose} -- --nocapture ;; -test-stable-perf) +test-stable-bpf) + # Clear the C dependency files, if dependency moves these files are not regenerated + test -d target/debug/bpf && find target/debug/bpf -name '*.d' -delete + test -d target/release/bpf && find target/release/bpf -name '*.d' -delete + + # rustfilt required for dumping BPF assembly listings + "$cargo" install rustfilt + # solana-keygen required when building C programs _ "$cargo" build --manifest-path=keygen/Cargo.toml export PATH="$PWD/target/debug":$PATH + cargo_build_bpf="$(realpath ./cargo-build-bpf)" # BPF solana-sdk legacy compile test - ./cargo-build-bpf --manifest-path sdk/Cargo.toml + "$cargo_build_bpf" --manifest-path sdk/Cargo.toml # BPF Program unit tests "$cargo" test --manifest-path programs/bpf/Cargo.toml - cargo-build-bpf --manifest-path programs/bpf/Cargo.toml --bpf-sdk sdk/bpf + "$cargo_build_bpf" --manifest-path programs/bpf/Cargo.toml --bpf-sdk sdk/bpf # BPF program system tests _ make -C programs/bpf/c tests @@ -53,6 +57,26 @@ test-stable-perf) --manifest-path programs/bpf/Cargo.toml \ --no-default-features --features=bpf_c,bpf_rust -- --nocapture + # Dump BPF program assembly listings + for bpf_test in programs/bpf/rust/*; do + if pushd "$bpf_test"; then + "$cargo_build_bpf" --dump + popd + fi + done + + # BPF program instruction count assertion + bpf_target_path=programs/bpf/target + _ "$cargo" stable test \ + --manifest-path programs/bpf/Cargo.toml \ + --no-default-features --features=bpf_c,bpf_rust assert_instruction_count \ + -- --nocapture &> "${bpf_target_path}"/deploy/instuction_counts.txt + + bpf_dump_archive="bpf-dumps.tar.bz2" + rm -f "$bpf_dump_archive" + tar cjvf "$bpf_dump_archive" "${bpf_target_path}"/{deploy/*.txt,bpfel-unknown-unknown/release/*.so} + ;; +test-stable-perf) if [[ $(uname) = Linux ]]; then # Enable persistence mode to keep the CUDA kernel driver loaded, avoiding a # lengthy and unexpected delay the first time CUDA is involved when the driver