solana/ci/test-stable.sh

118 lines
3.5 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
set -e
2018-05-27 18:19:07 -07:00
cd "$(dirname "$0")/.."
2018-05-21 23:02:54 -07:00
cargo="$(readlink -f "./cargo")"
2018-12-18 14:25:10 -08:00
source ci/_
annotate() {
${BUILDKITE:-false} && {
buildkite-agent annotate "$@"
}
}
# Run the appropriate test based on entrypoint
testName=$(basename "$0" .sh)
source ci/rust-version.sh stable
2018-06-24 21:24:08 -07:00
export RUST_BACKTRACE=1
2018-09-20 18:51:11 -07:00
export RUSTFLAGS="-D warnings"
source scripts/ulimit-n.sh
# Limit compiler jobs to reduce memory usage
2020-05-31 21:29:32 -07:00
# on machines with 2gb/thread of memory
NPROC=$(nproc)
2020-05-31 21:29:32 -07:00
NPROC=$((NPROC>14 ? 14 : NPROC))
echo "Executing $testName"
case $testName in
test-stable)
_ "$cargo" stable test --jobs "$NPROC" --all --exclude solana-local-cluster ${V:+--verbose} -- --nocapture
;;
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
2021-07-30 15:15:06 -07:00
export PATH="$PWD/target/debug":$PATH
cargo_build_bpf="$(realpath ./cargo-build-bpf)"
2021-07-30 15:15:06 -07:00
cargo_test_bpf="$(realpath ./cargo-test-bpf)"
# BPF solana-sdk legacy compile test
"$cargo_build_bpf" --manifest-path sdk/Cargo.toml
2021-07-30 15:15:06 -07:00
# BPF C program system tests
_ make -C programs/bpf/c tests
_ "$cargo" stable test \
--manifest-path programs/bpf/Cargo.toml \
--no-default-features --features=bpf_c,bpf_rust -- --nocapture
2021-07-30 15:15:06 -07:00
# BPF Rust program unit tests
for bpf_test in programs/bpf/rust/*; do
if pushd "$bpf_test"; then
2021-07-30 15:15:06 -07:00
"$cargo" test
"$cargo_build_bpf" --bpf-sdk ../../../../sdk/bpf --dump
"$cargo_test_bpf" --bpf-sdk ../../../../sdk/bpf
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
2019-02-27 08:18:29 -08:00
# 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
# is not yet loaded.
sudo --non-interactive ./net/scripts/enable-nvidia-persistence-mode.sh || true
2019-02-27 08:18:29 -08:00
rm -rf target/perf-libs
2019-02-27 08:18:29 -08:00
./fetch-perf-libs.sh
2019-09-26 13:36:51 -07:00
# Force CUDA for solana-core unit tests
export TEST_PERF_LIBS_CUDA=1
# Force CUDA in ci/localnet-sanity.sh
export SOLANA_CUDA=1
2019-02-27 08:18:29 -08:00
fi
_ "$cargo" stable build --bins ${V:+--verbose}
_ "$cargo" stable test --package solana-perf --package solana-ledger --package solana-core --lib ${V:+--verbose} -- --nocapture
_ "$cargo" stable run --manifest-path poh-bench/Cargo.toml ${V:+--verbose} -- --hashes-per-tick 10
;;
test-local-cluster)
_ "$cargo" stable build --release --bins ${V:+--verbose}
_ "$cargo" stable test --release --package solana-local-cluster ${V:+--verbose} -- --nocapture --test-threads=1
exit 0
;;
*)
echo "Error: Unknown test: $testName"
;;
esac
2018-07-30 12:51:35 -07:00
(
export CARGO_TOOLCHAIN=+"$rust_stable"
echo --- ci/localnet-sanity.sh
ci/localnet-sanity.sh -x
echo --- ci/run-sanity.sh
ci/run-sanity.sh -x
2018-07-30 12:51:35 -07:00
)