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
4313725Sgabeblack@google.comm5.systemc.sc_main('gem5_systemc_test');
4412870Sgabeblack@google.com
4512870Sgabeblack@google.comm5.instantiate(None)
4612870Sgabeblack@google.com
4712870Sgabeblack@google.comcause = m5.simulate(m5.MaxTick).getCause()
4813082Sgabeblack@google.com
4913725Sgabeblack@google.comresult = m5.systemc.sc_main_result()
5013082Sgabeblack@google.comif result.code != 0:
5113082Sgabeblack@google.com    # Arguably this should make gem5 fail, but some tests purposefully
5213082Sgabeblack@google.com    # generate errors, and as long as their output matches that's still
5313082Sgabeblack@google.com    # considered correct. A "real" systemc config should expect sc_main
5413082Sgabeblack@google.com    # (if present) not to fail.
5513182Sgabeblack@google.com    sys.exit(int(result.code))
56