Bobby Bruce has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/64091?usp=email )

Change subject: tests: Add 'checkpoint-path' to checkpoint stdlib example
......................................................................

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
---
M configs/example/gem5_library/checkpoints/riscv-hello-save-checkpoint.py
M tests/gem5/gem5_library_example_tests/test_gem5_library_examples.py
2 files changed, 45 insertions(+), 4 deletions(-)



diff --git a/configs/example/gem5_library/checkpoints/riscv-hello-save-checkpoint.py b/configs/example/gem5_library/checkpoints/riscv-hello-save-checkpoint.py
index c00b43d..159c4b7 100644
--- a/configs/example/gem5_library/checkpoints/riscv-hello-save-checkpoint.py +++ b/configs/example/gem5_library/checkpoints/riscv-hello-save-checkpoint.py
@@ -43,6 +43,7 @@
 ```
 """

+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.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 @@
     )
 )

-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")
diff --git a/tests/gem5/gem5_library_example_tests/test_gem5_library_examples.py b/tests/gem5/gem5_library_example_tests/test_gem5_library_examples.py
index ee212ae..d60fbb3 100644
--- a/tests/gem5/gem5_library_example_tests/test_gem5_library_examples.py
+++ b/tests/gem5/gem5_library_example_tests/test_gem5_library_examples.py
@@ -32,6 +32,11 @@
 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 @@
         "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,

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/64091?usp=email To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: Ib985433786c99c37794a1c67cc4337a5dfd0498d
Gerrit-Change-Number: 64091
Gerrit-PatchSet: 1
Gerrit-Owner: Bobby Bruce <bbr...@ucdavis.edu>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org

Reply via email to