FeatMgrBuilder

FeatMgrBuilder is a builder class for FeatMgr. It allows for the construction of a FeatMgr object from multiple sources. It is used to construct a FeatMgr object from test header, a cpu config, and command line arguments.

Different strategies can be used to construct the FeatMgr object. This allows for

class riescue.FeatMgrBuilder

Constructs FeatMgr from multiple sources.

This leads to a lot of repeated code, but it’s the only way to get the type checking and traceability of the builder pattern to work

To add new fields:

  1. add them to the FeatMgr class

  2. Add Candidate fields to the FeatMgrBuilder class.

  3. Add a line to the FeatMgr.build() method that calls .choose() on the Candidate field.

Note

Only add fields here that are set by the builder or have a set of possible values. Values that are hardcoded should only be added to the FeatMgr class.

Usage:

from riescue import FeatMgrBuilder
from riescue.lib.rand import RandNum

rng = RandNum(seed=42)
builder = FeatMgrBuilder()
builder.with_test_header(header)
builder.with_cpu_json(path)
builder.with_args(args)
featmgr = builder.build(rng=rng)
with_test_header(header: ParsedTestHeader) FeatMgrBuilder

Update builder with test header contents

Parameters:

header – The test header to update the builder with

See also

Test Headers Reference for the support Test Header format.

with_cpu_json(path: Path) FeatMgrBuilder

Update builder with cpu config contents

Parameters:

path – The path to the cpu config file

See also

Configuration Schema Reference for the required JSON format.

with_args(args: Namespace) FeatMgrBuilder

Update builder with command line arguments

Parameters:

args – The command line arguments to update the builder with

See also

FeatMgr Command Line Interface for the command line interface.

build(rng: RandNum) FeatMgr

Where randomization happens. Verbose, but allows for easier debugging

Parameters:

rng – The RandNum generator should be using randomization.

Returns:

A FeatMgr object with the randomization applied

duplicate() FeatMgrBuilder

Used to duplicate a FeatMgrBuilder for each test case.

with_priv_mode(priv_mode: RiscvPrivileges) FeatMgrBuilder

Shortcut for setting privilege mode candidate to a single item

with_paging_mode(paging_mode: RiscvPagingModes) FeatMgrBuilder

Shortcut for setting paging mode candidate to a single item