xref: /aosp_15_r20/test/dittosuite/test/include/instruction_test.h (revision 6fa2df46f119dce7527f5beb2814eca0e6f886ac)
1*6fa2df46SAndroid Build Coastguard Worker // Copyright (C) 2021 The Android Open Source Project
2*6fa2df46SAndroid Build Coastguard Worker //
3*6fa2df46SAndroid Build Coastguard Worker // Licensed under the Apache License, Version 2.0 (the "License");
4*6fa2df46SAndroid Build Coastguard Worker // you may not use this file except in compliance with the License.
5*6fa2df46SAndroid Build Coastguard Worker // You may obtain a copy of the License at
6*6fa2df46SAndroid Build Coastguard Worker //
7*6fa2df46SAndroid Build Coastguard Worker //      http://www.apache.org/licenses/LICENSE-2.0
8*6fa2df46SAndroid Build Coastguard Worker //
9*6fa2df46SAndroid Build Coastguard Worker // Unless required by applicable law or agreed to in writing, software
10*6fa2df46SAndroid Build Coastguard Worker // distributed under the License is distributed on an "AS IS" BASIS,
11*6fa2df46SAndroid Build Coastguard Worker // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12*6fa2df46SAndroid Build Coastguard Worker // See the License for the specific language governing permissions and
13*6fa2df46SAndroid Build Coastguard Worker // limitations under the License.
14*6fa2df46SAndroid Build Coastguard Worker 
15*6fa2df46SAndroid Build Coastguard Worker #pragma once
16*6fa2df46SAndroid Build Coastguard Worker 
17*6fa2df46SAndroid Build Coastguard Worker #include "mock_syscall.h"
18*6fa2df46SAndroid Build Coastguard Worker 
19*6fa2df46SAndroid Build Coastguard Worker #include <gmock/gmock.h>
20*6fa2df46SAndroid Build Coastguard Worker #include <gtest/gtest.h>
21*6fa2df46SAndroid Build Coastguard Worker 
22*6fa2df46SAndroid Build Coastguard Worker #include <ditto/instruction.h>
23*6fa2df46SAndroid Build Coastguard Worker #include <ditto/shared_variables.h>
24*6fa2df46SAndroid Build Coastguard Worker 
25*6fa2df46SAndroid Build Coastguard Worker #ifdef __ANDROID__
26*6fa2df46SAndroid Build Coastguard Worker #include <android-base/file.h>
27*6fa2df46SAndroid Build Coastguard Worker const std::string absolute_path = android::base::GetExecutableDirectory();
28*6fa2df46SAndroid Build Coastguard Worker #else
29*6fa2df46SAndroid Build Coastguard Worker const std::string absolute_path = "";
30*6fa2df46SAndroid Build Coastguard Worker #endif
31*6fa2df46SAndroid Build Coastguard Worker 
32*6fa2df46SAndroid Build Coastguard Worker class InstructionTest : public ::testing::Test {
33*6fa2df46SAndroid Build Coastguard Worker  protected:
34*6fa2df46SAndroid Build Coastguard Worker   MockSyscall syscall_;
35*6fa2df46SAndroid Build Coastguard Worker   std::list<int> thread_ids;
36*6fa2df46SAndroid Build Coastguard Worker 
37*6fa2df46SAndroid Build Coastguard Worker   // Set absolute_path
SetUp()38*6fa2df46SAndroid Build Coastguard Worker   virtual void SetUp() override {
39*6fa2df46SAndroid Build Coastguard Worker     dittosuite::SharedVariables::ClearKeys();
40*6fa2df46SAndroid Build Coastguard Worker     thread_ids.push_back(0);
41*6fa2df46SAndroid Build Coastguard Worker     auto absolute_path_key = dittosuite::SharedVariables::GetKey(thread_ids, "absolute_path");
42*6fa2df46SAndroid Build Coastguard Worker     dittosuite::SharedVariables::Set(absolute_path_key, absolute_path);
43*6fa2df46SAndroid Build Coastguard Worker     dittosuite::Instruction::SetAbsolutePathKey(absolute_path_key);
44*6fa2df46SAndroid Build Coastguard Worker   }
45*6fa2df46SAndroid Build Coastguard Worker };
46*6fa2df46SAndroid Build Coastguard Worker 
47*6fa2df46SAndroid Build Coastguard Worker template <class T>
48*6fa2df46SAndroid Build Coastguard Worker class InstructionTestWithParam : public InstructionTest, public ::testing::WithParamInterface<T> {};
49