mirror of
https://github.com/LizardByte/Sunshine.git
synced 2026-08-07 10:20:46 +00:00
chore: use lizardbyte-common in c++ (#5356)
Co-authored-by: Kishi <41839133+Kishi85@users.noreply.github.com>
This commit is contained in:
@@ -13,10 +13,6 @@
|
||||
[submodule "third-party/glad"]
|
||||
path = third-party/glad
|
||||
url = https://github.com/Dav1dde/glad.git
|
||||
[submodule "third-party/googletest"]
|
||||
path = third-party/googletest
|
||||
url = https://github.com/google/googletest.git
|
||||
branch = main
|
||||
[submodule "third-party/inputtino"]
|
||||
path = third-party/inputtino
|
||||
url = https://github.com/games-on-whales/inputtino.git
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
<div align="center">
|
||||
<img src="sunshine.png" alt="Sunshine icon"/>
|
||||
<img
|
||||
src="sunshine.svg"
|
||||
alt="Sunshine icon"
|
||||
width="256"
|
||||
/>
|
||||
<h1 align="center">Sunshine</h1>
|
||||
<h4 align="center">Self-hosted game stream host for Moonlight.</h4>
|
||||
</div>
|
||||
@@ -8,16 +12,15 @@
|
||||
<a href="https://github.com/LizardByte/Sunshine"><img src="https://img.shields.io/github/stars/lizardbyte/sunshine.svg?logo=github&style=for-the-badge" alt="GitHub stars"></a>
|
||||
<a href="https://github.com/LizardByte/Sunshine/releases/latest"><img src="https://img.shields.io/github/downloads/lizardbyte/sunshine/total.svg?style=for-the-badge&logo=github" alt="GitHub Releases"></a>
|
||||
<a href="https://hub.docker.com/r/lizardbyte/sunshine"><img src="https://img.shields.io/docker/pulls/lizardbyte/sunshine.svg?style=for-the-badge&logo=docker" alt="Docker"></a>
|
||||
<a href="https://github.com/LizardByte/Sunshine/pkgs/container/sunshine"><img src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fipitio.github.io%2Fbackage%2FLizardByte%2FSunshine%2Fsunshine.json&query=%24.downloads&label=ghcr%20pulls&style=for-the-badge&logo=github" alt="GHCR"></a>
|
||||
<a href="https://flathub.org/apps/dev.lizardbyte.app.Sunshine"><img src="https://img.shields.io/flathub/downloads/dev.lizardbyte.app.Sunshine?style=for-the-badge&logo=flathub" alt="Flathub installs"></a>
|
||||
<a href="https://flathub.org/apps/dev.lizardbyte.app.Sunshine"><img src="https://img.shields.io/flathub/v/dev.lizardbyte.app.Sunshine?style=for-the-badge&logo=flathub" alt="Flathub Version"></a>
|
||||
<a href="https://github.com/microsoft/winget-pkgs/tree/master/manifests/l/LizardByte/Sunshine"><img src="https://img.shields.io/winget/v/LizardByte.Sunshine?style=for-the-badge&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAHuSURBVFhH7ZfNTtRQGIYZiMDwN/IrCAqIhMSNKxcmymVwG+5dcDVsWHgDrtxwCYQVl+BChzDEwSnPY+eQ0sxoOz1mQuBNnpyvTdvz9jun5/SrjfxnJUkyQbMEz2ELduF1l0YUA3QyTrMAa2AnPtyOXsELeAYNyKtV2EC3k3lYgTOwg09ghy/BTp7CKBRV844BOpmmMV2+ySb4BmInG7AKY7AHH+EYqqhZo9PPBG/BVDlOizAD/XQFmnoPXzxRQX8M/CCYS48L6RIc4ygGHK9WGg9HZSZMUNRPVwNJGg5Hg2Qgqh4N3FsDsb6EmgYm07iwwvUxstdxJTwgmILf4CfZ6bb5OHANX8GN5x20IVxnG8ge94pt2xpwU3GnCwayF4Q2G2vgFLzHndFzQdk4q77nNfCdwL28qNyMtmEf3A1/QV5FjDiPWo5jrwf8TWZChTlgJvL4F9QL50/A43qVidTvLcuoM2wDQ1+IkgefgUpLcYwMVBqCKNJA2b0gKNocOIITOIef8C/F/CdMbh/GklynsSawKLHS8d9/B1x2LUqsfFyy3TMsWj5A1cLkotDbYO4JjWWZlZEGv8EbOIR1CAVN2eG8W5oNKgxaeC6DmTJjZs7ixUxpznLPLT+v4sXpoMLcLI3mzFSonDXIEI/M3QCIO4YuimBJ/gAAAABJRU5ErkJggg==" alt="Winget Version"></a>
|
||||
<a href="https://gurubase.io/g/sunshine"><img src="https://img.shields.io/badge/Gurubase-Ask%20Guru-ef1a1b?style=for-the-badge&logo=data:image/jpeg;base64,/9j/2wCEAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDIBCQkJDAsMGA0NGDIhHCEyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMv/AABEIABgAGAMBIgACEQEDEQH/xAGiAAABBQEBAQEBAQAAAAAAAAAAAQIDBAUGBwgJCgsQAAIBAwMCBAMFBQQEAAABfQECAwAEEQUSITFBBhNRYQcicRQygZGhCCNCscEVUtHwJDNicoIJChYXGBkaJSYnKCkqNDU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6g4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2drh4uPk5ebn6Onq8fLz9PX29/j5+gEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoLEQACAQIEBAMEBwUEBAABAncAAQIDEQQFITEGEkFRB2FxEyIygQgUQpGhscEJIzNS8BVictEKFiQ04SXxFxgZGiYnKCkqNTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqCg4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2dri4+Tl5ufo6ery8/T19vf4+fr/2gAMAwEAAhEDEQA/AOLqSO3mlilljido4QGkYDIQEgAn05IH41seFo7aS+uRKlrJci2Y2cd2QImlyOGyQPu7sA8ZxXapAlvpThbPRkv7nTQWhDoIZZRc/XaSAOmcZGOnFfP06XMr3P17F5iqE+Tl1uuvf9Lde55dRW74pit4r61EcdtFdG2U3kVqQY0lyeBgkD5duQOASawqykuV2O6jV9rTU0rXLNjf3Om3QubSXy5QCudoYEEYIIOQR7GnahqV3qk6zXk3mOqhFAUKqqOyqAAByeAKqUUXdrFezhz89lfv1+8KKKKRZ//Z" alt="Gurubase"></a>
|
||||
<a href="https://github.com/LizardByte/Sunshine/pkgs/container/sunshine"><img src="https://img.shields.io/badge/dynamic/json.svg?url=https%3A%2F%2Fipitio.github.io%2Fbackage%2FLizardByte%2FSunshine%2Fsunshine.json&query=%24.downloads&label=ghcr%20pulls&style=for-the-badge&logo=github" alt="GHCR"></a>
|
||||
<a href="https://flathub.org/apps/dev.lizardbyte.app.Sunshine"><img src="https://img.shields.io/flathub/downloads/dev.lizardbyte.app.Sunshine.svg?style=for-the-badge&logo=flathub" alt="Flathub installs"></a>
|
||||
<a href="https://flathub.org/apps/dev.lizardbyte.app.Sunshine"><img src="https://img.shields.io/flathub/v/dev.lizardbyte.app.Sunshine.svg?style=for-the-badge&logo=flathub" alt="Flathub Version"></a>
|
||||
<a href="https://github.com/microsoft/winget-pkgs/tree/master/manifests/l/LizardByte/Sunshine"><img src="https://img.shields.io/winget/v/LizardByte.Sunshine.svg?style=for-the-badge&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAHuSURBVFhH7ZfNTtRQGIYZiMDwN/IrCAqIhMSNKxcmymVwG+5dcDVsWHgDrtxwCYQVl+BChzDEwSnPY+eQ0sxoOz1mQuBNnpyvTdvz9jun5/SrjfxnJUkyQbMEz2ELduF1l0YUA3QyTrMAa2AnPtyOXsELeAYNyKtV2EC3k3lYgTOwg09ghy/BTp7CKBRV844BOpmmMV2+ySb4BmInG7AKY7AHH+EYqqhZo9PPBG/BVDlOizAD/XQFmnoPXzxRQX8M/CCYS48L6RIc4ygGHK9WGg9HZSZMUNRPVwNJGg5Hg2Qgqh4N3FsDsb6EmgYm07iwwvUxstdxJTwgmILf4CfZ6bb5OHANX8GN5x20IVxnG8ge94pt2xpwU3GnCwayF4Q2G2vgFLzHndFzQdk4q77nNfCdwL28qNyMtmEf3A1/QV5FjDiPWo5jrwf8TWZChTlgJvL4F9QL50/A43qVidTvLcuoM2wDQ1+IkgefgUpLcYwMVBqCKNJA2b0gKNocOIITOIef8C/F/CdMbh/GklynsSawKLHS8d9/B1x2LUqsfFyy3TMsWj5A1cLkotDbYO4JjWWZlZEGv8EbOIR1CAVN2eG8W5oNKgxaeC6DmTJjZs7ixUxpznLPLT+v4sXpoMLcLI3mzFSonDXIEI/M3QCIO4YuimBJ/gAAAABJRU5ErkJggg==" alt="Winget Version"></a>
|
||||
<a href="https://gurubase.io/g/sunshine"><img src="https://img.shields.io/badge/Gurubase-Ask%20Guru-ef1a1b.svg?style=for-the-badge&logo=data:image/jpeg;base64,/9j/2wCEAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDIBCQkJDAsMGA0NGDIhHCEyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMv/AABEIABgAGAMBIgACEQEDEQH/xAGiAAABBQEBAQEBAQAAAAAAAAAAAQIDBAUGBwgJCgsQAAIBAwMCBAMFBQQEAAABfQECAwAEEQUSITFBBhNRYQcicRQygZGhCCNCscEVUtHwJDNicoIJChYXGBkaJSYnKCkqNDU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6g4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2drh4uPk5ebn6Onq8fLz9PX29/j5+gEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoLEQACAQIEBAMEBwUEBAABAncAAQIDEQQFITEGEkFRB2FxEyIygQgUQpGhscEJIzNS8BVictEKFiQ04SXxFxgZGiYnKCkqNTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqCg4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2dri4+Tl5ufo6ery8/T19vf4+fr/2gAMAwEAAhEDEQA/AOLqSO3mlilljido4QGkYDIQEgAn05IH41seFo7aS+uRKlrJci2Y2cd2QImlyOGyQPu7sA8ZxXapAlvpThbPRkv7nTQWhDoIZZRc/XaSAOmcZGOnFfP06XMr3P17F5iqE+Tl1uuvf9Lde55dRW74pit4r61EcdtFdG2U3kVqQY0lyeBgkD5duQOASawqykuV2O6jV9rTU0rXLNjf3Om3QubSXy5QCudoYEEYIIOQR7GnahqV3qk6zXk3mOqhFAUKqqOyqAAByeAKqUUXdrFezhz89lfv1+8KKKKRZ//Z" alt="Gurubase"></a>
|
||||
<a href="https://github.com/LizardByte/Sunshine/actions/workflows/ci.yml?query=branch%3Amaster"><img src="https://img.shields.io/github/actions/workflow/status/lizardbyte/sunshine/ci.yml.svg?branch=master&label=CI%20build&logo=github&style=for-the-badge" alt="GitHub Workflow Status (CI)"></a>
|
||||
<a href="https://github.com/LizardByte/Sunshine/actions/workflows/localize.yml?query=branch%3Amaster"><img src="https://img.shields.io/github/actions/workflow/status/lizardbyte/sunshine/localize.yml.svg?branch=master&label=localize%20build&logo=github&style=for-the-badge" alt="GitHub Workflow Status (localize)"></a>
|
||||
<a href="https://docs.lizardbyte.dev/projects/sunshine"><img src="https://img.shields.io/readthedocs/sunshinestream.svg?label=Docs&style=for-the-badge&logo=readthedocs" alt="Read the Docs"></a>
|
||||
<a href="https://codecov.io/gh/LizardByte/Sunshine"><img src="https://img.shields.io/codecov/c/gh/LizardByte/Sunshine?token=SMGXQ5NVMJ&style=for-the-badge&logo=codecov&label=codecov" alt="Codecov"></a>
|
||||
<a href="https://sonarcloud.io/project/overview?id=LizardByte_Sunshine"><img src="https://img.shields.io/sonar/quality_gate/LizardByte_Sunshine?server=https%3A%2F%2Fsonarcloud.io&style=for-the-badge&logo=sonarqubecloud&label=sonarcloud" alt="SonarCloud"></a>
|
||||
<a href="https://codecov.io/gh/LizardByte/Sunshine"><img src="https://img.shields.io/endpoint.svg?url=https%3A%2F%2Fapp.lizardbyte.dev%2Fdashboard%2Fshields%2Fcodecov%2FSunshine.json&style=for-the-badge&logo=codecov" alt="Codecov"></a>
|
||||
<a href="https://sonarcloud.io/project/overview?id=LizardByte_Sunshine"><img src="https://img.shields.io/sonar/quality_gate/LizardByte_Sunshine.svg?server=https%3A%2F%2Fsonarcloud.io&style=for-the-badge&logo=sonarqubecloud&label=sonarcloud" alt="SonarCloud"></a>
|
||||
</div>
|
||||
|
||||
## ℹ️ About
|
||||
|
||||
@@ -150,6 +150,7 @@ list(APPEND SUNSHINE_EXTERNAL_LIBRARIES
|
||||
${CMAKE_THREAD_LIBS_INIT}
|
||||
enet
|
||||
libdisplaydevice::display_device
|
||||
lizardbyte::common
|
||||
nlohmann_json::nlohmann_json
|
||||
${Opus_LIBRARY}
|
||||
${FFMPEG_LIBRARIES}
|
||||
|
||||
@@ -16,6 +16,11 @@ add_subdirectory("${CMAKE_SOURCE_DIR}/third-party/moonlight-common-c/enet")
|
||||
# web server
|
||||
add_subdirectory("${CMAKE_SOURCE_DIR}/third-party/Simple-Web-Server")
|
||||
|
||||
# lizardbyte common helpers
|
||||
set(LIZARDBYTE_COMMON_BUILD_TEST_SUPPORT ${BUILD_TESTS}
|
||||
CACHE BOOL "Build lizardbyte-common GoogleTest support helpers" FORCE)
|
||||
add_subdirectory("${CMAKE_SOURCE_DIR}/third-party/lizardbyte-common")
|
||||
|
||||
# libdisplaydevice
|
||||
add_subdirectory("${CMAKE_SOURCE_DIR}/third-party/libdisplaydevice")
|
||||
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ DOCSET_BUNDLE_ID = dev.lizardbyte.Sunshine
|
||||
DOCSET_PUBLISHER_ID = dev.lizardbyte.Sunshine.documentation
|
||||
PROJECT_BRIEF = "Self-hosted game stream host for Moonlight."
|
||||
PROJECT_ICON = ../sunshine.ico
|
||||
PROJECT_LOGO = ../sunshine.png
|
||||
PROJECT_LOGO = ../sunshine.svg
|
||||
PROJECT_NAME = Sunshine
|
||||
|
||||
# project specific settings
|
||||
|
||||
@@ -953,21 +953,6 @@ namespace platf {
|
||||
|
||||
void restart();
|
||||
|
||||
/**
|
||||
* @brief Set an environment variable.
|
||||
* @param name The name of the environment variable.
|
||||
* @param value The value to set the environment variable to.
|
||||
* @return 0 on success, non-zero on failure.
|
||||
*/
|
||||
int set_env(const std::string &name, const std::string &value);
|
||||
|
||||
/**
|
||||
* @brief Unset an environment variable.
|
||||
* @param name The name of the environment variable.
|
||||
* @return 0 on success, non-zero on failure.
|
||||
*/
|
||||
int unset_env(const std::string &name);
|
||||
|
||||
/**
|
||||
* @brief Platform buffer pointer and size for batched socket sends.
|
||||
*/
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
* @file src/platform/linux/input/inputtino_seat.cpp
|
||||
* @brief Implementation for multi-seat naming (udev-only).
|
||||
*/
|
||||
// standard includes
|
||||
#include <cstdlib>
|
||||
// lib includes
|
||||
#include <lizardbyte/common/env.h>
|
||||
|
||||
// local includes
|
||||
#include "inputtino_seat.h"
|
||||
@@ -11,10 +11,8 @@
|
||||
namespace platf::inputtino_seat {
|
||||
|
||||
std::string get_target_seat() {
|
||||
if (const char *seat = std::getenv("XDG_SEAT")) {
|
||||
if (seat[0] != '\0') {
|
||||
return seat;
|
||||
}
|
||||
if (std::string seat; lizardbyte::common::get_env("XDG_SEAT", seat) && !seat.empty()) {
|
||||
return seat;
|
||||
}
|
||||
|
||||
return {};
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include <thread>
|
||||
|
||||
// lib includes
|
||||
#include <lizardbyte/common/env.h>
|
||||
#include <pipewire/pipewire.h>
|
||||
#include <poll.h>
|
||||
#include <unistd.h>
|
||||
@@ -55,7 +56,7 @@ namespace kwin {
|
||||
* @return True when KWin reports that the permission system is disabled.
|
||||
*/
|
||||
static bool is_permission_system_deactivated() {
|
||||
return getenvstr("KWIN_WAYLAND_NO_PERMISSION_CHECKS") == "1";
|
||||
return lizardbyte::common::get_env("KWIN_WAYLAND_NO_PERMISSION_CHECKS") == "1";
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -160,17 +161,9 @@ namespace kwin {
|
||||
static inline bool initialized = false;
|
||||
static inline bool create_file = true;
|
||||
|
||||
static std::string getenvstr(std::string const &key) {
|
||||
char const *val = std::getenv(key.c_str());
|
||||
if (!val) {
|
||||
return "";
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
static std::filesystem::path get_home_dir() {
|
||||
// Check HOME environment variable
|
||||
if (std::string homedir = getenvstr("HOME"); !homedir.empty()) {
|
||||
if (std::string homedir = lizardbyte::common::get_env("HOME"); !homedir.empty()) {
|
||||
return homedir;
|
||||
}
|
||||
// Fall back to home directory from NSS passwd
|
||||
@@ -182,7 +175,7 @@ namespace kwin {
|
||||
// Follow the XDG base directory specification for user data home:
|
||||
// https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
|
||||
std::filesystem::path xdg_data_home;
|
||||
if (std::string dir = getenvstr("XDG_DATA_HOME"); !dir.empty()) {
|
||||
if (std::string dir = lizardbyte::common::get_env("XDG_DATA_HOME"); !dir.empty()) {
|
||||
xdg_data_home = std::filesystem::path(dir);
|
||||
} else {
|
||||
const auto homedir = get_home_dir();
|
||||
@@ -222,7 +215,7 @@ namespace kwin {
|
||||
static bool check_kwin_system_permissions(const std::string_view &filenameprefix, const std::string_view &executablepath) {
|
||||
// Find data dirs to check from XDG_DATA_DIRS
|
||||
std::vector<std::string> xdg_data_dirs;
|
||||
if (const std::string e = getenvstr("XDG_DATA_DIRS"); !e.empty()) {
|
||||
if (const std::string e = lizardbyte::common::get_env("XDG_DATA_DIRS"); !e.empty()) {
|
||||
std::stringstream ss(e);
|
||||
std::string item;
|
||||
|
||||
@@ -322,13 +315,13 @@ namespace kwin {
|
||||
screencast_permission_helper_t::setup();
|
||||
}
|
||||
|
||||
const char *wl_name = std::getenv("WAYLAND_DISPLAY");
|
||||
if (!wl_name) {
|
||||
std::string wl_name;
|
||||
if (!lizardbyte::common::get_env("WAYLAND_DISPLAY", wl_name)) {
|
||||
BOOST_LOG(error) << "[kwingrab] WAYLAND_DISPLAY not set"sv;
|
||||
return -1;
|
||||
}
|
||||
|
||||
wl_display = wl_display_connect(wl_name);
|
||||
wl_display = wl_display_connect(wl_name.c_str());
|
||||
if (!wl_display) {
|
||||
BOOST_LOG(error) << "[kwingrab] cannot connect to Wayland display: "sv << wl_name;
|
||||
return -1;
|
||||
|
||||
+15
-53
@@ -44,6 +44,7 @@
|
||||
#include <boost/asio/ip/host_name.hpp>
|
||||
#include <boost/process/v1.hpp>
|
||||
#include <fcntl.h>
|
||||
#include <lizardbyte/common/env.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef SUNSHINE_BUILD_DRM
|
||||
@@ -179,38 +180,35 @@ namespace platf {
|
||||
std::call_once(migration_flag, []() {
|
||||
bool found = false;
|
||||
bool migrate_config = true;
|
||||
const char *dir;
|
||||
const char *homedir;
|
||||
const char *migrate_envvar;
|
||||
fs::path homedir {lizardbyte::common::get_env("HOME")};
|
||||
|
||||
// Get the home directory
|
||||
if ((homedir = getenv("HOME")) == nullptr || strlen(homedir) == 0) {
|
||||
if (homedir.empty()) {
|
||||
// If HOME is empty or not set, use the current user's home directory
|
||||
homedir = getpwuid(geteuid())->pw_dir;
|
||||
}
|
||||
|
||||
// May be set if running under a systemd service with the ConfigurationDirectory= option set.
|
||||
if ((dir = getenv("CONFIGURATION_DIRECTORY")) != nullptr && strlen(dir) > 0) {
|
||||
if (std::string dir; lizardbyte::common::get_env("CONFIGURATION_DIRECTORY", dir) && !dir.empty()) {
|
||||
found = true;
|
||||
config_path = fs::path(dir) / "sunshine"sv;
|
||||
}
|
||||
// Otherwise, follow the XDG base directory specification:
|
||||
// https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
|
||||
if (!found && (dir = getenv("XDG_CONFIG_HOME")) != nullptr && strlen(dir) > 0) {
|
||||
if (std::string dir; !found && lizardbyte::common::get_env("XDG_CONFIG_HOME", dir) && !dir.empty()) {
|
||||
found = true;
|
||||
config_path = fs::path(dir) / "sunshine"sv;
|
||||
}
|
||||
// As a last resort, use the home directory
|
||||
if (!found) {
|
||||
migrate_config = false;
|
||||
config_path = fs::path(homedir) / ".config/sunshine"sv;
|
||||
config_path = homedir / ".config" / "sunshine";
|
||||
}
|
||||
|
||||
// migrate from the old config location if necessary
|
||||
migrate_envvar = getenv("SUNSHINE_MIGRATE_CONFIG");
|
||||
if (migrate_config && found && migrate_envvar && strcmp(migrate_envvar, "1") == 0) {
|
||||
if (std::string migrate_envvar; migrate_config && found && lizardbyte::common::get_env("SUNSHINE_MIGRATE_CONFIG", migrate_envvar) && migrate_envvar == "1") {
|
||||
std::error_code ec;
|
||||
fs::path old_config_path = fs::path(homedir) / ".config/sunshine"sv;
|
||||
fs::path old_config_path = homedir / ".config" / "sunshine";
|
||||
if (old_config_path != config_path && fs::exists(old_config_path, ec)) {
|
||||
if (!fs::exists(config_path, ec)) {
|
||||
std::cout << "Migrating config from "sv << old_config_path << " to "sv << config_path << std::endl;
|
||||
@@ -365,7 +363,7 @@ namespace platf {
|
||||
*/
|
||||
void open_url(const std::string &url) {
|
||||
// set working dir to user home directory
|
||||
auto working_dir = boost::filesystem::path(std::getenv("HOME"));
|
||||
auto working_dir = boost::filesystem::path(lizardbyte::common::get_env("HOME"));
|
||||
std::string cmd = R"(xdg-open ")" + url + R"(")";
|
||||
|
||||
boost::process::v1::environment _env = boost::this_process::environment();
|
||||
@@ -506,42 +504,6 @@ namespace platf {
|
||||
lifetime::exit_sunshine(0, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Read an environment variable as an optional string.
|
||||
*
|
||||
* @param name Human-readable name to assign.
|
||||
* @return Environment variable value, or an empty string when unset.
|
||||
*/
|
||||
std::string get_env(const std::string &name) {
|
||||
if (const auto value = getenv(name.c_str()); value != nullptr) {
|
||||
return value;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
int set_env(const std::string &name, const std::string &value) {
|
||||
return setenv(name.c_str(), value.c_str(), 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Append a value to a separator-delimited environment variable.
|
||||
*
|
||||
* @param name Human-readable name to assign.
|
||||
* @param value Entry to add when it is not already present.
|
||||
* @param separator Character used to join or split the value.
|
||||
* @return Result from updating the environment variable.
|
||||
*/
|
||||
int append_env(const std::string &name, const std::string &value, const std::string &separator) {
|
||||
if (const std::string old_value = get_env(name); !old_value.contains(value)) {
|
||||
return set_env(name, old_value.empty() ? value : old_value + separator + value);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int unset_env(const std::string &name) {
|
||||
return unsetenv(name.c_str());
|
||||
}
|
||||
|
||||
bool request_process_group_exit(std::uintptr_t native_handle) {
|
||||
if (kill(-((pid_t) native_handle), SIGTERM) == 0 || errno == ESRCH) {
|
||||
BOOST_LOG(debug) << "Successfully sent SIGTERM to process group: "sv << native_handle;
|
||||
@@ -1267,25 +1229,25 @@ namespace platf {
|
||||
std::unique_ptr<deinit_t> init() {
|
||||
// enable low latency mode for AMD
|
||||
// https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30039
|
||||
set_env("AMD_DEBUG", "lowlatencyenc");
|
||||
lizardbyte::common::set_env("AMD_DEBUG", "lowlatencyenc");
|
||||
|
||||
// enable Vulkan video extensions for AMD RADV
|
||||
set_env("RADV_PERFTEST", "video_encode");
|
||||
lizardbyte::common::set_env("RADV_PERFTEST", "video_encode");
|
||||
// Above is deprecated on Mesa 26.1+ and replaced by (keep both to ensure best compatibility):
|
||||
append_env("RADV_EXPERIMENTAL", "video_encode", ",");
|
||||
lizardbyte::common::append_env("RADV_EXPERIMENTAL", "video_encode", ",");
|
||||
|
||||
// These are allowed to fail.
|
||||
gbm::init();
|
||||
|
||||
window_system = window_system_e::NONE;
|
||||
#ifdef SUNSHINE_BUILD_WAYLAND
|
||||
if (std::getenv("WAYLAND_DISPLAY")) {
|
||||
if (std::string v; lizardbyte::common::get_env("WAYLAND_DISPLAY", v)) {
|
||||
window_system = window_system_e::WAYLAND;
|
||||
}
|
||||
#endif
|
||||
#if defined(SUNSHINE_BUILD_X11) || defined(SUNSHINE_BUILD_CUDA)
|
||||
if (std::getenv("DISPLAY") && window_system != window_system_e::WAYLAND) {
|
||||
if (std::getenv("WAYLAND_DISPLAY")) {
|
||||
if (std::string v; lizardbyte::common::get_env("DISPLAY", v) && window_system != window_system_e::WAYLAND) {
|
||||
if (lizardbyte::common::get_env("WAYLAND_DISPLAY", v)) {
|
||||
BOOST_LOG(warning) << "Wayland detected, yet sunshine will use X11 for screencasting, screencasting will only work on XWayland applications"sv;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,9 +2,6 @@
|
||||
* @file src/platform/linux/wayland.cpp
|
||||
* @brief Definitions for Wayland capture.
|
||||
*/
|
||||
// standard includes
|
||||
#include <cstdlib>
|
||||
|
||||
// platform includes
|
||||
#include <drm_fourcc.h>
|
||||
#include <fcntl.h>
|
||||
@@ -15,6 +12,9 @@
|
||||
#include <wayland-util.h>
|
||||
#include <xf86drm.h>
|
||||
|
||||
// lib includes
|
||||
#include <lizardbyte/common/env.h>
|
||||
|
||||
// local includes
|
||||
#include "graphics.h"
|
||||
#include "src/logging.h"
|
||||
@@ -53,8 +53,11 @@ namespace wl {
|
||||
};
|
||||
|
||||
int display_t::init(const char *display_name) {
|
||||
std::string env_display_name;
|
||||
if (!display_name) {
|
||||
display_name = std::getenv("WAYLAND_DISPLAY");
|
||||
if (lizardbyte::common::get_env("WAYLAND_DISPLAY", env_display_name)) {
|
||||
display_name = env_display_name.c_str();
|
||||
}
|
||||
}
|
||||
|
||||
if (!display_name) {
|
||||
|
||||
@@ -296,14 +296,6 @@ namespace platf {
|
||||
lifetime::exit_sunshine(0, true);
|
||||
}
|
||||
|
||||
int set_env(const std::string &name, const std::string &value) {
|
||||
return setenv(name.c_str(), value.c_str(), 1);
|
||||
}
|
||||
|
||||
int unset_env(const std::string &name) {
|
||||
return unsetenv(name.c_str());
|
||||
}
|
||||
|
||||
bool request_process_group_exit(std::uintptr_t native_handle) {
|
||||
if (killpg((pid_t) native_handle, SIGTERM) == 0 || errno == ESRCH) {
|
||||
BOOST_LOG(debug) << "Successfully sent SIGTERM to process group: "sv << native_handle;
|
||||
|
||||
@@ -520,8 +520,7 @@ namespace platf::dxgi {
|
||||
height = desc.DesktopCoordinates.bottom - offset_y;
|
||||
|
||||
display_rotation = desc.Rotation;
|
||||
if (display_rotation == DXGI_MODE_ROTATION_ROTATE90 ||
|
||||
display_rotation == DXGI_MODE_ROTATION_ROTATE270) {
|
||||
if (display_rotation == DXGI_MODE_ROTATION_ROTATE90 || display_rotation == DXGI_MODE_ROTATION_ROTATE270) {
|
||||
width_before_rotation = height;
|
||||
height_before_rotation = width;
|
||||
} else {
|
||||
@@ -621,8 +620,7 @@ namespace platf::dxgi {
|
||||
HANDLE token;
|
||||
LUID val;
|
||||
|
||||
if (OpenProcessToken(GetCurrentProcess(), flags, &token) &&
|
||||
!!LookupPrivilegeValue(nullptr, SE_INC_BASE_PRIORITY_NAME, &val)) {
|
||||
if (OpenProcessToken(GetCurrentProcess(), flags, &token) && !!LookupPrivilegeValue(nullptr, SE_INC_BASE_PRIORITY_NAME, &val)) {
|
||||
tp.PrivilegeCount = 1;
|
||||
tp.Privileges[0].Luid = val;
|
||||
tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
|
||||
|
||||
@@ -1324,14 +1324,6 @@ namespace platf {
|
||||
lifetime::exit_sunshine(0, true);
|
||||
}
|
||||
|
||||
int set_env(const std::string &name, const std::string &value) {
|
||||
return _putenv_s(name.c_str(), value.c_str());
|
||||
}
|
||||
|
||||
int unset_env(const std::string &name) {
|
||||
return _putenv_s(name.c_str(), "");
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Stores state while enumerating top-level Windows windows.
|
||||
*/
|
||||
|
||||
@@ -15,10 +15,12 @@ include_directories("${CMAKE_SOURCE_DIR}")
|
||||
enable_testing()
|
||||
|
||||
# Add GoogleTest directory to the project
|
||||
set(GTEST_SOURCE_DIR "${CMAKE_SOURCE_DIR}/third-party/googletest")
|
||||
set(GTEST_SOURCE_DIR "${CMAKE_SOURCE_DIR}/third-party/lizardbyte-common/third-party/googletest")
|
||||
set(INSTALL_GTEST OFF)
|
||||
set(INSTALL_GMOCK OFF)
|
||||
add_subdirectory("${GTEST_SOURCE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/googletest")
|
||||
if(NOT TARGET gtest)
|
||||
add_subdirectory("${GTEST_SOURCE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/googletest")
|
||||
endif()
|
||||
include_directories("${GTEST_SOURCE_DIR}/googletest/include" "${GTEST_SOURCE_DIR}")
|
||||
|
||||
# coverage
|
||||
@@ -167,7 +169,7 @@ add_dependencies(${PROJECT_NAME} sync_locale_files)
|
||||
# Build the list of libraries to link
|
||||
set(TEST_LINK_LIBRARIES
|
||||
${SUNSHINE_EXTERNAL_LIBRARIES}
|
||||
gtest
|
||||
lizardbyte::test_support
|
||||
${PLATFORM_LIBRARIES}
|
||||
)
|
||||
|
||||
|
||||
@@ -20,9 +20,10 @@
|
||||
// local includes
|
||||
#include "src/file_handler.h"
|
||||
|
||||
class ConfigConsistencyTest: public ::testing::Test {
|
||||
class ConfigConsistencyTest: public BaseTest {
|
||||
protected:
|
||||
void SetUp() override {
|
||||
BaseTest::SetUp();
|
||||
// Define the expected mapping between documentation sections and UI tabs
|
||||
expectedDocToTabMapping = {
|
||||
{"General", "general"},
|
||||
|
||||
@@ -37,9 +37,10 @@ struct ExternalCommandTestData {
|
||||
xfail_reason(std::move(xfail_rsn)) {}
|
||||
};
|
||||
|
||||
class ExternalCommandTest: public ::testing::TestWithParam<ExternalCommandTestData> {
|
||||
class ExternalCommandTest: public BaseTest, public ::testing::WithParamInterface<ExternalCommandTestData> {
|
||||
protected:
|
||||
void SetUp() override {
|
||||
BaseTest::SetUp();
|
||||
if constexpr (IS_WINDOWS) {
|
||||
current_platform = "windows";
|
||||
} else if constexpr (IS_MACOS) {
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
class LocaleConsistencyTest: public ::testing::Test {
|
||||
class LocaleConsistencyTest: public BaseTest {
|
||||
protected:
|
||||
// Extract locale options from config.cpp
|
||||
static std::set<std::string, std::less<>> extractConfigCppLocales() {
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#pragma GCC diagnostic ignored "-Wstringop-overflow"
|
||||
#endif
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <lizardbyte/common/testing.h>
|
||||
#include <src/globals.h>
|
||||
#include <src/logging.h>
|
||||
#include <src/platform/common.h>
|
||||
@@ -146,7 +146,7 @@ namespace test_utils {
|
||||
#define IS_FREEBSD false
|
||||
#endif
|
||||
|
||||
struct PlatformTestSuite: testing::Test {
|
||||
struct PlatformTestSuite: BaseTest {
|
||||
static void SetUpTestSuite() {
|
||||
ASSERT_FALSE(platf_deinit);
|
||||
BOOST_LOG(tests) << "Setting up platform test suite";
|
||||
|
||||
+10
-31
@@ -5,7 +5,7 @@
|
||||
#pragma once
|
||||
#include "tests_common.h"
|
||||
|
||||
struct SunshineEventListener: testing::EmptyTestEventListener {
|
||||
struct SunshineEventListener: BufferedTestEventListener {
|
||||
SunshineEventListener() {
|
||||
sink = boost::make_shared<sink_t>();
|
||||
sink_buffer = boost::make_shared<std::stringstream>();
|
||||
@@ -14,51 +14,30 @@ struct SunshineEventListener: testing::EmptyTestEventListener {
|
||||
}
|
||||
|
||||
void OnTestProgramStart(const testing::UnitTest &unit_test) override {
|
||||
static_cast<void>(unit_test);
|
||||
boost::log::core::get()->add_sink(sink);
|
||||
}
|
||||
|
||||
void OnTestProgramEnd(const testing::UnitTest &unit_test) override {
|
||||
static_cast<void>(unit_test);
|
||||
boost::log::core::get()->remove_sink(sink);
|
||||
}
|
||||
|
||||
void OnTestStart(const testing::TestInfo &test_info) override {
|
||||
BOOST_LOG(tests) << "From " << test_info.file() << ":" << test_info.line();
|
||||
BOOST_LOG(tests) << " " << test_info.test_suite_name() << "/" << test_info.name() << " started";
|
||||
protected:
|
||||
void logTestEvent(const std::string &message) override {
|
||||
BOOST_LOG(tests) << message;
|
||||
}
|
||||
|
||||
void OnTestPartResult(const testing::TestPartResult &test_part_result) override {
|
||||
std::string file = test_part_result.file_name();
|
||||
BOOST_LOG(tests) << "At " << file << ":" << test_part_result.line_number();
|
||||
|
||||
auto result_text = test_part_result.passed() ? "Success" :
|
||||
test_part_result.nonfatally_failed() ? "Non-fatal failure" :
|
||||
test_part_result.fatally_failed() ? "Failure" :
|
||||
"Skip";
|
||||
|
||||
std::string summary = test_part_result.summary();
|
||||
std::string message = test_part_result.message();
|
||||
BOOST_LOG(tests) << " " << result_text << ": " << summary;
|
||||
if (message != summary) {
|
||||
BOOST_LOG(tests) << " " << message;
|
||||
}
|
||||
[[nodiscard]] std::string bufferedTestOutput() const override {
|
||||
return sink_buffer->str();
|
||||
}
|
||||
|
||||
void OnTestEnd(const testing::TestInfo &test_info) override {
|
||||
auto &result = *test_info.result();
|
||||
|
||||
auto result_text = result.Passed() ? "passed" :
|
||||
result.Skipped() ? "skipped" :
|
||||
"failed";
|
||||
BOOST_LOG(tests) << test_info.test_suite_name() << "/" << test_info.name() << " " << result_text;
|
||||
|
||||
if (result.Failed()) {
|
||||
std::cout << sink_buffer->str();
|
||||
}
|
||||
|
||||
void clearBufferedTestOutput() override {
|
||||
sink_buffer->str("");
|
||||
sink_buffer->clear();
|
||||
}
|
||||
|
||||
private:
|
||||
using sink_t = boost::log::sinks::synchronous_sink<boost::log::sinks::text_ostream_backend>;
|
||||
boost::shared_ptr<sink_t> sink;
|
||||
boost::shared_ptr<std::stringstream> sink_buffer;
|
||||
|
||||
@@ -7,48 +7,6 @@
|
||||
#include <boost/asio/ip/host_name.hpp>
|
||||
#include <src/platform/common.h>
|
||||
|
||||
struct SetEnvTest: ::testing::TestWithParam<std::tuple<std::string, std::string, int>> {
|
||||
protected:
|
||||
void TearDown() override {
|
||||
// Clean up environment variable after each test
|
||||
const auto &[name, value, expected] = GetParam();
|
||||
platf::unset_env(name);
|
||||
}
|
||||
};
|
||||
|
||||
TEST_P(SetEnvTest, SetEnvironmentVariableTests) {
|
||||
const auto &[name, value, expected] = GetParam();
|
||||
platf::set_env(name, value);
|
||||
|
||||
const char *env_value = std::getenv(name.c_str());
|
||||
if (expected == 0 && !value.empty()) {
|
||||
ASSERT_NE(env_value, nullptr);
|
||||
ASSERT_EQ(std::string(env_value), value);
|
||||
} else {
|
||||
ASSERT_EQ(env_value, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_P(SetEnvTest, UnsetEnvironmentVariableTests) {
|
||||
const auto &[name, value, expected] = GetParam();
|
||||
platf::unset_env(name);
|
||||
|
||||
const char *env_value = std::getenv(name.c_str());
|
||||
if (expected == 0) {
|
||||
ASSERT_EQ(env_value, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
SetEnvTests,
|
||||
SetEnvTest,
|
||||
::testing::Values(
|
||||
std::make_tuple("SUNSHINE_UNIT_TEST_ENV_VAR", "test_value_0", 0),
|
||||
std::make_tuple("SUNSHINE_UNIT_TEST_ENV_VAR", "test_value_1", 0),
|
||||
std::make_tuple("", "test_value", -1)
|
||||
)
|
||||
);
|
||||
|
||||
TEST(HostnameTests, TestAsioEquality) {
|
||||
// These should be equivalent on all platforms for ASCII hostnames
|
||||
ASSERT_EQ(platf::get_host_name(), boost::asio::ip::host_name());
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
/**
|
||||
* @brief Test fixture for utf_utils namespace functions
|
||||
*/
|
||||
class UtfUtilsTest: public testing::Test {};
|
||||
class UtfUtilsTest: public BaseTest {};
|
||||
|
||||
TEST_F(UtfUtilsTest, FromUtf8WithEmptyString) {
|
||||
const std::string empty_string = "";
|
||||
|
||||
@@ -10,6 +10,7 @@ using namespace audio;
|
||||
|
||||
struct AudioTest: PlatformTestSuite, testing::WithParamInterface<std::tuple<std::basic_string_view<char>, config_t>> {
|
||||
void SetUp() override {
|
||||
BaseTest::SetUp();
|
||||
m_config = std::get<1>(GetParam());
|
||||
m_mail = std::make_shared<safe::mail_raw_t>();
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ X4wnh1bwdiidqpcgyuKossLOPxbS786WmsesaAWPnpoY6M8aija+ALwNNuWWmyMg
|
||||
*
|
||||
* This fixture creates a real server to test the actual confighttp functions.
|
||||
*/
|
||||
class ConfigHttpTest: public ::testing::Test { // NOSONAR(cpp:S3656) - protected members are intentional for test fixture subclassing
|
||||
class ConfigHttpTest: public BaseTest { // NOSONAR(cpp:S3656) - protected members are intentional for test fixture subclassing
|
||||
protected:
|
||||
std::unique_ptr<SimpleWeb::Server<SimpleWeb::HTTPS>> server;
|
||||
std::unique_ptr<SimpleWeb::Client<SimpleWeb::HTTPS>> client;
|
||||
@@ -107,6 +107,7 @@ protected:
|
||||
std::filesystem::path web_dir_test_file;
|
||||
|
||||
void SetUp() override {
|
||||
BaseTest::SetUp();
|
||||
// Save current config
|
||||
saved_username = config::sunshine.username;
|
||||
saved_password = config::sunshine.password;
|
||||
@@ -354,6 +355,7 @@ protected:
|
||||
if (std::filesystem::exists(test_web_dir)) {
|
||||
std::filesystem::remove_all(test_web_dir);
|
||||
}
|
||||
BaseTest::TearDown();
|
||||
}
|
||||
|
||||
static std::string create_auth_header(const std::string &username, const std::string &password) {
|
||||
@@ -1251,7 +1253,6 @@ TEST_F(BrowseDirectoryTest, IsBrowsableExecutable_LinuxGroupExecBit_ReturnsTrue)
|
||||
TEST_F(BrowseDirectoryTest, BuildBrowseEntries_TypeAny_ReturnsAllEntries) {
|
||||
const auto entries = confighttp::build_browse_entries(browse_test_dir, "any");
|
||||
ASSERT_TRUE(entries.is_array());
|
||||
// subdir_a, subdir_b, file_alpha.txt, file_beta.txt, test_exec[.exe] = 5
|
||||
ASSERT_EQ(entries.size(), 5u);
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace {
|
||||
const std::string max_uint_string {std::to_string(std::numeric_limits<unsigned int>::max())};
|
||||
|
||||
template<class T>
|
||||
struct DisplayDeviceConfigTest: testing::TestWithParam<T> {};
|
||||
struct DisplayDeviceConfigTest: BaseTest, testing::WithParamInterface<T> {};
|
||||
} // namespace
|
||||
|
||||
using ParseDeviceId = DisplayDeviceConfigTest<std::pair<std::string, std::string>>;
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <format>
|
||||
#include <src/file_handler.h>
|
||||
|
||||
struct FileHandlerParentDirectoryTest: testing::TestWithParam<std::tuple<std::string, std::string>> {};
|
||||
struct FileHandlerParentDirectoryTest: BaseTest, testing::WithParamInterface<std::tuple<std::string, std::string>> {};
|
||||
|
||||
TEST_P(FileHandlerParentDirectoryTest, Run) {
|
||||
auto [input, expected] = GetParam();
|
||||
@@ -24,7 +24,7 @@ INSTANTIATE_TEST_SUITE_P(
|
||||
)
|
||||
);
|
||||
|
||||
struct FileHandlerMakeDirectoryTest: testing::TestWithParam<std::tuple<std::string, bool, bool>> {};
|
||||
struct FileHandlerMakeDirectoryTest: BaseTest, testing::WithParamInterface<std::tuple<std::string, bool, bool>> {};
|
||||
|
||||
TEST_P(FileHandlerMakeDirectoryTest, Run) {
|
||||
auto [input, expected, remove] = GetParam();
|
||||
@@ -52,7 +52,7 @@ INSTANTIATE_TEST_SUITE_P(
|
||||
)
|
||||
);
|
||||
|
||||
struct FileHandlerTests: testing::TestWithParam<std::tuple<int, std::string>> {};
|
||||
struct FileHandlerTests: BaseTest, testing::WithParamInterface<std::tuple<int, std::string>> {};
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
TestFiles,
|
||||
|
||||
@@ -76,7 +76,7 @@ X4wnh1bwdiidqpcgyuKossLOPxbS786WmsesaAWPnpoY6M8aija+ALwNNuWWmyMg
|
||||
9SVDV76xJzM36Uq7Kg3QJYTlY04WmPIdJHkCtXWf9g==
|
||||
-----END CERTIFICATE-----)";
|
||||
|
||||
struct PairingTest: testing::TestWithParam<std::tuple<pairing_input, pairing_output>> {};
|
||||
struct PairingTest: BaseTest, testing::WithParamInterface<std::tuple<pairing_input, pairing_output>> {};
|
||||
|
||||
TEST_P(PairingTest, Run) {
|
||||
auto [input, expected] = GetParam();
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
// local imports
|
||||
#include <src/httpcommon.h>
|
||||
|
||||
struct UrlEscapeTest: testing::TestWithParam<std::tuple<std::string, std::string>> {};
|
||||
struct UrlEscapeTest: BaseTest, testing::WithParamInterface<std::tuple<std::string, std::string>> {};
|
||||
|
||||
TEST_P(UrlEscapeTest, Run) {
|
||||
const auto &[input, expected] = GetParam();
|
||||
@@ -28,7 +28,7 @@ INSTANTIATE_TEST_SUITE_P(
|
||||
)
|
||||
);
|
||||
|
||||
struct UrlGetHostTest: testing::TestWithParam<std::tuple<std::string, std::string>> {};
|
||||
struct UrlGetHostTest: BaseTest, testing::WithParamInterface<std::tuple<std::string, std::string>> {};
|
||||
|
||||
TEST_P(UrlGetHostTest, Run) {
|
||||
const auto &[input, expected] = GetParam();
|
||||
@@ -45,7 +45,7 @@ INSTANTIATE_TEST_SUITE_P(
|
||||
)
|
||||
);
|
||||
|
||||
struct DownloadFileTest: testing::TestWithParam<std::tuple<std::string, std::string>> {};
|
||||
struct DownloadFileTest: BaseTest, testing::WithParamInterface<std::tuple<std::string, std::string>> {};
|
||||
|
||||
TEST_P(DownloadFileTest, Run) {
|
||||
const auto &[url, filename] = GetParam();
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace {
|
||||
constexpr auto log_file = "test_sunshine.log";
|
||||
} // namespace
|
||||
|
||||
struct LogLevelsTest: testing::TestWithParam<decltype(log_levels)::value_type> {};
|
||||
struct LogLevelsTest: BaseTest, testing::WithParamInterface<decltype(log_levels)::value_type> {};
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
Logging,
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
struct MouseHIDTest: PlatformTestSuite, testing::WithParamInterface<util::point_t> {
|
||||
void SetUp() override {
|
||||
BaseTest::SetUp();
|
||||
#ifdef _WIN32
|
||||
// TODO: Windows tests are failing, `get_mouse_loc` seems broken and `platf::abs_mouse` too
|
||||
// the alternative `platf::abs_mouse` method seem to work better during tests,
|
||||
@@ -21,6 +22,7 @@ struct MouseHIDTest: PlatformTestSuite, testing::WithParamInterface<util::point_
|
||||
|
||||
void TearDown() override {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(200));
|
||||
BaseTest::TearDown();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#include <src/network.h>
|
||||
|
||||
struct MdnsInstanceNameTest: testing::TestWithParam<std::tuple<std::string, std::string>> {};
|
||||
struct MdnsInstanceNameTest: BaseTest, testing::WithParamInterface<std::tuple<std::string, std::string>> {};
|
||||
|
||||
TEST_P(MdnsInstanceNameTest, Run) {
|
||||
auto [input, expected] = GetParam();
|
||||
@@ -30,11 +30,12 @@ INSTANTIATE_TEST_SUITE_P(
|
||||
/**
|
||||
* @brief Test fixture for bind_address tests with setup/teardown
|
||||
*/
|
||||
class BindAddressTest: public ::testing::Test {
|
||||
class BindAddressTest: public BaseTest {
|
||||
protected:
|
||||
std::string original_bind_address;
|
||||
|
||||
void SetUp() override {
|
||||
BaseTest::SetUp();
|
||||
// Save the original bind_address config
|
||||
original_bind_address = config::sunshine.bind_address;
|
||||
}
|
||||
@@ -42,6 +43,7 @@ protected:
|
||||
void TearDown() override {
|
||||
// Restore the original bind_address config
|
||||
config::sunshine.bind_address = original_bind_address;
|
||||
BaseTest::TearDown();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -14,9 +14,10 @@
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
class ProcessPNGTest: public ::testing::Test {
|
||||
class ProcessPNGTest: public BaseTest {
|
||||
protected:
|
||||
void SetUp() override {
|
||||
BaseTest::SetUp();
|
||||
// Create test directory
|
||||
test_dir = fs::temp_directory_path() / "sunshine_process_png_test"; // NOSONAR(cpp:S5443) - safe for tests
|
||||
fs::create_directories(test_dir);
|
||||
@@ -27,6 +28,7 @@ protected:
|
||||
if (fs::exists(test_dir)) {
|
||||
fs::remove_all(test_dir);
|
||||
}
|
||||
BaseTest::TearDown();
|
||||
}
|
||||
|
||||
// Helper function to create a file with specific content
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
struct EncoderTest: PlatformTestSuite, testing::WithParamInterface<video::encoder_t *> {
|
||||
void SetUp() override {
|
||||
BaseTest::SetUp();
|
||||
auto &encoder = *GetParam();
|
||||
if (!video::validate_encoder(encoder, false)) {
|
||||
// Encoder failed validation,
|
||||
@@ -49,7 +50,7 @@ TEST_P(EncoderTest, ValidateEncoder) {
|
||||
// todo:: test something besides fixture setup
|
||||
}
|
||||
|
||||
struct FramerateX100Test: testing::TestWithParam<std::tuple<std::int32_t, AVRational>> {};
|
||||
struct FramerateX100Test: BaseTest, testing::WithParamInterface<std::tuple<std::int32_t, AVRational>> {};
|
||||
|
||||
TEST_P(FramerateX100Test, Run) {
|
||||
const auto &[x100, expected] = GetParam();
|
||||
|
||||
Vendored
-1
Submodule third-party/googletest deleted from 52eb8108c5
Vendored
+1
-1
Submodule third-party/lizardbyte-common updated: bd1b0bb88d...06cd442b80
Reference in New Issue
Block a user