1 /** 2 * Copyright (c) 2021-2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 #ifndef PANDA_INTRUSIVE_TEST_H 16 #define PANDA_INTRUSIVE_TEST_H 17 18 #if defined(INTRUSIVE_TESTING) 19 #include "libpandabase/macros.h" 20 #include <atomic> 21 #include <cstdint> 22 23 namespace ark { 24 class IntrusiveTest { 25 protected: 26 static std::atomic<uint32_t> id_; 27 28 public: SetId(uint32_t test_id)29 static DISABLE_THREAD_SANITIZER_INSTRUMENTATION void SetId(uint32_t test_id) 30 { 31 IntrusiveTest::id_ = test_id; 32 } 33 GetId()34 static DISABLE_THREAD_SANITIZER_INSTRUMENTATION uint32_t GetId() 35 { 36 return IntrusiveTest::id_; 37 } 38 }; 39 } // namespace ark 40 #endif 41 #endif // PANDA_INTRUSIVE_TEST_H 42