Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,4 @@ _UpgradeReport_Files/
run*/
/tests/scripts/systemc/
/tests/scripts/tlm/
/.cache
11 changes: 11 additions & 0 deletions docker/alma.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ FROM $IMAGE

WORKDIR /app

ARG ALMA_VERSION=$ALMA_VERSION
RUN dnf install -y \
cmake \
gcc \
Expand All @@ -14,6 +15,16 @@ RUN dnf install -y \
libubsan \
&& dnf clean all

# Installing gtest is version-dependent. 8 is mostly normal, though we need an
# extra repo:
#
# TODO: can these both work via just enabling epel-release?
RUN [ "$ALMA_VERSION" -eq 8 ] && dnf config-manager --set-enabled powertools || exit 0
RUN [ "$ALMA_VERSION" -eq 9 ] && dnf install -y epel-release || exit 0

RUN dnf update -y || exit 0
RUN dnf install -y gtest-devel gmock-devel || exit 0

# Copy the current directory contents into the container at /app
COPY . /app
# Setup entrypoint CI script
Expand Down
2 changes: 2 additions & 0 deletions docker/ubuntu.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ RUN apt-get update && \
g++ \
clang \
gcovr \
libgtest-dev \
libgmock-dev \
&& rm -rf /var/lib/apt/lists/*

# Copy the current directory contents into the container at /app
Expand Down
126 changes: 2 additions & 124 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,135 +16,13 @@
# permissions and limitations under the License.
#
###############################################################################
#
# tests/CMakeLists.txt -- discover and build SystemC regression tests
#
# Original Author: Philipp A. Hartmann, Apple Inc.
#
###############################################################################

if (NOT ENABLE_REGRESSION)
return()
endif()

cmake_minimum_required(VERSION 3.12...3.31) # FindPython3

set(TEST_CATEGORY tests)
include(SystemCTesting)

###############################################################################

find_package(Python3 COMPONENTS Interpreter REQUIRED) # needed for run-test.py

###############################################################################

function(configure_and_add_regression_test TEST_PATH)
string(REGEX REPLACE "^([^/]+)/.*" "\\1" TEST_GROUP "${TEST_PATH}")
get_filename_component(TEST_FOLDER "${TEST_PATH}" DIRECTORY)
string(REPLACE "/" "-" TEST_NAME "${TEST_PATH}")

# message(DEBUG "found ${TEST_GROUP} test: ${TEST_NAME} (${TEST_PATH})")
add_executable(${TEST_NAME})
set_target_properties(${TEST_NAME} PROPERTIES FOLDER "tests/${TEST_FOLDER}")
add_dependencies(all-tests ${TEST_NAME})

file(GLOB sources CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${TEST_PATH}/*.f")
if(sources) # found a file list
get_filename_component(TEST_LEAFNAME ${sources} NAME_WLE)
file(STRINGS ${sources} sources_list)
set(sources)
foreach(src ${sources_list})
string(REGEX REPLACE "^[^/]+/(.*)" "${CMAKE_CURRENT_SOURCE_DIR}/${TEST_PATH}/\\1" src "${src}")
string(STRIP "${src}" src)
list(APPEND sources ${src})
endforeach()
else(sources)
file(GLOB sources CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${TEST_PATH}/*.cpp")
get_filename_component(TEST_LEAFNAME ${sources} NAME_WLE)
endif(sources)
# message(TRACE "found ${TEST_NAME} sources: ${sources}")
target_sources(${TEST_NAME} PRIVATE ${sources})

if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/${TEST_GROUP}")
target_include_directories(${TEST_NAME} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/include/${TEST_GROUP}")
endif()
target_link_libraries(${TEST_NAME} PRIVATE SystemC::systemc)


set(testname ${TEST_PATH}${TEST_SUFFIX})
add_test(NAME ${testname}
COMMAND ${Python3_EXECUTABLE} ${PROJECT_SOURCE_DIR}/cmake/run-test.py $<TARGET_FILE:${TEST_NAME}>)

set(workdir ${CMAKE_CURRENT_BINARY_DIR}/Testing/${TEST_PATH})
get_filename_component(leafdir ${TEST_PATH} NAME)
file(MAKE_DIRECTORY ${workdir})
if (UNIX OR MINGW)
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink
${CMAKE_CURRENT_SOURCE_DIR}/${TEST_PATH}
${workdir}/${leafdir})
else()
# use mklink /J (junction) on Windows to avoid need for special privileges
file(TO_NATIVE_PATH ${workdir}/${leafdir} _dstDir)
file(TO_NATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/${TEST_PATH} _srcDir)
execute_process(COMMAND cmd.exe /c mklink /J "${_dstDir}" "${_srcDir}")
endif()

set(env
SYSTEMC_REGRESSION=1
SYSTEMC_ARCH=${SystemC_TARGET_ARCH}
TEST_FULLNAME=${TEST_PATH}
TEST_LEAFNAME=${TEST_LEAFNAME}
TEST_BUILD_TYPE=$<CONFIG>
)

# Windows might heuristically block some test executables when
# their name contains certain keywords, e.g., "update".
# Set requested execution level to "asInvoker" to disable heuristic analysis.
if (WIN32)
list(APPEND env "__COMPAT_LAYER=RunAsInvoker")
endif()

set_tests_properties(${testname} PROPERTIES
LABELS "${TEST_GROUP}"
ENVIRONMENT "${env}"
SKIP_RETURN_CODE 111
WORKING_DIRECTORY ${workdir}
)
endfunction(configure_and_add_regression_test)

function(skip_test TEST_PATH)
set(testname ${TEST_PATH}${TEST_SUFFIX})
get_test_property(${testname} ENVIRONMENT env)
list(APPEND env TEST_SKIPPED=yes)
set_tests_properties(${testname} PROPERTIES ENVIRONMENT "${env}")
endfunction(skip_test)

function(discover_regression_tests)
# find all golden log directories
file(GLOB_RECURSE tests
LIST_DIRECTORIES TRUE
RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
CONFIGURE_DEPENDS "golden"
)
foreach(test ${tests})
if (IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${test}/golden")
configure_and_add_regression_test(${test})
endif()
endforeach()
endfunction()

discover_regression_tests()

###############################################################################
# Additional compile/link options for specific tests

target_link_libraries(systemc-kernel-sc_suspend PRIVATE Threads::Threads)

if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# Ignore overly strict -Wfree-nonheap-object warning on GCC 11.0 and later
# -- https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54202
target_compile_options(systemc-1666-2011-compliance-event_list PRIVATE
$<$<VERSION_GREATER_EQUAL:$<CXX_COMPILER_VERSION>,11.0.0>:-Wno-free-nonheap-object>
)
endif()

add_subdirectory(golden-file)
add_subdirectory(gtest)
5 changes: 5 additions & 0 deletions tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# SystemC Testing

There are two test suites:
+ An older, golden-file based test suite in `golden-file`
+ A newer, GTest based test suite in `gtest`.
140 changes: 140 additions & 0 deletions tests/golden-file/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
###############################################################################
#
# Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
# more contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright ownership.
# Accellera licenses this file to you under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with the
# License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied. See the License for the specific language governing
# permissions and limitations under the License.
#
###############################################################################
#
# tests/CMakeLists.txt -- discover and build SystemC regression tests
#
# Original Author: Philipp A. Hartmann, Apple Inc.
#
###############################################################################

cmake_minimum_required(VERSION 3.12...3.31) # FindPython3

###############################################################################

find_package(Python3 COMPONENTS Interpreter REQUIRED) # needed for run-test.py

###############################################################################

function(configure_and_add_regression_test TEST_PATH)
string(REGEX REPLACE "^[^/]+/([^/]+)/.*" "\\1" TEST_GROUP "${TEST_PATH}")
get_filename_component(TEST_FOLDER "${TEST_PATH}" DIRECTORY)
string(REPLACE "/" "-" TEST_NAME "${TEST_PATH}")

# message(DEBUG "found ${TEST_GROUP} test: ${TEST_NAME} (${TEST_PATH})")
add_executable(${TEST_NAME})
set_target_properties(${TEST_NAME} PROPERTIES FOLDER "tests/${TEST_FOLDER}")
add_dependencies(all-tests ${TEST_NAME})

file(GLOB sources CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${TEST_PATH}/*.f")
if(sources) # found a file list
get_filename_component(TEST_LEAFNAME ${sources} NAME_WLE)
file(STRINGS ${sources} sources_list)
set(sources)
foreach(src ${sources_list})
string(REGEX REPLACE "^[^/]+/(.*)" "${CMAKE_CURRENT_SOURCE_DIR}/${TEST_PATH}/\\1" src "${src}")
string(STRIP "${src}" src)
list(APPEND sources ${src})
endforeach()
else(sources)
file(GLOB sources CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${TEST_PATH}/*.cpp")
get_filename_component(TEST_LEAFNAME ${sources} NAME_WLE)
endif(sources)
# message(TRACE "found ${TEST_NAME} sources: ${sources}")
target_sources(${TEST_NAME} PRIVATE ${sources})

target_include_directories(${TEST_NAME} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/include/tlm")
target_link_libraries(${TEST_NAME} PRIVATE SystemC::systemc)


set(testname ${TEST_PATH}${TEST_SUFFIX})
add_test(NAME ${testname}
COMMAND ${Python3_EXECUTABLE} ${PROJECT_SOURCE_DIR}/cmake/run-test.py $<TARGET_FILE:${TEST_NAME}>)

set(workdir ${CMAKE_CURRENT_BINARY_DIR}/Testing/${TEST_PATH})
get_filename_component(leafdir ${TEST_PATH} NAME)
file(MAKE_DIRECTORY ${workdir})
if (UNIX OR MINGW)
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink
${CMAKE_CURRENT_SOURCE_DIR}/${TEST_PATH}
${workdir}/${leafdir})
else()
# use mklink /J (junction) on Windows to avoid need for special privileges
file(TO_NATIVE_PATH ${workdir}/${leafdir} _dstDir)
file(TO_NATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/${TEST_PATH} _srcDir)
execute_process(COMMAND cmd.exe /c mklink /J "${_dstDir}" "${_srcDir}")
endif()

set(env
SYSTEMC_REGRESSION=1
SYSTEMC_ARCH=${SystemC_TARGET_ARCH}
TEST_FULLNAME=${TEST_PATH}
TEST_LEAFNAME=${TEST_LEAFNAME}
TEST_BUILD_TYPE=$<CONFIG>
)

# Windows might heuristically block some test executables when
# their name contains certain keywords, e.g., "update".
# Set requested execution level to "asInvoker" to disable heuristic analysis.
if (WIN32)
list(APPEND env "__COMPAT_LAYER=RunAsInvoker")
endif()

set_tests_properties(${testname} PROPERTIES
LABELS "${TEST_GROUP}"
ENVIRONMENT "${env}"
SKIP_RETURN_CODE 111
WORKING_DIRECTORY ${workdir}
)
endfunction(configure_and_add_regression_test)

function(skip_test TEST_PATH)
set(testname ${TEST_PATH}${TEST_SUFFIX})
get_test_property(${testname} ENVIRONMENT env)
list(APPEND env TEST_SKIPPED=yes)
set_tests_properties(${testname} PROPERTIES ENVIRONMENT "${env}")
endfunction(skip_test)

function(discover_regression_tests)
# find all golden log directories
file(GLOB_RECURSE tests
LIST_DIRECTORIES TRUE
RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
CONFIGURE_DEPENDS "golden"
)
foreach(test ${tests})
if (IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${test}/golden")
configure_and_add_regression_test(${test})
endif()
endforeach()
endfunction()

discover_regression_tests()

###############################################################################
# Additional compile/link options for specific tests

target_link_libraries(systemc-kernel-sc_suspend PRIVATE Threads::Threads)

if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# Ignore overly strict -Wfree-nonheap-object warning on GCC 11.0 and later
# -- https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54202
target_compile_options(systemc-1666-2011-compliance-event_list PRIVATE
$<$<VERSION_GREATER_EQUAL:$<CXX_COMPILER_VERSION>,11.0.0>:-Wno-free-nonheap-object>
)
endif()
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading
Loading