tests: Add --host tag
authorGiacomo Travaglini <giacomo.travaglini@arm.com>
Fri, 17 Jan 2020 14:04:47 +0000 (14:04 +0000)
committerGiacomo Travaglini <giacomo.travaglini@arm.com>
Mon, 10 Feb 2020 09:57:56 +0000 (09:57 +0000)
A host tag has been added to take into consideration the host ISA which
is running gem5 (default is X86).
There might be regressions which are supposed to be run on a particular
host machine only. This could be the case of dynamically linked
regressions which require dynamic linker/loader + shared libraries of
the same ISA as the target.

Change-Id: I4c4044a4f1b8899f443856340df302df7c1aaf8e
Signed-off-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
Reviewed-by: Ciro Santilli <ciro.santilli@arm.com>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/24527
Reviewed-by: Jason Lowe-Power <jason@lowepower.com>
Maintainer: Bobby R. Bruce <bbruce@ucdavis.edu>
Tested-by: kokoro <noreply+kokoro@google.com>
ext/testlib/config.py
ext/testlib/main.py
tests/gem5/.testignore
tests/gem5/suite.py

index 513463fd863cf712a8af85bacdcfc77cd2398469..643ef68cadc05533a5e5edad5a5775487f07dc9d 100644 (file)
@@ -251,6 +251,11 @@ def define_constants(constants):
     constants.quick_tag = 'quick'
     constants.long_tag = 'long'
 
+    constants.host_isa_tag_type = 'host'
+    constants.host_x86_64_tag = 'x86_64'
+    constants.host_i386_tag = 'i386'
+    constants.host_arm_tag = 'aarch64'
+
     constants.supported_tags = {
         constants.isa_tag_type : (
             constants.x86_tag,
@@ -271,11 +276,30 @@ def define_constants(constants):
             constants.quick_tag,
             constants.long_tag,
         ),
+        constants.host_isa_tag_type: (
+            constants.host_x86_64_tag,
+            constants.host_i386_tag,
+            constants.host_arm_tag,
+        ),
+    }
+
+    # Binding target ISA with host ISA. This is useful for the
+    # case where host ISA and target ISA need to coincide
+    constants.target_host = {
+        constants.arm_tag   : (constants.host_arm_tag,),
+        constants.x86_tag   : (constants.host_x86_64_tag, constants.host_i386_tag),
+        constants.sparc_tag : (constants.host_x86_64_tag, constants.host_i386_tag),
+        constants.alpha_tag : (constants.host_x86_64_tag, constants.host_i386_tag),
+        constants.riscv_tag : (constants.host_x86_64_tag, constants.host_i386_tag),
+        constants.mips_tag  : (constants.host_x86_64_tag, constants.host_i386_tag),
+        constants.power_tag : (constants.host_x86_64_tag, constants.host_i386_tag),
+        constants.null_tag  : (None,)
     }
 
     constants.supported_isas = constants.supported_tags['isa']
     constants.supported_variants = constants.supported_tags['variant']
     constants.supported_lengths = constants.supported_tags['length']
+    constants.supported_hosts = constants.supported_tags['host']
 
     constants.tempdir_fixture_name = 'tempdir'
     constants.gem5_simulation_stderr = 'simerr'
@@ -347,6 +371,19 @@ def define_post_processors(config):
         else:
             return length
 
+    def default_host(host):
+        if not host[0]:
+            try:
+                import platform
+                host_machine = platform.machine()
+                if host_machine not in constants.supported_hosts:
+                    raise ValueError("Invalid host machine")
+                return [[host_machine]]
+            except:
+                return [[constants.host_x86_64_tag]]
+        else:
+            return host
+
     def compile_tag_regex(positional_tags):
         if not positional_tags:
             return positional_tags
@@ -370,6 +407,7 @@ def define_post_processors(config):
     config._add_post_processor('isa', default_isa)
     config._add_post_processor('variant', default_variant)
     config._add_post_processor('length', default_length)
+    config._add_post_processor('host', default_host)
     config._add_post_processor('threads', threads_as_int)
     config._add_post_processor('test_threads', test_threads_as_int)
     config._add_post_processor(StorePositionalTagsAction.position_kword,
@@ -486,6 +524,11 @@ def define_common_args(config):
             action='append',
             default=[],
             help="Only tests that are one of these lengths. Comma separated."),
+        Argument(
+            '--host',
+            action='append',
+            default=[],
+            help="Only tests that are meant to runnable on the selected host"),
         Argument(
             '--uid',
             action='store',
@@ -601,6 +644,7 @@ class RunParser(ArgParser):
         common_args.isa.add_to(parser)
         common_args.variant.add_to(parser)
         common_args.length.add_to(parser)
+        common_args.host.add_to(parser)
         common_args.include_tags.add_to(parser)
         common_args.exclude_tags.add_to(parser)
 
@@ -653,6 +697,7 @@ class ListParser(ArgParser):
         common_args.isa.add_to(parser)
         common_args.variant.add_to(parser)
         common_args.length.add_to(parser)
+        common_args.host.add_to(parser)
         common_args.include_tags.add_to(parser)
         common_args.exclude_tags.add_to(parser)
 
@@ -675,6 +720,7 @@ class RerunParser(ArgParser):
         common_args.isa.add_to(parser)
         common_args.variant.add_to(parser)
         common_args.length.add_to(parser)
+        common_args.host.add_to(parser)
 
 config = _Config()
 define_constants(config.constants)
index cbba0005f2d836003fc781ccc61974c0da2ed723..3827f7815f2f48dbd76a09eb31c3a2b17fe5816a 100644 (file)
@@ -114,6 +114,7 @@ def filter_with_config_tags(loaded_library):
     special_tags = (
         cfg.constants.isa_tag_type,
         cfg.constants.length_tag_type,
+        cfg.constants.host_isa_tag_type,
         cfg.constants.variant_tag_type
     )
 
index 99911b843d5616e5be2a88148627a0f61784cc96..bca395ddeee9baa38239b4f725732d40754aef2f 100644 (file)
@@ -1,12 +1,36 @@
-test-hello-RISCV-opt
-test-hello-RISCV-debug
-test-hello-RISCV-fast
-test-hello-SPARC-opt
-test-hello-SPARC-debug
-test-hello-SPARC-fast
-test-hello-MIPS-opt
-test-hello-MIPS-debug
-test-hello-MIPS-fast
-test-hello-ALPHA-opt
-test-hello-ALPHA-debug
-test-hello-ALPHA-fast
+test-hello-RISCV-x86_64-opt
+test-hello-RISCV-x86_64-debug
+test-hello-RISCV-x86_64-fast
+test-hello-RISCV-i386-opt
+test-hello-RISCV-i386-debug
+test-hello-RISCV-i386-fast
+test-hello-RISCV-aarch64-opt
+test-hello-RISCV-aarch64-debug
+test-hello-RISCV-aarch64-fast
+test-hello-SPARC-x86_64-opt
+test-hello-SPARC-x86_64-debug
+test-hello-SPARC-x86_64-fast
+test-hello-SPARC-i386-opt
+test-hello-SPARC-i386-debug
+test-hello-SPARC-i386-fast
+test-hello-SPARC-aarch64-opt
+test-hello-SPARC-aarch64-debug
+test-hello-SPARC-aarch64-fast
+test-hello-MIPS-x86_64-opt
+test-hello-MIPS-x86_64-debug
+test-hello-MIPS-x86_64-fast
+test-hello-MIPS-i386-opt
+test-hello-MIPS-i386-debug
+test-hello-MIPS-i386-fast
+test-hello-MIPS-aarch64-opt
+test-hello-MIPS-aarch64-debug
+test-hello-MIPS-aarch64-fast
+test-hello-ALPHA-x86_64-opt
+test-hello-ALPHA-x86_64-debug
+test-hello-ALPHA-x86_64-fast
+test-hello-ALPHA-i386-opt
+test-hello-ALPHA-i386-debug
+test-hello-ALPHA-i386-fast
+test-hello-ALPHA-aarch64-opt
+test-hello-ALPHA-aarch64-debug
+test-hello-ALPHA-aarch64-fast
index 2c4879759b27fac876313d4a1202eaedc5c84f7f..85ffeda7e4ce6fd51f7fc800076bfc4e9a0f04cf 100644 (file)
@@ -1,3 +1,15 @@
+# Copyright (c) 2020 ARM Limited
+# All rights reserved
+#
+# The license below extends only to copyright in the software and shall
+# not be construed as granting a license to any other intellectual
+# property including but not limited to intellectual property relating
+# to a hardware implementation of the functionality of the software
+# licensed hereunder.  You may use the software subject to the license
+# terms below provided that you ensure that this notice is replicated
+# unmodified and in its entirety in all distributions of the software,
+# modified or unmodified, in source code or in binary form.
+#
 # Copyright (c) 2017 Mark D. Hill and David A. Wood
 # All rights reserved.
 #
@@ -47,6 +59,7 @@ def gem5_verify_config(name,
                        valid_isas=constants.supported_isas,
                        valid_variants=constants.supported_variants,
                        length=constants.supported_lengths[0],
+                       valid_hosts=constants.supported_hosts,
                        protocol=None):
     '''
     Helper class to generate common gem5 tests using verifiers.
@@ -85,58 +98,60 @@ def gem5_verify_config(name,
     if os.path.exists(_test_ignore_file_loc):
         ignore.update(open(_test_ignore_file_loc).read().splitlines())
 
-    for opt in valid_variants:
-        for isa in valid_isas:
-
-            # Create a tempdir fixture to be shared throughout the test.
-            tempdir = TempdirFixture()
-            gem5_returncode = VariableFixture(
-                    name=constants.gem5_returncode_fixture_name)
-
-            # Common name of this generated testcase.
-            _name = '{given_name}-{isa}-{opt}'.format(
-                    given_name=name,
-                    isa=isa,
-                    opt=opt)
-            if protocol:
-                _name += '-'+protocol
-
-            # We check to see if this test suite is to be ignored. If so, we
-            # skip it.
-            if _name in ignore:
-                continue
-
-            # Create the running of gem5 subtest.
-            # NOTE: We specifically create this test before our verifiers so
-            # this is listed first.
-            tests = []
-            gem5_execution = TestFunction(
-                    _create_test_run_gem5(config, config_args, gem5_args),
-                    name=_name)
-            tests.append(gem5_execution)
-
-            # Create copies of the verifier subtests for this isa and
-            # variant.
-            for verifier in verifiers:
-                tests.append(verifier.instantiate_test(_name))
-
-            # Add the isa and variant to tags list.
-            tags = [isa, opt, length]
-
-            # Create the gem5 target for the specific architecture and
-            # variant.
-            _fixtures = copy.copy(fixtures)
-            _fixtures.append(Gem5Fixture(isa, opt, protocol))
-            _fixtures.append(tempdir)
-            _fixtures.append(gem5_returncode)
-
-            # Finally construct the self contained TestSuite out of our
-            # tests.
-            testsuites.append(TestSuite(
-                name=_name,
-                fixtures=_fixtures,
-                tags=tags,
-                tests=tests))
+    for host in valid_hosts:
+        for opt in valid_variants:
+            for isa in valid_isas:
+
+                # Create a tempdir fixture to be shared throughout the test.
+                tempdir = TempdirFixture()
+                gem5_returncode = VariableFixture(
+                        name=constants.gem5_returncode_fixture_name)
+
+                # Common name of this generated testcase.
+                _name = '{given_name}-{isa}-{host}-{opt}'.format(
+                        given_name=name,
+                        isa=isa,
+                        host=host,
+                        opt=opt)
+                if protocol:
+                    _name += '-'+protocol
+
+                # We check to see if this test suite is to be ignored. If so,
+                # we skip it.
+                if _name in ignore:
+                    continue
+
+                # Create the running of gem5 subtest.  NOTE: We specifically
+                # create this test before our verifiers so this is listed
+                # first.
+                tests = []
+                gem5_execution = TestFunction(
+                        _create_test_run_gem5(config, config_args, gem5_args),
+                        name=_name)
+                tests.append(gem5_execution)
+
+                # Create copies of the verifier subtests for this isa and
+                # variant.
+                for verifier in verifiers:
+                    tests.append(verifier.instantiate_test(_name))
+
+                # Add the isa and variant to tags list.
+                tags = [isa, opt, length, host]
+
+                # Create the gem5 target for the specific architecture and
+                # variant.
+                _fixtures = copy.copy(fixtures)
+                _fixtures.append(Gem5Fixture(isa, opt, protocol))
+                _fixtures.append(tempdir)
+                _fixtures.append(gem5_returncode)
+
+                # Finally construct the self contained TestSuite out of our
+                # tests.
+                testsuites.append(TestSuite(
+                    name=_name,
+                    fixtures=_fixtures,
+                    tags=tags,
+                    tests=tests))
     return testsuites
 
 def _create_test_run_gem5(config, config_args, gem5_args):