• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2023 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 #include "hidumper_test_utils.h"
16 
17 using namespace std;
18 namespace OHOS {
19 namespace HiviewDFX {
HidumperTestUtils()20 HidumperTestUtils::HidumperTestUtils()
21 {
22 }
23 
~HidumperTestUtils()24 HidumperTestUtils::~HidumperTestUtils()
25 {
26 }
27 
IsExistInCmdResult(const std::string & cmd,const std::string & str)28 bool HidumperTestUtils::IsExistInCmdResult(const std::string &cmd, const std::string &str)
29 {
30     bool res = false;
31     size_t len = 0;
32     FILE *fp = popen(cmd.c_str(), "r");
33     char* buffer = nullptr;
34     while (getline(&buffer, &len, fp) != -1) {
35         std::string line = buffer;
36         if (line.find(str) != string::npos) {
37             res = true;
38             break;
39         }
40     }
41     pclose(fp);
42     return res;
43 }
44 } // namespace HiviewDFX
45 } // namespace OHOS
46