abseil-cpp/absl/debugging/internal/stack_consumption_test.cc
Go to the documentation of this file.
1 //
2 // Copyright 2018 The Abseil Authors.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // https://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 
16 #include "absl/debugging/internal/stack_consumption.h"
17 
18 #ifdef ABSL_INTERNAL_HAVE_DEBUGGING_STACK_CONSUMPTION
19 
20 #include <string.h>
21 
22 #include "gtest/gtest.h"
23 #include "absl/base/internal/raw_logging.h"
24 
25 namespace absl {
27 namespace debugging_internal {
28 namespace {
29 
30 static void SimpleSignalHandler(int signo) {
31  char buf[100];
32  memset(buf, 'a', sizeof(buf));
33 
34  // Never true, but prevents compiler from optimizing buf out.
35  if (signo == 0) {
36  ABSL_RAW_LOG(INFO, "%p", static_cast<void*>(buf));
37  }
38 }
39 
40 TEST(SignalHandlerStackConsumptionTest, MeasuresStackConsumption) {
41  // Our handler should consume reasonable number of bytes.
42  EXPECT_GE(GetSignalHandlerStackConsumption(SimpleSignalHandler), 100);
43 }
44 
45 } // namespace
46 } // namespace debugging_internal
48 } // namespace absl
49 
50 #endif // ABSL_INTERNAL_HAVE_DEBUGGING_STACK_CONSUMPTION
memset
return memset(p, 0, total)
string.h
buf
voidpf void * buf
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:136
absl::TEST
TEST(NotificationTest, SanityTest)
Definition: abseil-cpp/absl/synchronization/notification_test.cc:126
ABSL_NAMESPACE_END
#define ABSL_NAMESPACE_END
Definition: third_party/abseil-cpp/absl/base/config.h:171
ABSL_NAMESPACE_BEGIN
#define ABSL_NAMESPACE_BEGIN
Definition: third_party/abseil-cpp/absl/base/config.h:170
python_utils.jobset.INFO
INFO
Definition: jobset.py:111
EXPECT_GE
#define EXPECT_GE(val1, val2)
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:2034
absl
Definition: abseil-cpp/absl/algorithm/algorithm.h:31
ABSL_RAW_LOG
#define ABSL_RAW_LOG(severity,...)
Definition: abseil-cpp/absl/base/internal/raw_logging.h:44


grpc
Author(s):
autogenerated on Fri May 16 2025 03:00:17