xref: /aosp_15_r20/test/dittosuite/test/include/instruction_test.h (revision 6fa2df46f119dce7527f5beb2814eca0e6f886ac)
1 // Copyright (C) 2021 The Android Open Source Project
2 //
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 #pragma once
16 
17 #include "mock_syscall.h"
18 
19 #include <gmock/gmock.h>
20 #include <gtest/gtest.h>
21 
22 #include <ditto/instruction.h>
23 #include <ditto/shared_variables.h>
24 
25 #ifdef __ANDROID__
26 #include <android-base/file.h>
27 const std::string absolute_path = android::base::GetExecutableDirectory();
28 #else
29 const std::string absolute_path = "";
30 #endif
31 
32 class InstructionTest : public ::testing::Test {
33  protected:
34   MockSyscall syscall_;
35   std::list<int> thread_ids;
36 
37   // Set absolute_path
SetUp()38   virtual void SetUp() override {
39     dittosuite::SharedVariables::ClearKeys();
40     thread_ids.push_back(0);
41     auto absolute_path_key = dittosuite::SharedVariables::GetKey(thread_ids, "absolute_path");
42     dittosuite::SharedVariables::Set(absolute_path_key, absolute_path);
43     dittosuite::Instruction::SetAbsolutePathKey(absolute_path_key);
44   }
45 };
46 
47 template <class T>
48 class InstructionTestWithParam : public InstructionTest, public ::testing::WithParamInterface<T> {};
49