From 454ba32c519ff1d16ba25b88d14b408810c67f86 Mon Sep 17 00:00:00 2001 From: Giacomo Travaglini Date: Thu, 16 Jan 2020 10:39:46 +0000 Subject: tests: Adding --bin-path option to select tests bin directory So far lots of tests will download binaries inside the gem5 directory. The path is also specific to the test being run. This doesn't play well with an environment where gem5 is cloned from scratch for every build, or if several gem5 are cloned in a single machine. Binaries will be automatically downloaded every time this happens. This patch is adding a --bin-path option, so that it's possible to setup a fixed directory with all pre-downloaded binaries. By default it is set to None to preserve original behaviour. Change-Id: I42fb25e3ce0a495c73672b15a097b1bd2607795c Signed-off-by: Giacomo Travaglini Reviewed-by: Ciro Santilli Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/24525 Reviewed-by: Jason Lowe-Power Reviewed-by: Bobby R. Bruce Maintainer: Jason Lowe-Power Tested-by: kokoro --- ext/testlib/config.py | 22 ++++++++++++++++++++++ tests/gem5/cpu_tests/test.py | 17 ++++++++++++++++- tests/gem5/fs/linux/arm/test.py | 7 ++++--- tests/gem5/hello_se/test_hello_se.py | 21 +++++++++++++++++++-- tests/gem5/m5_util/test_exit.py | 19 +++++++++++++++++-- 5 files changed, 78 insertions(+), 8 deletions(-) diff --git a/ext/testlib/config.py b/ext/testlib/config.py index 5e28cd0fd..513463fd8 100644 --- a/ext/testlib/config.py +++ b/ext/testlib/config.py @@ -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. # @@ -521,6 +533,13 @@ def define_common_args(config): action='store', help='The path to store results in.' ), + Argument( + '--bin-path', + action='store', + default=None, + help='Path where binaries are stored (downloaded if not present)' + ), + ] # NOTE: There is a limitation which arises due to this format. If you have @@ -576,6 +595,7 @@ class RunParser(ArgParser): common_args.directory.add_to(parser) common_args.build_dir.add_to(parser) common_args.base_dir.add_to(parser) + common_args.bin_path.add_to(parser) common_args.threads.add_to(parser) common_args.test_threads.add_to(parser) common_args.isa.add_to(parser) @@ -629,6 +649,7 @@ class ListParser(ArgParser): ).add_to(parser) common_args.directory.add_to(parser) + common_args.bin_path.add_to(parser) common_args.isa.add_to(parser) common_args.variant.add_to(parser) common_args.length.add_to(parser) @@ -648,6 +669,7 @@ class RerunParser(ArgParser): common_args.directory.add_to(parser) common_args.build_dir.add_to(parser) common_args.base_dir.add_to(parser) + common_args.bin_path.add_to(parser) common_args.threads.add_to(parser) common_args.test_threads.add_to(parser) common_args.isa.add_to(parser) diff --git a/tests/gem5/cpu_tests/test.py b/tests/gem5/cpu_tests/test.py index 1a61a7331..073bcc410 100644 --- a/tests/gem5/cpu_tests/test.py +++ b/tests/gem5/cpu_tests/test.py @@ -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) 2018 The Regents of the University of California # All Rights Reserved. # @@ -41,8 +53,11 @@ valid_isas = { 'riscv': ('AtomicSimpleCPU', 'TimingSimpleCPU', 'MinorCPU', 'DerivO3CPU'), } +if config.bin_path: + base_path = config.bin_path +else: + base_path = joinpath(absdirpath(__file__), 'benchmarks', 'bin') -base_path = joinpath(absdirpath(__file__), 'benchmarks', 'bin') base_url = 'http://dist.gem5.org/dist/current/gem5/cpu_tests/benchmarks/bin/' for isa in valid_isas: path = joinpath(base_path, isa) diff --git a/tests/gem5/fs/linux/arm/test.py b/tests/gem5/fs/linux/arm/test.py index fd1e05e05..d9d380e68 100644 --- a/tests/gem5/fs/linux/arm/test.py +++ b/tests/gem5/fs/linux/arm/test.py @@ -85,7 +85,8 @@ arm_fs_long_tests = [ tarball = 'aarch-system-201901106.tar.bz2' url = "http://dist.gem5.org/dist/current/arm/" + tarball -path = os.path.dirname(os.path.abspath(__file__)) +filepath = os.path.dirname(os.path.abspath(__file__)) +path = config.bin_path if config.bin_path else filepath arm_fs_binaries = DownloadedArchive(url, path, tarball) for name in arm_fs_quick_tests: @@ -96,7 +97,7 @@ for name in arm_fs_quick_tests: gem5_verify_config( name=name, verifiers=(), # Add basic stat verifiers - config=joinpath(path, 'run.py'), + config=joinpath(filepath, 'run.py'), config_args=args, valid_isas=(constants.arm_tag,), length=constants.quick_tag, @@ -111,7 +112,7 @@ for name in arm_fs_long_tests: gem5_verify_config( name=name, verifiers=(), # TODO: Add basic stat verifiers - config=joinpath(path, 'run.py'), + config=joinpath(filepath, 'run.py'), config_args=args, valid_isas=(constants.arm_tag,), length=constants.long_tag, diff --git a/tests/gem5/hello_se/test_hello_se.py b/tests/gem5/hello_se/test_hello_se.py index 3ebf40cce..74d7fb1a6 100644 --- a/tests/gem5/hello_se/test_hello_se.py +++ b/tests/gem5/hello_se/test_hello_se.py @@ -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. # @@ -40,13 +52,18 @@ test_progs = { 'sparc': ('hello',) } +if config.bin_path: + base_path = config.bin_path +else: + base_path = joinpath(absdirpath(__file__), '..', 'test-progs', 'hello', + 'bin') + urlbase = 'http://dist.gem5.org/dist/current/test-progs/hello/bin/' for isa in test_progs: for binary in test_progs[isa]: import os url = urlbase + isa + '/linux/' + binary - path = joinpath(absdirpath(__file__), '..', 'test-progs', 'hello', - 'bin', isa, 'linux') + path = joinpath(base_path, isa, 'linux') hello_program = DownloadedProgram(url, path, binary) ref_path = joinpath(getcwd(), 'ref') diff --git a/tests/gem5/m5_util/test_exit.py b/tests/gem5/m5_util/test_exit.py index 22680740b..e67e37428 100644 --- a/tests/gem5/m5_util/test_exit.py +++ b/tests/gem5/m5_util/test_exit.py @@ -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. # @@ -37,8 +49,11 @@ m5_exit_regex = re.compile( r'Exiting @ tick \d* because m5_exit instruction encountered' ) -path = joinpath(absdirpath(__file__), '..', - 'test-progs', 'hello', 'bin', 'x86', 'linux') +if config.bin_path: + path = config.bin_path +else: + path = joinpath(absdirpath(__file__), '..', + 'test-progs', 'hello', 'bin', 'x86', 'linux') filename = 'm5_exit' url = 'http://dist.gem5.org/dist/current/test-progs/' + 'm5-exit/bin/x86/linux/m5_exit' -- cgit v1.2.3