lisa.fuzz#
Fuzzing API to build random constrained values.
Note
The following example shows a direct use of the Gen
monad,
but be aware that lisa.wlgen.rta
API allows mixing both Gen
and RTA DSL into the same coroutine function using
lisa.wlgen.rta.task_factory()
.
Example:
from lisa.platforms.platinfo import PlatformInfo
from lisa.fuzz import GenMonad, Choice, Int, Float, retry_until
# The function must be decorated with GenMonad.do() so that "await" gains
# its special meaning.
@GenMonad.do
async def make_data(duration=None):
# Draw a value from an iterable.
period = await Choice([16e-3, 8e-3])
nr = await Choice(range(1, 4))
duration = duration or (await Float(1, 2))
# Arbitrary properties can be enforced. If they are not satisfied, the
# function will run again until the condition is true.
await retry_until(0 < nr <= 2)
return (nr, duration, period)
# seed (or rng) can be fixed for reproducible results
data = make_data(duration=42)(seed=1)
print(data)
Classes
Draw a random bool. |
|
Randomly choose one values among |
|
Randomly choose |
|
Same as |
|
Draw a random float fitting within the |
|
Random generator monad inspired by Haskell’s QuickCheck. |
|
Draw a random int fitting within the |
|
Same as |
|
Randomly shuffle the given sequence. |
|
Same as |
|
Same as |
Functions
Returns an awaitable that will signify to the |
Exceptions
Exception raised to signify to |