Skip to content

Commit

Permalink
client: Update run-test.sh script to build and check validator state (
Browse files Browse the repository at this point in the history
  • Loading branch information
ochaloup authored Jun 7, 2024
1 parent b751183 commit 21d5609
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions client/example/run-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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.
#
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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.
Expand Down Expand Up @@ -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

0 comments on commit 21d5609

Please sign in to comment.