From 7c5452d3ae1e90ca902f5668c1d37a6dcc6702fc Mon Sep 17 00:00:00 2001 From: Michael Brase Date: Thu, 4 Jan 2024 02:30:03 -0600 Subject: [PATCH] [fuchsia] Remove LoggingSocketTest.UseSyslogOnFuchsia test (flutter/engine#49524) This test reads back logged messages on Fuchsia to verify that FML logging has the log sink setup correctly. However, it relies on internal implementation details of the Fuchsia log packet format, which recently changed (to support structured logging) and it broke this test. Since there isn't a supported way to parse structured log packets outside of the Fuchsia repository, I'm removing this test to unblock the SDK roll. flutter/flutter#140950 b/315973146 ## Pre-launch Checklist - [X] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [X] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [X] I read and followed the [Flutter Style Guide] and the [C++, Objective-C, Java style guides]. - [X] I listed at least one issue that this PR fixes in the description above. - [X] I added new tests to check the change I am making or feature I am adding, or the PR is [test-exempt]. See [testing the engine] for instructions on writing and running engine tests. - [X] I updated/added relevant documentation (doc comments with `///`). - [X] I signed the [CLA]. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. [Contributor Guide]: https://github.com/flutter/flutter/wiki/Tree-hygiene#overview [Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene [test-exempt]: https://github.com/flutter/flutter/wiki/Tree-hygiene#tests [Flutter Style Guide]: https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style [testing the engine]: https://github.com/flutter/flutter/wiki/Testing-the-engine [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/wiki/Chat --- engine/src/flutter/fml/logging_unittests.cc | 101 -------------------- 1 file changed, 101 deletions(-) diff --git a/engine/src/flutter/fml/logging_unittests.cc b/engine/src/flutter/fml/logging_unittests.cc index b418397640..812dbf6706 100644 --- a/engine/src/flutter/fml/logging_unittests.cc +++ b/engine/src/flutter/fml/logging_unittests.cc @@ -9,15 +9,6 @@ #include "flutter/fml/logging.h" #include "gtest/gtest.h" -#if defined(OS_FUCHSIA) -#include -#include -#include -#include - -#include "gmock/gmock.h" -#endif - namespace fml { namespace testing { @@ -76,97 +67,5 @@ TEST(LoggingTest, UnreachableKillProcessWithMacro) { ASSERT_DEATH({ FML_UNREACHABLE(); }, ""); } -#if defined(OS_FUCHSIA) - -struct LogPacket { - fx_log_metadata_t metadata; - std::vector tags; - std::string message; -}; - -class LoggingSocketTest : public ::testing::Test { - protected: - void SetUp() override { - zx::socket local; - ASSERT_EQ(ZX_OK, zx::socket::create(ZX_SOCKET_DATAGRAM, &local, &socket_)); - - fx_logger_config_t config = { - .min_severity = FX_LOG_INFO, - .log_sink_socket = local.release(), - .tags = nullptr, - .num_tags = 0, - }; - - fx_log_reconfigure(&config); - } - - LogPacket ReadPacket() { - LogPacket result; - fx_log_packet_t packet; - zx_status_t res = socket_.read(0, &packet, sizeof(packet), nullptr); - EXPECT_EQ(ZX_OK, res); - result.metadata = packet.metadata; - int pos = 0; - while (packet.data[pos]) { - int tag_len = packet.data[pos++]; - result.tags.emplace_back(packet.data + pos, tag_len); - pos += tag_len; - } - result.message.append(packet.data + pos + 1); - return result; - } - - void ReadPacketAndCompare(fx_log_severity_t severity, - const std::string& message, - const std::vector& tags = {}) { - LogPacket packet = ReadPacket(); - EXPECT_EQ(severity, packet.metadata.severity); - EXPECT_THAT(packet.message, ::testing::EndsWith(message)); - EXPECT_EQ(tags, packet.tags); - } - - void CheckSocketEmpty() { - zx_info_socket_t info = {}; - zx_status_t status = - socket_.get_info(ZX_INFO_SOCKET, &info, sizeof(info), nullptr, nullptr); - ASSERT_EQ(ZX_OK, status); - EXPECT_EQ(0u, info.rx_buf_available); - } - - zx::socket socket_; -}; - -TEST_F(LoggingSocketTest, UseSyslogOnFuchsia) { - const char* msg1 = "test message"; - const char* msg2 = "hello"; - const char* msg3 = "logging"; - const char* msg4 = "Another message"; - const char* msg5 = "Foo"; - - fml::SetLogSettings({.min_log_level = -1}); - - FML_LOG(INFO) << msg1; - ReadPacketAndCompare(FX_LOG_INFO, msg1); - CheckSocketEmpty(); - - FML_LOG(WARNING) << msg2; - ReadPacketAndCompare(FX_LOG_WARNING, msg2); - CheckSocketEmpty(); - - FML_LOG(ERROR) << msg3; - ReadPacketAndCompare(FX_LOG_ERROR, msg3); - CheckSocketEmpty(); - - FML_VLOG(1) << msg4; - ReadPacketAndCompare(fx_log_severity_from_verbosity(1), msg4); - CheckSocketEmpty(); - - // VLOG(2) is not enabled so the log gets dropped. - FML_VLOG(2) << msg5; - CheckSocketEmpty(); -} - -#endif - } // namespace testing } // namespace fml