Skip to content

Allow serializing BaseEnv instances #723

@peniblec

Description

@peniblec

Hi!

Some e3-testsuite-based testsuites define a test.py script for each testcase, make the driver execute that script plus some pre-/post-processing steps. These test.py scripts typically import a harness module shared with the main testsuite process, and that module will load data that has been serialized by the driver.

This data generally includes

  • some of the main process's command-line options, i.e. information about the run as a whole,
  • the test_env received by the driver, i.e. information that parameterizes test.py.

As things stand, testsuite drivers need to devise their own serialization strategy, e.g. a record where the driver will tuck Env() platforms, test_env items, etc; the driver will pickle that record, spawn test.py and let it un-pickle the record.

It would be convenient to use e3.env's existing de/serialization code for this, using a protocol along the lines of:

# Driver side:
testcase_env = BaseEnv.from_env()       # Copy Env singleton into a non-global instance.
testcase_env.test_env = self.test_env   # Add per-testcase data.
testcase_env.store(self.working_dir(harness.TESTCASE_ENV_FILE))
self.shell(["test.py"])                 # Spawn test.py in self.working_dir().

# test.py side:
Env.restore(harness.TESTCASE_ENV_FILE)

However, currently this cannot work:

  • BaseEnv.from_env only copies the build, host & target platforms; it does not copy other attributes;
  • BaseEnv.copy does not accept Env parameters;
  • only Env has store & restore methods.

Filing this enhancement request after chatting with @Nikokrock. The title might be too biased toward a preconceived solution; open to discussing the use-case more and seeing where else we can go.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions