Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
TST: Ensure prng only produces a zero once
  • Loading branch information
pan14001 committed May 16, 2019
1 parent 52ee38c commit 81eebc5
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions tests/prng.bats
Expand Up @@ -6,7 +6,7 @@ true
# shellcheck source=../parallel_opts.sh
. "${BATS_TEST_DIRNAME}/../examples/script_that_sometimes_fails.sh"

@test 'prng fails at least once' {
@test 'prng fails at least 4 times' {
# shellcheck disable=2034
SLURM_NTASKS=5

Expand All @@ -16,10 +16,14 @@ true
sum=0
for ID in {0..4}
do
result[ID]=$(prng)
sum+=${result[ID]}
x=$(prng)
if (( x % SLURM_NTASKS != 0 ))
then
sum=$(( sum + 1 ))
fi
result[ID]=$x
done
echo "seed: $seed, prng: ${result[*]}"
[[ $sum -gt 0 ]]
echo "seed: $seed, prng: ${result[*]}, sum: $sum"
[[ $sum -ge 4 ]]
done
}

0 comments on commit 81eebc5

Please sign in to comment.