xref: /aosp_15_r20/art/dex2oat/common_transaction_test.h (revision 795d594fd825385562da6b089ea9b2033f3abf5a)
1 /*
2  * Copyright (C) 2024 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 #ifndef ART_DEX2OAT_COMMON_TRANSACTION_TEST_H_
18 #define ART_DEX2OAT_COMMON_TRANSACTION_TEST_H_
19 
20 #include "common_runtime_test.h"
21 
22 #include "compiler_callbacks.h"
23 
24 namespace art HIDDEN {
25 
26 class CommonTransactionTestImpl {
27  protected:
28   static CompilerCallbacks* CreateCompilerCallbacks();
29 
30   static void EnterTransactionMode() REQUIRES_SHARED(Locks::mutator_lock_);
31   static void ExitTransactionMode();
32   static void RollbackAndExitTransactionMode() REQUIRES_SHARED(Locks::mutator_lock_);
33   static bool IsTransactionAborted();
34 };
35 
36 template <typename TestType>
37 class CommonTransactionTestBase : public TestType, public CommonTransactionTestImpl {
38  public:
SetUpRuntimeOptions(RuntimeOptions * options)39   void SetUpRuntimeOptions(RuntimeOptions* options) override {
40     TestType::SetUpRuntimeOptions(options);
41     this->callbacks_.reset(CommonTransactionTestImpl::CreateCompilerCallbacks());
42   }
43 };
44 
45 using CommonTransactionTest = CommonTransactionTestBase<CommonRuntimeTest>;
46 
47 }  // namespace art
48 
49 #endif  // ART_DEX2OAT_COMMON_TRANSACTION_TEST_H_
50