fix(linux): explain a missing graphical session when no capture method starts (#6095)

This commit is contained in:
Eren Çakar authored and GitHub committed 2026-11-13 18:12:25 -05:00
1 parent 949570130b
commit 657f9b68bf
3 files changed
+56

No files matched your search

+30
View File
@@ -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__