mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-04-28 13:28:01 +03:00
Add unit tests
Add unit tests
This commit is contained in:
parent
f435225940
commit
2b9a1b7b1b
8 changed files with 99 additions and 8 deletions
|
@ -52,6 +52,7 @@ cmake .. \
|
||||||
-DOpenGL_GL_PREFERENCE=LEGACY \
|
-DOpenGL_GL_PREFERENCE=LEGACY \
|
||||||
-DLLVM_DIR=/opt/llvm/lib/cmake/llvm \
|
-DLLVM_DIR=/opt/llvm/lib/cmake/llvm \
|
||||||
-DSTATIC_LINK_LLVM=ON \
|
-DSTATIC_LINK_LLVM=ON \
|
||||||
|
-DBUILD_RPCS3_TESTS=ON \
|
||||||
-G Ninja
|
-G Ninja
|
||||||
|
|
||||||
ninja; build_status=$?;
|
ninja; build_status=$?;
|
||||||
|
|
|
@ -58,7 +58,7 @@ env:
|
||||||
|
|
||||||
# linux_task:
|
# linux_task:
|
||||||
# container:
|
# container:
|
||||||
# image: rpcs3/rpcs3-ci-jammy:1.5
|
# image: rpcs3/rpcs3-ci-jammy:1.6
|
||||||
# cpu: 4
|
# cpu: 4
|
||||||
# memory: 16G
|
# memory: 16G
|
||||||
# env:
|
# env:
|
||||||
|
@ -134,7 +134,7 @@ freebsd_task:
|
||||||
# matrix:
|
# matrix:
|
||||||
# - name: Cirrus Linux AArch64 Clang
|
# - name: Cirrus Linux AArch64 Clang
|
||||||
# arm_container:
|
# arm_container:
|
||||||
# image: 'docker.io/rpcs3/rpcs3-ci-jammy-aarch64:1.5'
|
# image: 'docker.io/rpcs3/rpcs3-ci-jammy-aarch64:1.6'
|
||||||
# cpu: 8
|
# cpu: 8
|
||||||
# memory: 8G
|
# memory: 8G
|
||||||
# clang_script:
|
# clang_script:
|
||||||
|
|
12
.github/workflows/rpcs3.yml
vendored
12
.github/workflows/rpcs3.yml
vendored
|
@ -25,17 +25,17 @@ jobs:
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- os: ubuntu-24.04
|
- os: ubuntu-24.04
|
||||||
docker_img: "rpcs3/rpcs3-ci-jammy:1.5"
|
docker_img: "rpcs3/rpcs3-ci-jammy:1.6"
|
||||||
build_sh: "/rpcs3/.ci/build-linux.sh"
|
build_sh: "/rpcs3/.ci/build-linux.sh"
|
||||||
compiler: clang
|
compiler: clang
|
||||||
UPLOAD_COMMIT_HASH: d812f1254a1157c80fd402f94446310560f54e5f
|
UPLOAD_COMMIT_HASH: d812f1254a1157c80fd402f94446310560f54e5f
|
||||||
UPLOAD_REPO_FULL_NAME: "rpcs3/rpcs3-binaries-linux"
|
UPLOAD_REPO_FULL_NAME: "rpcs3/rpcs3-binaries-linux"
|
||||||
- os: ubuntu-24.04
|
- os: ubuntu-24.04
|
||||||
docker_img: "rpcs3/rpcs3-ci-jammy:1.5"
|
docker_img: "rpcs3/rpcs3-ci-jammy:1.6"
|
||||||
build_sh: "/rpcs3/.ci/build-linux.sh"
|
build_sh: "/rpcs3/.ci/build-linux.sh"
|
||||||
compiler: gcc
|
compiler: gcc
|
||||||
- os: ubuntu-24.04-arm
|
- os: ubuntu-24.04-arm
|
||||||
docker_img: "rpcs3/rpcs3-ci-jammy-aarch64:1.5"
|
docker_img: "rpcs3/rpcs3-ci-jammy-aarch64:1.6"
|
||||||
build_sh: "/rpcs3/.ci/build-linux-aarch64.sh"
|
build_sh: "/rpcs3/.ci/build-linux-aarch64.sh"
|
||||||
compiler: clang
|
compiler: clang
|
||||||
UPLOAD_COMMIT_HASH: a1d35836e8d45bfc6f63c26f0a3e5d46ef622fe1
|
UPLOAD_COMMIT_HASH: a1d35836e8d45bfc6f63c26f0a3e5d46ef622fe1
|
||||||
|
@ -77,6 +77,12 @@ jobs:
|
||||||
${{ matrix.docker_img }} \
|
${{ matrix.docker_img }} \
|
||||||
${{ matrix.build_sh }}
|
${{ matrix.build_sh }}
|
||||||
|
|
||||||
|
- name: Unit tests
|
||||||
|
if: |
|
||||||
|
github.event_name == 'pull_request'
|
||||||
|
working-directory: ${{github.workspace}}/build
|
||||||
|
run: ctest -j -VV -C Release
|
||||||
|
|
||||||
- name: Upload artifacts
|
- name: Upload artifacts
|
||||||
uses: actions/upload-artifact@main
|
uses: actions/upload-artifact@main
|
||||||
with:
|
with:
|
||||||
|
|
|
@ -32,6 +32,7 @@ option(USE_SYSTEM_CURL "Prefer system Curl instead of the prebuild one" ON)
|
||||||
option(USE_SYSTEM_OPENCV "Prefer system OpenCV instead of the builtin one" ON)
|
option(USE_SYSTEM_OPENCV "Prefer system OpenCV instead of the builtin one" ON)
|
||||||
option(HAS_MEMORY_BREAKPOINTS "Add support for memory breakpoints to the interpreter" OFF)
|
option(HAS_MEMORY_BREAKPOINTS "Add support for memory breakpoints to the interpreter" OFF)
|
||||||
option(USE_LTO "Use LTO for building" ON)
|
option(USE_LTO "Use LTO for building" ON)
|
||||||
|
option(BUILD_RPCS3_TESTS "Build RPCS3 unit tests." OFF)
|
||||||
|
|
||||||
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/buildfiles/cmake")
|
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/buildfiles/cmake")
|
||||||
|
|
||||||
|
|
|
@ -40,13 +40,13 @@ jobs:
|
||||||
# displayName: ccache
|
# displayName: ccache
|
||||||
|
|
||||||
# - bash: |
|
# - bash: |
|
||||||
# docker pull --quiet rpcs3/rpcs3-ci-jammy:1.5
|
# docker pull --quiet rpcs3/rpcs3-ci-jammy:1.6
|
||||||
# docker run \
|
# docker run \
|
||||||
# -v $(pwd):/rpcs3 \
|
# -v $(pwd):/rpcs3 \
|
||||||
# --env-file .ci/docker.env \
|
# --env-file .ci/docker.env \
|
||||||
# -v $CCACHE_DIR:/root/.ccache \
|
# -v $CCACHE_DIR:/root/.ccache \
|
||||||
# -v $BUILD_ARTIFACTSTAGINGDIRECTORY:/root/artifacts \
|
# -v $BUILD_ARTIFACTSTAGINGDIRECTORY:/root/artifacts \
|
||||||
# rpcs3/rpcs3-ci-jammy:1.5 \
|
# rpcs3/rpcs3-ci-jammy:1.6 \
|
||||||
# /rpcs3/.ci/build-linux.sh
|
# /rpcs3/.ci/build-linux.sh
|
||||||
# displayName: Docker setup and build
|
# displayName: Docker setup and build
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# Define GNU standard installation directories
|
# Define GNU standard installation directories
|
||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
|
|
||||||
# Generate git-version.h at build time.
|
# Generate git-version.h at build time.
|
||||||
|
@ -196,3 +196,60 @@ if (NOT ANDROID)
|
||||||
DESTINATION ${CMAKE_INSTALL_DATADIR}/rpcs3)
|
DESTINATION ${CMAKE_INSTALL_DATADIR}/rpcs3)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# Unit tests
|
||||||
|
if(BUILD_RPCS3_TESTS)
|
||||||
|
enable_testing()
|
||||||
|
find_package(GTest REQUIRED)
|
||||||
|
include(GoogleTest)
|
||||||
|
|
||||||
|
message(STATUS "Building unit tests...")
|
||||||
|
|
||||||
|
add_executable(tests
|
||||||
|
tests/test.cpp
|
||||||
|
tests/test_fmt.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(tests
|
||||||
|
PRIVATE
|
||||||
|
GTest::gtest
|
||||||
|
rpcs3_emu
|
||||||
|
rpcs3_ui
|
||||||
|
3rdparty::discordRPC
|
||||||
|
3rdparty::qt6
|
||||||
|
3rdparty::hidapi
|
||||||
|
3rdparty::libusb
|
||||||
|
3rdparty::wolfssl
|
||||||
|
3rdparty::libcurl
|
||||||
|
3rdparty::zlib
|
||||||
|
3rdparty::opencv
|
||||||
|
3rdparty::fusion
|
||||||
|
${ADDITIONAL_LIBS}
|
||||||
|
)
|
||||||
|
|
||||||
|
# Unix display manager
|
||||||
|
if(X11_FOUND)
|
||||||
|
target_link_libraries(tests PRIVATE X11::X11)
|
||||||
|
elseif(USE_VULKAN AND UNIX AND NOT WAYLAND_FOUND AND NOT APPLE AND NOT ANDROID)
|
||||||
|
# Wayland has been checked in 3rdparty/CMakeLists.txt already.
|
||||||
|
message(FATAL_ERROR "RPCS3 requires either X11 or Wayland (or both) for Vulkan.")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(UNIX)
|
||||||
|
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
|
||||||
|
find_package(Threads REQUIRED)
|
||||||
|
target_link_libraries(tests PRIVATE Threads::Threads)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(WIN32)
|
||||||
|
target_link_libraries(tests PRIVATE bcrypt ws2_32 Iphlpapi Winmm Psapi gdi32 setupapi pdh)
|
||||||
|
else()
|
||||||
|
target_link_libraries(tests PRIVATE ${CMAKE_DL_LIBS})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(USE_PRECOMPILED_HEADERS)
|
||||||
|
target_precompile_headers(tests PRIVATE stdafx.h)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
gtest_discover_tests(tests)
|
||||||
|
endif()
|
||||||
|
|
8
rpcs3/tests/test.cpp
Normal file
8
rpcs3/tests/test.cpp
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
int main(int argc, char** argv)
|
||||||
|
{
|
||||||
|
::testing::InitGoogleTest(&argc, argv);
|
||||||
|
|
||||||
|
return RUN_ALL_TESTS();
|
||||||
|
}
|
18
rpcs3/tests/test_fmt.cpp
Normal file
18
rpcs3/tests/test_fmt.cpp
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
#include <gtest/gtest.h>
|
||||||
|
#include "Utilities/StrUtil.h"
|
||||||
|
|
||||||
|
TEST(StrUtil, to_upper_to_lower)
|
||||||
|
{
|
||||||
|
const std::string lowercase = "abcdefghijklmnopqrstuvwxyzäüöß0123456789 .,-<#+";
|
||||||
|
const std::string uppercase = "ABCDEFGHIJKLMNOPQRSTUVWXYZäüöß0123456789 .,-<#+";
|
||||||
|
const std::string to_lower_res = fmt::to_lower(uppercase);
|
||||||
|
const std::string to_upper_res = fmt::to_upper(lowercase);
|
||||||
|
|
||||||
|
EXPECT_EQ(std::string(), fmt::to_lower(""));
|
||||||
|
EXPECT_EQ(lowercase, fmt::to_lower(lowercase));
|
||||||
|
EXPECT_EQ(lowercase, to_lower_res);
|
||||||
|
|
||||||
|
EXPECT_EQ(std::string(), fmt::to_upper(""));
|
||||||
|
EXPECT_EQ(uppercase, fmt::to_lower(uppercase));
|
||||||
|
EXPECT_EQ(uppercase, to_upper_res);
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue