mirror of
https://github.com/LizardByte/Sunshine.git
synced 2026-11-30 09:08:53 +00:00
fix(linux): explain a missing graphical session when no capture method starts (#6095)
This commit is contained in:
1 parent
949570130b
commit
657f9b68bf
3 files changed
+56
No files matched your search
@@ -7,6 +7,7 @@
|
||||
|
||||
// test includes
|
||||
#include "../../../tests_common.h"
|
||||
#include "../../../tests_log_checker.h"
|
||||
|
||||
// standard includes
|
||||
#include <array>
|
||||
@@ -15,8 +16,10 @@
|
||||
#include <string>
|
||||
|
||||
// local includes
|
||||
#include "src/config.h"
|
||||
#include "src/logging.h"
|
||||
#include "src/platform/linux/misc.h"
|
||||
#include "src/utility.h"
|
||||
|
||||
namespace {
|
||||
/**
|
||||
@@ -109,4 +112,31 @@ TEST_F(ProcessEnvironmentSecurity, PreservesTraySessionVariables) {
|
||||
EXPECT_STREQ(std::getenv("WAYLAND_DISPLAY"), "wayland-test");
|
||||
}
|
||||
|
||||
TEST(LinuxCaptureSessionHint, LogsOnlyWithoutSessionVariablesAndWithoutKms) {
|
||||
logging::log_flush();
|
||||
environment_guard_t wayland_guard {"WAYLAND_DISPLAY"};
|
||||
environment_guard_t display_guard {"DISPLAY"};
|
||||
const auto original_capture = config::video.capture;
|
||||
auto restore_capture = util::fail_guard([&]() {
|
||||
config::video.capture = original_capture;
|
||||
});
|
||||
|
||||
ASSERT_EQ(unsetenv("WAYLAND_DISPLAY"), 0);
|
||||
ASSERT_EQ(unsetenv("DISPLAY"), 0);
|
||||
|
||||
for (const char *capture : {"", "kwin", "kms"}) {
|
||||
config::video.capture = capture;
|
||||
EXPECT_EQ(platf::log_missing_graphical_session_hint(), config::video.capture != "kms") << capture;
|
||||
}
|
||||
EXPECT_TRUE(log_checker::line_contains("test_sunshine.log", "Error: Neither WAYLAND_DISPLAY nor DISPLAY is set"));
|
||||
|
||||
config::video.capture = "kwin";
|
||||
ASSERT_EQ(setenv("WAYLAND_DISPLAY", "wayland-test", 1), 0);
|
||||
EXPECT_FALSE(platf::log_missing_graphical_session_hint());
|
||||
|
||||
ASSERT_EQ(unsetenv("WAYLAND_DISPLAY"), 0);
|
||||
ASSERT_EQ(setenv("DISPLAY", ":1", 1), 0);
|
||||
EXPECT_FALSE(platf::log_missing_graphical_session_hint());
|
||||
}
|
||||
|
||||
#endif // __linux__
|
||||
Reference in new issue
Block a user