| Andreas Gampe | 1c5b42f | 2017-06-15 18:20:45 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2017 The Android Open Source Project |
| 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 | * http://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 | |
| 17 | #include "logging.h" |
| 18 | |
| 19 | #include <type_traits> |
| 20 | |
| 21 | #include "android-base/logging.h" |
| 22 | #include "base/bit_utils.h" |
| 23 | #include "base/macros.h" |
| 24 | #include "common_runtime_test.h" |
| 25 | |
| 26 | namespace art { |
| 27 | |
| 28 | static void SimpleAborter(const char* msg) { |
| 29 | LOG(FATAL_WITHOUT_ABORT) << msg; |
| 30 | _exit(1); |
| 31 | } |
| 32 | |
| 33 | class LoggingTest : public CommonRuntimeTest { |
| 34 | protected: |
| 35 | void PostRuntimeCreate() OVERRIDE { |
| 36 | // In our abort tests we really don't want the runtime to create a real dump. |
| 37 | android::base::SetAborter(SimpleAborter); |
| 38 | } |
| 39 | }; |
| 40 | |
| 41 | #ifdef NDEBUG |
| 42 | #error Unexpected NDEBUG |
| 43 | #endif |
| 44 | |
| 45 | class TestClass { |
| 46 | public: |
| 47 | DECLARE_RUNTIME_DEBUG_FLAG(kFlag); |
| 48 | }; |
| 49 | DEFINE_RUNTIME_DEBUG_FLAG(TestClass, kFlag); |
| 50 | |
| 51 | TEST_F(LoggingTest, DECL_DEF) { |
| 52 | SetRuntimeDebugFlagsEnabled(true); |
| 53 | EXPECT_TRUE(TestClass::kFlag); |
| 54 | |
| 55 | SetRuntimeDebugFlagsEnabled(false); |
| 56 | EXPECT_FALSE(TestClass::kFlag); |
| 57 | } |
| 58 | |
| 59 | } // namespace art |