File: build_32_bit_tests.patch

package info (click to toggle)
protobuf 3.21.12-3
  • links: PTS
  • area: main
  • in suites: bookworm
  • size: 41,020 kB
  • sloc: cpp: 179,370; java: 87,794; objc: 60,661; ansic: 37,810; cs: 28,526; python: 22,443; php: 11,464; ruby: 6,127; sh: 3,635; makefile: 3,341; pascal: 2,354; xml: 2,321; javascript: 311; lisp: 87; awk: 17
file content (140 lines) | stat: -rw-r--r-- 7,022 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
From 01c340d0bb9abb2654554afc732df2c89774ce81 Mon Sep 17 00:00:00 2001
From: Mike Kruskal <62662355+mkruskal-google@users.noreply.github.com>
Date: Mon, 19 Sep 2022 09:50:19 -0700
Subject: [PATCH] Adding full build to 32 bit tests (#10589)

* Adding full build to 32 bit tests

* Running C++ tests in 32 bit builds

* Patching static assert test failure

* Test fixes for 32-bit architectures

* Cleanup after CMake build

* Save protoc before cleanup

* Route protoc better
---
 .../compiler/cpp/message_size_unittest.cc     |  2 +-
 src/google/protobuf/extension_set_unittest.cc |  6 ++--
 .../protobuf/io/zero_copy_stream_unittest.cc  |  3 ++
 .../protobuf/repeated_field_unittest.cc       |  4 +--
 src/google/protobuf/util/time_util_test.cc    | 28 +++++++++++--------
 8 files changed, 42 insertions(+), 20 deletions(-)

diff --git a/src/google/protobuf/compiler/cpp/message_size_unittest.cc b/src/google/protobuf/compiler/cpp/message_size_unittest.cc
index a75d77a70cb..ed4a90e223f 100644
--- a/src/google/protobuf/compiler/cpp/message_size_unittest.cc
+++ b/src/google/protobuf/compiler/cpp/message_size_unittest.cc
@@ -139,9 +139,9 @@ TEST(GeneratedMessageTest, OneStringSize) {
 
 TEST(GeneratedMessageTest, MoreStringSize) {
   struct MockGenerated : public MockMessageBase {  // 16 bytes
-    int has_bits[1];                               // 4 bytes
     int cached_size;                               // 4 bytes
     MockRepeatedPtrField data;                     // 24 bytes
+    // + 4 bytes padding
   };
   GOOGLE_CHECK_MESSAGE_SIZE(MockGenerated, 48);
   EXPECT_EQ(sizeof(protobuf_unittest::MoreString), sizeof(MockGenerated));
diff --git a/src/google/protobuf/extension_set_unittest.cc b/src/google/protobuf/extension_set_unittest.cc
index 8b436bc20c9..84da3c5465a 100644
--- a/src/google/protobuf/extension_set_unittest.cc
+++ b/src/google/protobuf/extension_set_unittest.cc
@@ -852,8 +852,10 @@ TEST(ExtensionSetTest, SpaceUsedExcludingSelf) {
     const size_t old_capacity =                                                \
         message->GetRepeatedExtension(unittest::repeated_##type##_extension)   \
             .Capacity();                                                       \
-    EXPECT_GE(old_capacity,                                                    \
-              (RepeatedFieldLowerClampLimit<cpptype, sizeof(void*)>()));       \
+    EXPECT_GE(                                                                 \
+        old_capacity,                                                          \
+        (RepeatedFieldLowerClampLimit<cpptype, std::max(sizeof(cpptype),       \
+                                                        sizeof(void*))>()));   \
     for (int i = 0; i < 16; ++i) {                                             \
       message->AddExtension(unittest::repeated_##type##_extension, value);     \
     }                                                                          \
diff --git a/src/google/protobuf/io/zero_copy_stream_unittest.cc b/src/google/protobuf/io/zero_copy_stream_unittest.cc
index d82354e571b..d656da5f13b 100644
--- a/src/google/protobuf/io/zero_copy_stream_unittest.cc
+++ b/src/google/protobuf/io/zero_copy_stream_unittest.cc
@@ -719,6 +719,9 @@ TEST_F(IoTest, StringIo) {
 
 // Verifies that outputs up to kint32max can be created.
 TEST_F(IoTest, LargeOutput) {
+  // Filter out this test on 32-bit architectures.
+  if(sizeof(void*) < 8) return;
+
   std::string str;
   StringOutputStream output(&str);
   void* unused_data;
diff --git a/src/google/protobuf/repeated_field_unittest.cc b/src/google/protobuf/repeated_field_unittest.cc
index eb0b9091cf8..3baf6f25bb2 100644
--- a/src/google/protobuf/repeated_field_unittest.cc
+++ b/src/google/protobuf/repeated_field_unittest.cc
@@ -374,14 +374,14 @@ TEST(RepeatedField, ReserveNothing) {
 
 TEST(RepeatedField, ReserveLowerClamp) {
   int clamped_value = internal::CalculateReserveSize<bool, sizeof(void*)>(0, 1);
-  EXPECT_GE(clamped_value, 8 / sizeof(bool));
+  EXPECT_GE(clamped_value, sizeof(void*) / sizeof(bool));
   EXPECT_EQ((internal::RepeatedFieldLowerClampLimit<bool, sizeof(void*)>()),
             clamped_value);
   // EXPECT_EQ(clamped_value, (internal::CalculateReserveSize<bool,
   // sizeof(void*)>( clamped_value, 2)));
 
   clamped_value = internal::CalculateReserveSize<int, sizeof(void*)>(0, 1);
-  EXPECT_GE(clamped_value, 8 / sizeof(int));
+  EXPECT_GE(clamped_value, sizeof(void*) / sizeof(int));
   EXPECT_EQ((internal::RepeatedFieldLowerClampLimit<int, sizeof(void*)>()),
             clamped_value);
   // EXPECT_EQ(clamped_value, (internal::CalculateReserveSize<int,
diff --git a/src/google/protobuf/util/time_util_test.cc b/src/google/protobuf/util/time_util_test.cc
index 464e57b4ee5..dceb6dbe2bf 100644
--- a/src/google/protobuf/util/time_util_test.cc
+++ b/src/google/protobuf/util/time_util_test.cc
@@ -48,15 +48,18 @@ using google::protobuf::Timestamp;
 namespace {
 
 TEST(TimeUtilTest, TimestampStringFormat) {
-  Timestamp begin, end;
-  EXPECT_TRUE(TimeUtil::FromString("0001-01-01T00:00:00Z", &begin));
-  EXPECT_EQ(TimeUtil::kTimestampMinSeconds, begin.seconds());
-  EXPECT_EQ(0, begin.nanos());
-  EXPECT_TRUE(TimeUtil::FromString("9999-12-31T23:59:59.999999999Z", &end));
-  EXPECT_EQ(TimeUtil::kTimestampMaxSeconds, end.seconds());
-  EXPECT_EQ(999999999, end.nanos());
-  EXPECT_EQ("0001-01-01T00:00:00Z", TimeUtil::ToString(begin));
-  EXPECT_EQ("9999-12-31T23:59:59.999999999Z", TimeUtil::ToString(end));
+  // These these are out of bounds for 32-bit architectures.
+  if(sizeof(time_t) >= sizeof(uint64_t)) {
+    Timestamp begin, end;
+    EXPECT_TRUE(TimeUtil::FromString("0001-01-01T00:00:00Z", &begin));
+    EXPECT_EQ(TimeUtil::kTimestampMinSeconds, begin.seconds());
+    EXPECT_EQ(0, begin.nanos());
+    EXPECT_TRUE(TimeUtil::FromString("9999-12-31T23:59:59.999999999Z", &end));
+    EXPECT_EQ(TimeUtil::kTimestampMaxSeconds, end.seconds());
+    EXPECT_EQ(999999999, end.nanos());
+    EXPECT_EQ("0001-01-01T00:00:00Z", TimeUtil::ToString(begin));
+    EXPECT_EQ("9999-12-31T23:59:59.999999999Z", TimeUtil::ToString(end));
+  }
 
   // Test negative timestamps.
   Timestamp time = TimeUtil::NanosecondsToTimestamp(-1);
@@ -94,9 +97,12 @@ TEST(TimeUtilTest, DurationStringFormat) {
   EXPECT_TRUE(TimeUtil::FromString("0001-01-01T00:00:00Z", &begin));
   EXPECT_TRUE(TimeUtil::FromString("9999-12-31T23:59:59.999999999Z", &end));
 
-  EXPECT_EQ("315537897599.999999999s", TimeUtil::ToString(end - begin));
+  // These these are out of bounds for 32-bit architectures.
+  if(sizeof(time_t) >= sizeof(uint64_t)) {
+    EXPECT_EQ("315537897599.999999999s", TimeUtil::ToString(end - begin));
+    EXPECT_EQ("-315537897599.999999999s", TimeUtil::ToString(begin - end));
+  }
   EXPECT_EQ(999999999, (end - begin).nanos());
-  EXPECT_EQ("-315537897599.999999999s", TimeUtil::ToString(begin - end));
   EXPECT_EQ(-999999999, (begin - end).nanos());
 
   // Generated output should contain 3, 6, or 9 fractional digits.