Created
February 7, 2022 16:50
-
-
Save jessebutryn/cddf67b498c96ed6ffca19e7301be793 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| runs=$1 | |
| passorfail () { | |
| local _thing=$1 | |
| sleep 2 | |
| if [[ $_thing == pass ]]; then | |
| return 0 | |
| else | |
| return 1 | |
| fi | |
| } | |
| for ((i=1;i<=runs;i++)); do | |
| if (((RANDOM%10)+1>5)); then | |
| thing=pass | |
| else | |
| thing=fail | |
| fi | |
| passorfail "$thing" & | |
| pids+=($!) | |
| done | |
| for pid in "${pids[@]}"; do | |
| if wait "$pid"; then | |
| ((passed++)) | |
| else | |
| ((failed++)) | |
| fi | |
| done | |
| printf 'Passed: %d\nFailed: %d\n' "$passed" "$failed" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment