1 /*
2  * Copyright (c) 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 
16 #ifndef MOCK_ECMASCRIPT_AOT_RUNTIME_INFO_H
17 #define MOCK_ECMASCRIPT_AOT_RUNTIME_INFO_H
18 
19 #include "ecmascript/ohos/aot_runtime_info.h"
20 
21 namespace panda::test {
22 class MockAotRuntimeInfo : public ecmascript::ohos::AotRuntimeInfo {
23 public:
24     static constexpr const char *SANBOX_DIR = "ohos-crash-test";
25     static constexpr const char *AOT_RUNTIME_INFO = "aot_runtime_info.log";
26     MockAotRuntimeInfo();
MockAotRuntimeInfo(bool isRuntimeInfoCrashTest)27     MockAotRuntimeInfo(bool isRuntimeInfoCrashTest) : isRuntimeInfoCrashTest_(isRuntimeInfoCrashTest) {}
28     ~MockAotRuntimeInfo();
29 
30     bool GetRuntimeBuildId(char *buildId, int length) const override;
31     bool GetMicrosecondsTimeStamp(char *timestamp, size_t length) const override;
32     bool GetCrashSandBoxRealPath(char *realOutPath, size_t length) const override;
33 
34     bool BuildRuntimeInfoPart(char *runtimeInfoPart, const char *soBuildId, const char *timestamp,
35         ecmascript::ohos::RuntimeInfoType type) const;
36     void SetRuntimeInfo(const char *realOutPath, char lines[][BUFFER_SIZE], int length) const override;
37 
38 protected:
IsRuntimeInfoCrashTest() const39     bool IsRuntimeInfoCrashTest() const
40     {
41         return isRuntimeInfoCrashTest_;
42     }
43 
44     bool isRuntimeInfoCrashTest_ = false;
45 };
46 };  // namespace panda::test
47 #endif // MOCK_ECMASCRIPT_AOT_RUNTIME_INFO_H
48