From 21d56094ea7a67346a3481b8cba3e64dc46c20d0 Mon Sep 17 00:00:00 2001 From: chalda Date: Fri, 7 Jun 2024 23:51:27 +0200 Subject: [PATCH] client: Update `run-test.sh` script to build and check validator state (#3008) --- client/example/run-test.sh | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/client/example/run-test.sh b/client/example/run-test.sh index 13f3e47f8..5aba1a437 100755 --- a/client/example/run-test.sh +++ b/client/example/run-test.sh @@ -28,6 +28,17 @@ main() { local events_pid="2dhGsWUzy5YKUsjZdLHLmkNpUDAXkNa9MYWsPc4Ziqzy" local optional_pid="FNqz6pqLAwvMSds2FYjR4nKV3moVpPNtvkfGFrqLKrgG" + cd ../../tests/composite && anchor build && cd - + [ $? -ne 0 ] && exit 1 + cd ../../examples/tutorial/basic-2 && anchor build && cd - + [ $? -ne 0 ] && exit 1 + cd ../../examples/tutorial/basic-4 && anchor build && cd - + [ $? -ne 0 ] && exit 1 + cd ../../tests/events && anchor build && cd - + [ $? -ne 0 ] && exit 1 + cd ../../tests/optional && anchor build && cd - + [ $? -ne 0 ] && exit 1 + # # Bootup validator. # @@ -38,7 +49,10 @@ main() { --bpf-program $events_pid ../../tests/events/target/deploy/events.so \ --bpf-program $optional_pid ../../tests/optional/target/deploy/optional.so \ > test-validator.log & + test_validator_pid=$! + sleep 5 + check_solana_validator_running $test_validator_pid # # Run single threaded test. @@ -61,7 +75,10 @@ main() { --bpf-program $events_pid ../../tests/events/target/deploy/events.so \ --bpf-program $optional_pid ../../tests/optional/target/deploy/optional.so \ > test-validator.log & + test_validator_pid=$! + sleep 5 + check_solana_validator_running $test_validator_pid # # Run multi threaded test. @@ -85,7 +102,10 @@ main() { --bpf-program $events_pid ../../tests/events/target/deploy/events.so \ --bpf-program $optional_pid ../../tests/optional/target/deploy/optional.so \ > test-validator.log & + test_validator_pid=$! + sleep 5 + check_solana_validator_running $test_validator_pid # # Run async test. @@ -117,6 +137,15 @@ trap_add() { done } +check_solana_validator_running() { + local pid=$1 + exit_state=$(kill -0 "$pid" && echo 'living' || echo 'exited') + if [ "$exit_state" == 'exited' ]; then + echo "Cannot start test validator, see ./test-validator.log" + exit 1 + fi +} + declare -f -t trap_add trap_add 'cleanup' EXIT main