• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 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 <gtest/gtest.h>
16 #include "RAM.h"
17 #include <sstream>
18 #include <fstream>
19 #include <climits>
20 #include <cstdio>
21 #include <algorithm>
22 #include <iostream>
23 #include <thread>
24 #include <string>
25 #include <regex>
26 #include "sp_utils.h"
27 #include "memory_collector.h"
28 #include "collect_result.h"
29 #include "startup_delay.h"
30 #include "sp_log.h"
31 #include "common.h"
32 
33 using namespace testing::ext;
34 using namespace std;
35 
36 namespace OHOS {
37 namespace SmartPerf {
38 class RAMTest : public testing::Test {
39 public:
SetUpTestCase()40     static void SetUpTestCase() {}
TearDownTestCase()41     static void TearDownTestCase() {}
42 
SetUp()43     void SetUp() {}
TearDown()44     void TearDown() {}
45 };
46 
47 HWTEST_F(RAMTest, ProcMemNaInfoTest01, TestSize.Level1)
48 {
49     bool ret = false;
50     RAM &ram = RAM::GetInstance();
51     std::map<std::string, std::string> procMemInfo;
52     procMemInfo = ram.ProcMemNaInfo();
53     if (!procMemInfo.empty()) {
54         for (auto item : procMemInfo) {
55             if (item.second == "NA") {
56                 ret = true;
57             }
58         }
59     }
60     EXPECT_TRUE(ret);
61 }
62 
63 HWTEST_F(RAMTest, GetSysRamInfoTest01, TestSize.Level1)
64 {
65     bool ret = false;
66     RAM &ram = RAM::GetInstance();
67     std::map<std::string, std::string> procMemInfo;
68     procMemInfo = ram.GetSysRamInfo();
69     if (!procMemInfo.empty()) {
70         for (auto item : procMemInfo) {
71             if (item.first.find("memTotal") != std::string::npos) {
72                 ret = true;
73             }
74         }
75     }
76     EXPECT_TRUE(ret);
77 }
78 
79 HWTEST_F(RAMTest, GetRamInfoTest01, TestSize.Level1)
80 {
81     bool ret = false;
82     RAM &ram = RAM::GetInstance();
83     std::map<std::string, std::string> procMemInfo;
84     procMemInfo = ram.GetSysRamInfo();
85     if (!procMemInfo.empty()) {
86         for (auto item : procMemInfo) {
87             if (item.first.find("pss") != std::string::npos) {
88                 ret = true;
89             }
90         }
91     }
92     EXPECT_FALSE(false);
93 }
94 
95 }
96 }