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 
17 
18 #ifdef ABSL_INTERNAL_HAVE_DEBUGGING_STACK_CONSUMPTION
19 
20 #include <string.h>
21 
22 #include "gtest/gtest.h"
24 
25 namespace absl {
26 namespace debugging_internal {
27 namespace {
28 
29 static void SimpleSignalHandler(int signo) {
30  char buf[100];
31  memset(buf, 'a', sizeof(buf));
32 
33  // Never true, but prevents compiler from optimizing buf out.
34  if (signo == 0) {
35  ABSL_RAW_LOG(INFO, "%p", static_cast<void*>(buf));
36  }
37 }
38 
39 TEST(SignalHandlerStackConsumptionTest, MeasuresStackConsumption) {
40  // Our handler should consume reasonable number of bytes.
41  EXPECT_GE(GetSignalHandlerStackConsumption(SimpleSignalHandler), 100);
42 }
43 
44 } // namespace
45 } // namespace debugging_internal
46 } // namespace absl
47 
48 #endif // ABSL_INTERNAL_HAVE_DEBUGGING_STACK_CONSUMPTION
#define ABSL_RAW_LOG(severity,...)
Definition: raw_logging.h:42
TEST(NotificationTest, SanityTest)
char buf[N]
Definition: algorithm.h:29


abseil_cpp
Author(s):
autogenerated on Tue Jun 18 2019 19:44:37