stack_consumption_test.cc
Go to the documentation of this file.
00001 //
00002 // Copyright 2018 The Abseil Authors.
00003 //
00004 // Licensed under the Apache License, Version 2.0 (the "License");
00005 // you may not use this file except in compliance with the License.
00006 // You may obtain a copy of the License at
00007 //
00008 //      https://www.apache.org/licenses/LICENSE-2.0
00009 //
00010 // Unless required by applicable law or agreed to in writing, software
00011 // distributed under the License is distributed on an "AS IS" BASIS,
00012 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013 // See the License for the specific language governing permissions and
00014 // limitations under the License.
00015 
00016 #include "absl/debugging/internal/stack_consumption.h"
00017 
00018 #ifdef ABSL_INTERNAL_HAVE_DEBUGGING_STACK_CONSUMPTION
00019 
00020 #include <string.h>
00021 
00022 #include "gtest/gtest.h"
00023 #include "absl/base/internal/raw_logging.h"
00024 
00025 namespace absl {
00026 namespace debugging_internal {
00027 namespace {
00028 
00029 static void SimpleSignalHandler(int signo) {
00030   char buf[100];
00031   memset(buf, 'a', sizeof(buf));
00032 
00033   // Never true, but prevents compiler from optimizing buf out.
00034   if (signo == 0) {
00035     ABSL_RAW_LOG(INFO, "%p", static_cast<void*>(buf));
00036   }
00037 }
00038 
00039 TEST(SignalHandlerStackConsumptionTest, MeasuresStackConsumption) {
00040   // Our handler should consume reasonable number of bytes.
00041   EXPECT_GE(GetSignalHandlerStackConsumption(SimpleSignalHandler), 100);
00042 }
00043 
00044 }  // namespace
00045 }  // namespace debugging_internal
00046 }  // namespace absl
00047 
00048 #endif  // ABSL_INTERNAL_HAVE_DEBUGGING_STACK_CONSUMPTION


abseil_cpp
Author(s):
autogenerated on Wed Jun 19 2019 19:42:15