tests: Add 'checkpoint-path' to checkpoint stdlib example
The 'configs/example/gem5_library_example_tests/test_gem5_library_examples.py' example would dump the savepoint in the CWD. This is fine when running as an example, but we also run this script as a test. In this case the checkpoint litters the repository. To fix this, an optional 'checkpoint-path' argument is added to this example which specifies where the checkpoint is to be saved. In the tests, the checkpoint is saved to 'tests/gem5/resources'. This is our default location for resources needed/produced by tests and is ignored by git. Change-Id: Ib985433786c99c37794a1c67cc4337a5dfd0498d Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/64091 Reviewed-by: Jason Lowe-Power <power.jg@gmail.com> Tested-by: kokoro <noreply+kokoro@google.com> Maintainer: Jason Lowe-Power <power.jg@gmail.com>
This commit is contained in:
committed by
Bobby Bruce
parent
3e51091806
commit
64a087e5e8
@@ -43,6 +43,7 @@ scons build/RISCV/gem5.opt
|
||||
```
|
||||
"""
|
||||
|
||||
import argparse
|
||||
from gem5.isas import ISA
|
||||
from gem5.utils.requires import requires
|
||||
from gem5.resources.resource import Resource
|
||||
@@ -53,6 +54,18 @@ from gem5.components.cachehierarchies.classic.no_cache import NoCache
|
||||
from gem5.components.processors.simple_processor import SimpleProcessor
|
||||
from gem5.simulate.simulator import Simulator
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
|
||||
parser.add_argument(
|
||||
"--checkpoint-path",
|
||||
type=str,
|
||||
required=False,
|
||||
default="riscv-hello-checkpoint/",
|
||||
help="The directory to store the checkpoint.",
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
# This check ensures the gem5 binary is compiled to the RISCV ISA target.
|
||||
# If not, an exception will be thrown.
|
||||
requires(isa_required=ISA.RISCV)
|
||||
@@ -102,7 +115,6 @@ print(
|
||||
)
|
||||
)
|
||||
|
||||
checkpoint_path = "riscv-hello-checkpoint/"
|
||||
print("Taking a checkpoint at", checkpoint_path)
|
||||
simulator.save_checkpoint(checkpoint_path)
|
||||
print("Taking a checkpoint at", args.checkpoint_path)
|
||||
simulator.save_checkpoint(args.checkpoint_path)
|
||||
print("Done taking a checkpoint")
|
||||
|
||||
@@ -32,6 +32,11 @@ from testlib import *
|
||||
import re
|
||||
import os
|
||||
|
||||
if config.bin_path:
|
||||
resource_path = config.bin_path
|
||||
else:
|
||||
resource_path = joinpath(absdirpath(__file__), "..", "resources")
|
||||
|
||||
hello_verifier = verifier.MatchRegex(re.compile(r"Hello world!"))
|
||||
save_checkpoint_verifier = verifier.MatchRegex(
|
||||
re.compile(r"Done taking a checkpoint")
|
||||
@@ -62,7 +67,10 @@ gem5_verify_config(
|
||||
"checkpoints",
|
||||
"riscv-hello-save-checkpoint.py",
|
||||
),
|
||||
config_args=[],
|
||||
config_args=[
|
||||
"--checkpoint-path",
|
||||
joinpath(resource_path, "riscv-hello-checkpoint-save"),
|
||||
],
|
||||
valid_isas=(constants.all_compiled_tag,),
|
||||
valid_hosts=constants.supported_hosts,
|
||||
length=constants.quick_tag,
|
||||
|
||||
Reference in New Issue
Block a user