Commit f0445bf7 by Ben Clayton

CMake / Kokoro: Build and run system-unittests.

These were added for the .gn build, but were never enabled for the CMake build. Test these as part of the Kokoro presubmits. Bug: b/153193374 Change-Id: I36e7428bfe1a4867bea39b2fbb302aed6c3dff7b Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/43488 Kokoro-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Tested-by: 's avatarBen Clayton <bclayton@google.com>
parent b8d47928
...@@ -1167,6 +1167,40 @@ if(SWIFTSHADER_BUILD_TESTS) ...@@ -1167,6 +1167,40 @@ if(SWIFTSHADER_BUILD_TESTS)
if(NOT WIN32) if(NOT WIN32)
target_link_libraries(math-unittests pthread ${SWIFTSHADER_LIBS}) target_link_libraries(math-unittests pthread ${SWIFTSHADER_LIBS})
endif() endif()
# System unit tests
set(SYSTEM_UNITTESTS_LIST
${SOURCE_DIR}/System/Debug.cpp
${SOURCE_DIR}/System/Memory.cpp
${TESTS_DIR}/SystemUnitTests/main.cpp
${TESTS_DIR}/SystemUnitTests/unittests.cpp
)
if(LINUX OR ANDROID)
list(APPEND SYSTEM_UNITTESTS_LIST
${SOURCE_DIR}/System/Linux/MemFd.cpp
${SOURCE_DIR}/System/Linux/MemFd.hpp
)
endif()
set(SYSTEM_UNITTESTS_INCLUDE_DIR
${CMAKE_CURRENT_SOURCE_DIR}/src/
)
add_executable(system-unittests ${SYSTEM_UNITTESTS_LIST})
set_target_properties(system-unittests PROPERTIES
INCLUDE_DIRECTORIES "${SYSTEM_UNITTESTS_INCLUDE_DIR}"
FOLDER "Tests"
COMPILE_OPTIONS "${SWIFTSHADER_COMPILE_OPTIONS};${WARNINGS_AS_ERRORS}"
LINK_FLAGS "${SWIFTSHADER_LINK_FLAGS}"
)
target_link_libraries(system-unittests gtest gmock)
if(NOT WIN32)
target_link_libraries(system-unittests pthread ${SWIFTSHADER_LIBS})
endif()
endif(SWIFTSHADER_BUILD_TESTS) endif(SWIFTSHADER_BUILD_TESTS)
if(SWIFTSHADER_BUILD_BENCHMARKS) if(SWIFTSHADER_BUILD_BENCHMARKS)
......
// Copyright 2020 The SwiftShader Authors. All Rights Reserved.
//
// Licensed 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.
#include "gtest/gtest.h"
int main(int argc, char **argv)
{
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
...@@ -35,6 +35,7 @@ cd .. # Some tests must be run from project root ...@@ -35,6 +35,7 @@ cd .. # Some tests must be run from project root
build/ReactorUnitTests build/ReactorUnitTests
build/gles-unittests build/gles-unittests
build/system-unittests
build/vk-unittests build/vk-unittests
# Incrementally build and run rr::Print unit tests # Incrementally build and run rr::Print unit tests
......
...@@ -44,6 +44,9 @@ if !ERRORLEVEL! neq 0 exit /b !ERRORLEVEL! ...@@ -44,6 +44,9 @@ if !ERRORLEVEL! neq 0 exit /b !ERRORLEVEL!
build\Debug\gles-unittests.exe build\Debug\gles-unittests.exe
if !ERRORLEVEL! neq 0 exit /b !ERRORLEVEL! if !ERRORLEVEL! neq 0 exit /b !ERRORLEVEL!
build\Debug\system-unittests.exe
if !ERRORLEVEL! neq 0 exit /b !ERRORLEVEL!
build\Debug\vk-unittests.exe build\Debug\vk-unittests.exe
if !ERRORLEVEL! neq 0 exit /b !ERRORLEVEL! if !ERRORLEVEL! neq 0 exit /b !ERRORLEVEL!
......
...@@ -43,6 +43,7 @@ cd .. # Some tests must be run from project root ...@@ -43,6 +43,7 @@ cd .. # Some tests must be run from project root
build/ReactorUnitTests build/ReactorUnitTests
build/gles-unittests build/gles-unittests
build/system-unittests
build/vk-unittests build/vk-unittests
# Incrementally build and run rr::Print unit tests # Incrementally build and run rr::Print unit tests
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment