config.py revision 13725
112870Sgabeblack@google.com# Copyright 2018 Google, Inc. 212870Sgabeblack@google.com# 312870Sgabeblack@google.com# Redistribution and use in source and binary forms, with or without 412870Sgabeblack@google.com# modification, are permitted provided that the following conditions are 512870Sgabeblack@google.com# met: redistributions of source code must retain the above copyright 612870Sgabeblack@google.com# notice, this list of conditions and the following disclaimer; 712870Sgabeblack@google.com# redistributions in binary form must reproduce the above copyright 812870Sgabeblack@google.com# notice, this list of conditions and the following disclaimer in the 912870Sgabeblack@google.com# documentation and/or other materials provided with the distribution; 1012870Sgabeblack@google.com# neither the name of the copyright holders nor the names of its 1112870Sgabeblack@google.com# contributors may be used to endorse or promote products derived from 1212870Sgabeblack@google.com# this software without specific prior written permission. 1312870Sgabeblack@google.com# 1412870Sgabeblack@google.com# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1512870Sgabeblack@google.com# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1612870Sgabeblack@google.com# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 1712870Sgabeblack@google.com# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 1812870Sgabeblack@google.com# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 1912870Sgabeblack@google.com# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 2012870Sgabeblack@google.com# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2112870Sgabeblack@google.com# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2212870Sgabeblack@google.com# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2312870Sgabeblack@google.com# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 2412870Sgabeblack@google.com# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2512870Sgabeblack@google.com# 2612870Sgabeblack@google.com# Authors: Gabe Black 2712870Sgabeblack@google.com 2812870Sgabeblack@google.comfrom __future__ import print_function 2912870Sgabeblack@google.com 3013099Sgabeblack@google.comimport argparse 3112870Sgabeblack@google.comimport m5 3213099Sgabeblack@google.comimport os 3313082Sgabeblack@google.comimport re 3413182Sgabeblack@google.comimport sys 3512870Sgabeblack@google.com 3612870Sgabeblack@google.comfrom m5.objects import SystemC_Kernel, Root 3712870Sgabeblack@google.com 3812870Sgabeblack@google.com# pylint:disable=unused-variable 3912870Sgabeblack@google.com 4012870Sgabeblack@google.comkernel = SystemC_Kernel() 4112870Sgabeblack@google.comroot = Root(full_system=True, systemc_kernel=kernel) 4212870Sgabeblack@google.com 4313099Sgabeblack@google.comparser = argparse.ArgumentParser() 4413099Sgabeblack@google.comparser.add_argument('--working-dir') 4513099Sgabeblack@google.com 4613099Sgabeblack@google.comargs = parser.parse_args() 4713099Sgabeblack@google.comif args.working_dir: 4813099Sgabeblack@google.com os.chdir(args.working_dir) 4913099Sgabeblack@google.com 5013725Sgabeblack@google.comm5.systemc.sc_main('gem5_systemc_test'); 5112870Sgabeblack@google.com 5212870Sgabeblack@google.comm5.instantiate(None) 5312870Sgabeblack@google.com 5412870Sgabeblack@google.comcause = m5.simulate(m5.MaxTick).getCause() 5513082Sgabeblack@google.com 5613725Sgabeblack@google.comresult = m5.systemc.sc_main_result() 5713082Sgabeblack@google.comif result.code != 0: 5813082Sgabeblack@google.com # Arguably this should make gem5 fail, but some tests purposefully 5913082Sgabeblack@google.com # generate errors, and as long as their output matches that's still 6013082Sgabeblack@google.com # considered correct. A "real" systemc config should expect sc_main 6113082Sgabeblack@google.com # (if present) not to fail. 6213182Sgabeblack@google.com sys.exit(int(result.code)) 63