• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 LIBABCKIT_TESTS_VM_HELPERS
17 #define LIBABCKIT_TESTS_VM_HELPERS
18 
19 #include <iostream>
20 #include <sstream>
21 #include <string>
22 
23 namespace libabckit::test::helpers {
24 
25 // NOLINTNEXTLINE(cppcoreguidelines-special-member-functions)
26 class CoutRedirect {
27 public:
CoutRedirect(std::streambuf * newBuffer)28     explicit CoutRedirect(std::streambuf *newBuffer) : oldBuffer_(std::cout.rdbuf(newBuffer)) {}
29 
~CoutRedirect()30     ~CoutRedirect()
31     {
32         std::cout.rdbuf(oldBuffer_);
33     }
34 
35 private:
36     std::streambuf *oldBuffer_;
37 };
38 
39 std::string ExecuteDynamicAbc(const std::string &abcPath, const std::string &entry);
40 std::string ExecuteStaticAbc(const std::string &abcPath, const std::string &klassName, const std::string &methodName);
41 
42 }  // namespace libabckit::test::helpers
43 
44 #endif  // LIBABCKIT_TESTS_ETS_VM_HELPERS
45