SUT Calls: package fuzzinator.call

class AnonymizeDecorator

class fuzzinator.call.AnonymizeDecorator(*args, **kwargs)

Decorator for SUT calls to anonymize issue properties.

Mandatory parameter of the decorator:

  • old_text: text to replace in issue properties.

Optional parameters of the decorator:

  • new_text: text to replace ‘old_text’ with (empty string by default).
  • properties: array of properties to anonymize (anonymize all properties by default).

Example configuration snippet:

[sut.foo]
call=fuzzinator.call.StdinSubprocessCall
call.decorate(0)=fuzzinator.call.AnonymizeDecorator

[sut.foo.call]
command=/home/alice/foo/bin/foo -

[sut.foo.call.decorate(0)]
old_text=/home/alice/foo
new_text=FOO_ROOT
properties=["stdout", "stderr"]

class ExitCodeFilter

class fuzzinator.call.ExitCodeFilter(*args, **kwargs)

Decorator filter for SUT calls that return issues with 'exit_code' property.

Mandatory parameter of the decorator:

  • exit_codes: if issue['exit_code'] is not in the array of exit_codes, the issue is filtered out.

The issues that are not filtered out are not changed in any way.

Example configuration snippet:

[sut.foo]
call=fuzzinator.call.StdinSubprocessCall
call.decorate(0)=fuzzinator.call.ExitCodeFilter

[sut.foo.call]
command=/home/alice/foo/bin/foo -

[sut.foo.call.decorate(0)]
exit_codes=[139]

class FileReaderDecorator

class fuzzinator.call.FileReaderDecorator(*args, **kwargs)

Decorator for SUTs that take input as a file path: saves the content of the failing test case.

Moreover, the issue (if any) is also extended with the new 'filename' property containing the name of the test case (as received in the test argument).

Example configuration snippet:

[sut.foo]
call=fuzzinator.call.SubprocessCall
call.decorate(0)=fuzzinator.call.FileReaderDecorator

[sut.foo.call]
# assuming that foo takes one file as input specified on command line
command=/home/alice/foo/bin/foo {test}

class FileWriterDecorator

class fuzzinator.call.FileWriterDecorator(*args, **kwargs)

Decorator for SUTs that take input from a file: writes the test input to a temporary file and replaces the test input with the name of that file.

Mandatory parameter of the decorator:

  • filename: path pattern for the temporary file, which may contain the substring {uid} as a placeholder for a unique string (replaced by the decorator).

The issue returned by the decorated SUT (if any) is extended with the new 'filename' property containing the name of the generated file (although the file itself is removed).

Example configuration snippet:

[sut.foo]
call=fuzzinator.call.SubprocessCall
call.decorate(0)=fuzzionator.call.FileWriterDecorator

[sut.foo.call]
# assuming that foo takes one file as input specified on command line
command=/home/alice/foo/bin/foo {test}

[sut.foo.call.decorate(0)]
filename=${fuzzinator:work_dir}/test-{uid}.txt

class GdbBacktraceDecorator

class fuzzinator.call.GdbBacktraceDecorator(*args, **kwargs)

Decorator for subprocess-based SUT calls with file input to extend issues with 'backtrace' property.

Mandatory parameter of the decorator:

  • command: string to pass to GDB as a command to run (all occurrences of {test} in the string are replaced by the actual name of the test file).

Optional parameters of the decorator:

  • cwd: if not None, change working directory before GDB/command invocation.
  • env: if not None, a dictionary of variable names-values to update the environment with.

The new 'backtrace' issue property will contain the result of GDB’s bt command after the halt of the SUT.

Example configuration snippet:

[sut.foo]
call=fuzzinator.call.SubprocessCall
call.decorate(0)=fuzzinator.call.GdbBacktraceDecorator

[sut.foo.call]
# assuming that {test} is something that can be interpreted by foo as
# command line argument
command=./bin/foo {test}
cwd=/home/alice/foo
env={"BAR": "1"}

[sut.foo.call.decorate(0)]
command=${sut.foo.call:command}
cwd=${sut.foo.call:cwd}
env={"BAR": "1", "BAZ": "1"}

class LldbBacktraceDecorator

class fuzzinator.call.LldbBacktraceDecorator(*args, **kwargs)

Decorator for subprocess-based SUT calls with file input to extend issues with 'backtrace' property.

Mandatory parameter of the decorator:

  • command: string to pass to Lldb as a command to run (all occurrences of {test} in the string are replaced by the actual name of the test file).

Optional parameters of the decorator:

  • cwd: if not None, change working directory before Lldb/command invocation.
  • env: if not None, a dictionary of variable names-values to update the environment with.
  • timeout: timeout (in seconds) to wait between two lldb commands (integer number, 1 by default).

The new 'backtrace' issue property will contain the result of Lldb’s bt command after the halt of the SUT.

Example configuration snippet:

[sut.foo]
call=fuzzinator.call.SubprocessCall
call.decorate(0)=fuzzinator.call.LldbBacktraceDecorator

[sut.foo.call]
# assuming that {test} is something that can be interpreted by foo as
# command line argument
command=./bin/foo {test}
cwd=/home/alice/foo
env={"BAR": "1"}

[sut.foo.call.decorate(0)]
command=${sut.foo.call:command}
cwd=${sut.foo.call:cwd}
env={"BAR": "1", "BAZ": "1"}

class PlatformInfoDecorator

class fuzzinator.call.PlatformInfoDecorator(*args, **kwargs)

Decorator for SUT calls to extend issues with 'platform' property.

The new 'platform' issue property will contain the result of Python’s platform.platform.

Example configuration snippet:

[sut.foo]
#call=...
call.decorate(0)=fuzzinator.call.PlatformInfoDecorator

class RegexFilter

class fuzzinator.call.RegexFilter(*args, **kwargs)

Decorator filter for SUT calls to recognise patterns in the returned issue dictionaries.

Optional parameters of the decorator:

  • key: array of patterns to match against issue[key] (note that ‘key’ can be arbitrary, and multiple different keys can be given to the decorator).

If none of the patterns matches on any of the fields, the issue is filtered out. The issues that are not filtered out are extended with keys-values from the named groups of the matching regex pattern.

Example configuration snippet:

[sut.foo]
call=fuzzinator.call.StdinSubprocessCall
call.decorate(0)=fuzzinator.call.RegexFilter

[sut.foo.call]
command=/home/alice/foo/bin/foo -

[sut.foo.call.decorate(0)]
stderr=["(?P<file>[^:]+):(?P<line>[0-9]+): (?P<func>[^:]+): (?P<msg>Assertion `.*' failed)"]
backtrace=["#[0-9]+ +0x[0-9a-f]+ in (?P<path>[^ ]+) .*? at (?P<file>[^:]+):(?P<line>[0-9]+)"]

function StdinSubprocessCall

fuzzinator.call.StdinSubprocessCall(command, cwd=None, env=None, no_exit_code=None, test=None, timeout=None, **kwargs)

Subprocess invocation-based call of a SUT that takes a test input on its stdin stream.

Mandatory parameter of the SUT call:

  • command: string to pass to the child shell as a command to run.

Optional parameters of the SUT call:

  • cwd: if not None, change working directory before the command invocation.
  • env: if not None, a dictionary of variable names-values to update the environment with.
  • no_exit_code: makes possible to force issue creation regardless of the exit code.
  • timeout: run subprocess with timeout.

Result of the SUT call:

  • If the child process exits with 0 exit code, no issue is returned.
  • Otherwise, an issue with 'exit_code', 'stdout', and 'stderr' properties is returned.

Example configuration snippet:

[sut.foo]
call=fuzzinator.call.StdinSubprocessCall

[sut.foo.call]
command=./bin/foo -
cwd=/home/alice/foo
env={"BAR": "1"}

class StreamMonitoredSubprocessCall

class fuzzinator.call.StreamMonitoredSubprocessCall(command, cwd=None, env=None, end_patterns=None, timeout=None, **kwargs)

Note

Not available on platforms without fcntl support (e.g., Windows).

function SubprocessCall

fuzzinator.call.SubprocessCall(command, cwd=None, env=None, no_exit_code=None, test=None, timeout=None, **kwargs)

Subprocess invocation-based call of a SUT that takes test input on its command line. (See fuzzinator.call.FileWriterDecorator for SUTs that take input from a file.)

Mandatory parameter of the SUT call:

  • command: string to pass to the child shell as a command to run (all occurrences of {test} in the string are replaced by the actual test input).

Optional parameters of the SUT call:

  • cwd: if not None, change working directory before the command invocation.
  • env: if not None, a dictionary of variable names-values to update the environment with.
  • no_exit_code: makes possible to force issue creation regardless of the exit code.
  • timeout: run subprocess with timeout.

Result of the SUT call:

  • If the child process exits with 0 exit code, no issue is returned.
  • Otherwise, an issue with 'exit_code', 'stdout', and 'stderr' properties is returned.

Example configuration snippet:

[sut.foo]
call=fuzzinator.call.SubprocessCall

[sut.foo.call]
# assuming that {test} is something that can be interpreted by foo as
# command line argument
command=./bin/foo {test}
cwd=/home/alice/foo
env={"BAR": "1"}

class SubprocessPropertyDecorator

class fuzzinator.call.SubprocessPropertyDecorator(*args, **kwargs)

Decorator for SUT calls to extend issues with an arbitrary property where the value is the output of a shell subprocess.

Mandatory parameters of the decorator:

  • property: name of the property to extend the issue with.
  • command: string to pass to the child shell as a command to run.

Optional parameters of the decorator:

  • cwd: if not None, change working directory before the command invocation.
  • env: if not None, a dictionary of variable names-values to update the environment with.
  • timeout: run subprocess with timeout.

Example configuration snippet:

[sut.foo]
call=fuzzinator.call.StdinSubprocessCall
call.decorate(0)=fuzzinator.call.SubprocessPropertyDecorator

[sut.foo.call]
command=./bin/foo -
cwd=/home/alice/foo

[sut.foo.call.decorate(0)]
property=version
command=git rev-parse --short HEAD
cwd=${sut.foo.call:cwd}
env={"GIT_FLUSH": "1"}

class TestRunnerSubprocessCall

class fuzzinator.call.TestRunnerSubprocessCall(command, cwd=None, env=None, end_texts=None, init_wait=None, timeout_per_test=None, **kwargs)

Note

Not available on platforms without fcntl support (e.g., Windows).

class UniqueIdDecorator

class fuzzinator.call.UniqueIdDecorator(*args, **kwargs)

Decorator for SUT calls to extend issues with 'id' property.

Mandatory parameter of the decorator:

  • properties: array of issue property names, which are concatenated (separated by a space) to form the new 'id' property.

Example configuration snippet:

[sut.foo]
call=fuzzinator.call.StdinSubprocessCall
call.decorate(0)=fuzzinator.call.RegexFilter
call.decorate(1)=fuzzinator.call.UniqueIdDecorator

[sut.foo.call]
command=/home/alice/foo/bin/foo -

[sut.foo.call.decorate(0)]
stderr=[": (?P<file>[^:]+):(?P<line>[0-9]+): (?P<func>[^:]+): (?P<msg>Assertion `.*' failed)"]

[sut.foo.call.decorate(1)]
properties=["msg", "file", "func"]