From 488568eded70567e5ac0f81f2bd8da434bccd5ff Mon Sep 17 00:00:00 2001 From: Begasus Date: Sat, 2 Sep 2023 18:12:29 +0200 Subject: Add Haiku to supported platforms diff --git a/src/glog/platform.h b/src/glog/platform.h index efb6ff9..0efadfa 100644 --- a/src/glog/platform.h +++ b/src/glog/platform.h @@ -53,6 +53,8 @@ # define GLOG_OS_OPENBSD #elif defined(__EMSCRIPTEN__) # define GLOG_OS_EMSCRIPTEN +#elif defined(__HAIKU__) +#define GLOG_OS_HAIKU #else // TODO(hamaji): Add other platforms. #error Platform not supported by glog. Please consider to contribute platform information by submitting a pull request on Github. -- 2.45.2 From e0f2e27615af1f99b262c97c6813d0fc8d9c4a73 Mon Sep 17 00:00:00 2001 From: Begasus Date: Sat, 2 Sep 2023 18:37:03 +0200 Subject: Don't set CMAKE_POSITION_INDEPENDENT_CODE to ON diff --git a/CMakeLists.txt b/CMakeLists.txt index 45064ab..4c17072 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -58,7 +58,7 @@ endif (NOT WITH_GTEST) set (CMAKE_C_VISIBILITY_PRESET hidden) set (CMAKE_CXX_VISIBILITY_PRESET hidden) -set (CMAKE_POSITION_INDEPENDENT_CODE ON) +set (CMAKE_POSITION_INDEPENDENT_CODE OFF) set (CMAKE_VISIBILITY_INLINES_HIDDEN ON) set (CMAKE_DEBUG_POSTFIX d) -- 2.45.2 From 3885d43515369541edc5a909cc23fb89781c6fe3 Mon Sep 17 00:00:00 2001 From: Schrijvers Luc Date: Sun, 19 Jan 2025 09:14:20 +0100 Subject: Fix path for cmd:true diff --git a/src/logging_unittest.cc b/src/logging_unittest.cc index 321f38f..69d166a 100644 --- a/src/logging_unittest.cc +++ b/src/logging_unittest.cc @@ -1544,7 +1544,7 @@ TEST(LogMsgTime, gmtoff) { TEST(EmailLogging, ValidAddress) { FlagSaver saver; - FLAGS_logmailer = "/usr/bin/true"; + FLAGS_logmailer = "/bin/true"; EXPECT_TRUE( SendEmail("example@example.com", "Example subject", "Example body")); @@ -1552,7 +1552,7 @@ TEST(EmailLogging, ValidAddress) { TEST(EmailLogging, MultipleAddresses) { FlagSaver saver; - FLAGS_logmailer = "/usr/bin/true"; + FLAGS_logmailer = "/bin/true"; EXPECT_TRUE(SendEmail("example@example.com,foo@bar.com", "Example subject", "Example body")); @@ -1560,14 +1560,14 @@ TEST(EmailLogging, MultipleAddresses) { TEST(EmailLogging, InvalidAddress) { FlagSaver saver; - FLAGS_logmailer = "/usr/bin/true"; + FLAGS_logmailer = "/bin/true"; EXPECT_FALSE(SendEmail("hello world@foo", "Example subject", "Example body")); } TEST(EmailLogging, MaliciousAddress) { FlagSaver saver; - FLAGS_logmailer = "/usr/bin/true"; + FLAGS_logmailer = "/bin/true"; EXPECT_FALSE( SendEmail("!/bin/true@example.com", "Example subject", "Example body")); -- 2.45.2 From 5a7faf382ddea8465f383348496bcafda624d283 Mon Sep 17 00:00:00 2001 From: Schrijvers Luc Date: Sun, 19 Jan 2025 09:37:01 +0100 Subject: Fix test, kudos to Debian https://sources.debian.org/patches/google-glog/0.7.1-1/20120621_errnos.diff/ diff --git a/src/googletest.h b/src/googletest.h index 33af3fe..1f69a19 100644 --- a/src/googletest.h +++ b/src/googletest.h @@ -480,6 +480,18 @@ static inline void StringReplace(string* str, const string& oldsub, } } +static inline void IntReplace(string* str, + const string& oldsub, + int newsub) { + size_t pos = str->find(oldsub); + if (pos != string::npos) { + std::ostringstream ss; + ss << newsub; + const std::string x = ss.str(); + str->replace(pos, oldsub.size(), x.c_str()); + } +} + static inline string Munge(const string& filename) { std::unique_ptr fp{fopen(filename.c_str(), "rb")}; CHECK(fp != nullptr) << filename << ": couldn't open"; @@ -499,9 +511,13 @@ static inline string Munge(const string& filename) { StringReplace(&line, "__SUCCESS__", StrError(0)); StringReplace(&line, "__ENOENT__", StrError(ENOENT)); + IntReplace(&line, "__ENOENT_NUM__", ENOENT); StringReplace(&line, "__EINTR__", StrError(EINTR)); + IntReplace(&line, "__EINTR_NUM__", EINTR); StringReplace(&line, "__ENXIO__", StrError(ENXIO)); + IntReplace(&line, "__ENXIO_NUM__", ENXIO); StringReplace(&line, "__ENOEXEC__", StrError(ENOEXEC)); + IntReplace(&line, "__ENOEXEC_NUM__", ENOEXEC); result += line + "\n"; } return result; diff --git a/src/logging_unittest.cc b/src/logging_unittest.cc index 69d166a..5b11679 100644 --- a/src/logging_unittest.cc +++ b/src/logging_unittest.cc @@ -98,6 +98,17 @@ void SetExitOnDFatal(bool value); } // namespace base } // namespace google +static int errnoForIteration(int i) { + switch (i) { + case 0: return 0; + case 2: return ENOENT; + case 4: return EINTR; + case 6: return ENXIO; + case 8: return ENOEXEC; + } + return -1; +} + static void TestLogging(bool check_counts); static void TestRawLogging(); static void LogWithLevels(int v, int severity, bool err, bool alsoerr); @@ -311,7 +322,7 @@ void TestLogging(bool check_counts) { LOG(INFO) << string("foo ") << "bar " << 10 << ' ' << 3.4; for (int i = 0; i < 10; ++i) { int old_errno = errno; - errno = i; + errno = errnoForIteration(i); PLOG_EVERY_N(ERROR, 2) << "Plog every 2, iteration " << COUNTER; errno = old_errno; diff --git a/src/logging_unittest.err b/src/logging_unittest.err index 21517cb..6eef6dd 100644 --- a/src/logging_unittest.err +++ b/src/logging_unittest.err @@ -51,21 +51,21 @@ WYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Log if every 5, iteration 1 IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Log if every 1, iteration 1 EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Log if less than 3 every 2, iteration 1 IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Log if every 1, iteration 2 -EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Plog every 2, iteration 3: __ENOENT__ [2] +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Plog every 2, iteration 3: ENOENT [ENOENT_NUM] IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Log if every 1, iteration 3 EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Log if less than 3 every 2, iteration 3 EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Log every 3, iteration 4 IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Log if every 1, iteration 4 -EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Plog every 2, iteration 5: __EINTR__ [4] +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Plog every 2, iteration 5: __EINTR__ [ENOENT_NUM] EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Log every 4, iteration 5 IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Log if every 1, iteration 5 WYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Log if every 5, iteration 6 IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Log if every 1, iteration 6 -EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Plog every 2, iteration 7: __ENXIO__ [6] +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Plog every 2, iteration 7: __ENXIO__ [ENOENT_NUM] EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Log every 3, iteration 7 IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Log if every 1, iteration 7 IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Log if every 1, iteration 8 -EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Plog every 2, iteration 9: __ENOEXEC__ [8] +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Plog every 2, iteration 9: __ENOEXEC__ [ENOENT_NUM] EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Log every 4, iteration 9 IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Log if every 1, iteration 9 EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Log every 3, iteration 10 -- 2.45.2