Bobby R. Bruce has submitted this change. ( https://gem5-review.googlesource.com/c/public/gem5/+/50487 )

Change subject: tests: Add KVM CPU switch tests
......................................................................

tests: Add KVM CPU switch tests

These test switching from KVM cores to other, more detailed cores using
the x86-ubuntu-img resource.

Change-Id: Ief5d09084a88726fc3944e0c56f3a61a5d04ec1b
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/50487
Maintainer: Bobby R. Bruce <[email protected]>
Tested-by: kokoro <[email protected]>
Reviewed-by: Austin Harris <[email protected]>
---
M tests/gem5/configs/boot_kvm_switch_exit.py
A tests/gem5/kvm-switch-tests/test_kvm_cpu_switch.py
2 files changed, 143 insertions(+), 1 deletion(-)

Approvals:
  Austin Harris: Looks good to me, approved
  Bobby R. Bruce: Looks good to me, approved
  kokoro: Regressions pass




diff --git a/tests/gem5/configs/boot_kvm_switch_exit.py b/tests/gem5/configs/boot_kvm_switch_exit.py
index eaf9032..79f3d86 100644
--- a/tests/gem5/configs/boot_kvm_switch_exit.py
+++ b/tests/gem5/configs/boot_kvm_switch_exit.py
@@ -196,7 +196,7 @@
         resource_directory=args.resource_directory,
     ),
     disk_image=Resource(
-        "x86-boot-exit",
+        "x86-ubuntu-img",
         override=args.override_download,
         resource_directory=args.resource_directory,
     ),
diff --git a/tests/gem5/kvm-switch-tests/test_kvm_cpu_switch.py b/tests/gem5/kvm-switch-tests/test_kvm_cpu_switch.py
new file mode 100644
index 0000000..19e83e5
--- /dev/null
+++ b/tests/gem5/kvm-switch-tests/test_kvm_cpu_switch.py
@@ -0,0 +1,142 @@
+# Copyright (c) 2021 The Regents of the University of California
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met: redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer;
+# redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution;
+# neither the name of the copyright holders nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+"""
+The purpose of this Suite of tests is to check the gem5.components switchable
+processor is functioning as intended; allowing switching from KVM to a more
+detailed processor.
+"""
+
+import os
+
+from testlib import *
+
+if config.bin_path:
+    resource_path = config.bin_path
+else:
+    resource_path = joinpath(absdirpath(__file__), "..", "resources")
+
+
+def test_kvm_switch(cpu: str, num_cpus: int, mem_system: str, length: str):
+
+    if not os.access("/dev/kvm", mode=os.R_OK | os.W_OK):
+        # Don't run the tests if KVM is unavailable.
+        return
+
+    name = "{}-cpu_{}-cores_{}_kvm-switch-test".format(
+        cpu, str(num_cpus), mem_system
+    )
+    verifiers = []
+
+    if mem_system == "mesi_two_level":
+        protocol_to_use = "MESI_Two_Level"
+        isa_to_use = constants.x86_tag
+    elif mem_system == "mi_example":
+        protocol_to_use = None
+        isa_to_use = constants.x86_tag
+    else:
+        protocol_to_use = None
+        isa_to_use = constants.gcn3_x86_tag
+
+    gem5_verify_config(
+        name=name,
+        verifiers=verifiers,
+        fixtures=(),
+        config=joinpath(
+            config.base_dir,
+            "tests",
+            "gem5",
+            "configs",
+            "boot_kvm_switch_exit.py",
+        ),
+        config_args=[
+            "--cpu",
+            cpu,
+            "--num-cpus",
+            str(num_cpus),
+            "--mem-system",
+            mem_system,
+            "--override-download",
+            "--resource-directory",
+            resource_path,
+            "--kernel-args=''",
+        ],
+        valid_isas=(isa_to_use,),
+        valid_hosts=constants.supported_hosts,
+        protocol=protocol_to_use,
+        length=length,
+    )
+
+
+#### The quick (pre-submit/Kokoro) tests ####
+
+test_kvm_switch(
+ cpu="atomic", num_cpus=1, mem_system="classic", length=constants.quick_tag
+)
+test_kvm_switch(
+ cpu="timing", num_cpus=1, mem_system="classic", length=constants.quick_tag
+)
+test_kvm_switch(
+    cpu="o3", num_cpus=1, mem_system="classic", length=constants.quick_tag
+)
+test_kvm_switch(
+ cpu="timing", num_cpus=4, mem_system="classic", length=constants.quick_tag
+)
+
+test_kvm_switch(
+    cpu="timing",
+    num_cpus=4,
+    mem_system="mi_example",
+    length=constants.quick_tag,
+)
+
+### The long (nightly) tests ####
+
+test_kvm_switch(
+    cpu="atomic",
+    num_cpus=1,
+    mem_system="mesi_two_level",
+    length=constants.long_tag,
+)
+test_kvm_switch(
+    cpu="timing",
+    num_cpus=1,
+    mem_system="mesi_two_level",
+    length=constants.long_tag,
+)
+test_kvm_switch(
+    cpu="o3",
+    num_cpus=8,
+    mem_system="mesi_two_level",
+    length=constants.long_tag,
+)
+
+test_kvm_switch(
+    cpu="timing",
+    num_cpus=2,
+    mem_system="mesi_two_level",
+    length=constants.long_tag,
+)
\ No newline at end of file

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/50487
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: Ief5d09084a88726fc3944e0c56f3a61a5d04ec1b
Gerrit-Change-Number: 50487
Gerrit-PatchSet: 5
Gerrit-Owner: Bobby R. Bruce <[email protected]>
Gerrit-Reviewer: Austin Harris <[email protected]>
Gerrit-Reviewer: Bobby R. Bruce <[email protected]>
Gerrit-Reviewer: kokoro <[email protected]>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to