Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow serializing BaseEnv instances #723

Open
peniblec opened this issue May 28, 2024 · 0 comments
Open

Allow serializing BaseEnv instances #723

peniblec opened this issue May 28, 2024 · 0 comments

Comments

@peniblec
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant