mirror of
https://gitee.com/openharmony/xts_hats
synced 2024-12-04 21:29:07 +00:00
!762 【内核子系统】【master】新增GetRssByPid接口用例
Merge pull request !762 from 李猛/kernel_20230713_01_master
This commit is contained in:
commit
ea734f8dd3
@ -23,6 +23,7 @@ group("kernel") {
|
||||
deps = [
|
||||
"accesstokenid:HatsAccesstokenidTest",
|
||||
"dmabuffer:HatsDmaBufferTest",
|
||||
"libmeminfoPc:HatsMemInfoTest",
|
||||
"memtracker:HatsMemoryTrackerTest",
|
||||
"open_posix_testsuite/conformance/interfaces_gn:${posix_interface_module}",
|
||||
"prctl:HatsPrctlTest",
|
||||
@ -33,6 +34,7 @@ group("kernel") {
|
||||
"accesstokenid:HatsAccesstokenidTest",
|
||||
"dmabuffer:HatsDmaBufferTest",
|
||||
"freelist:HatsFreeListTest",
|
||||
"libmeminfoPc:HatsMemInfoTest",
|
||||
"memtracker:HatsMemoryTrackerTest",
|
||||
"open_posix_testsuite/conformance/interfaces_gn:${posix_interface_module}",
|
||||
"prctl:HatsPrctlTest",
|
||||
|
37
kernel/libmeminfoPc/BUILD.gn
Normal file
37
kernel/libmeminfoPc/BUILD.gn
Normal file
@ -0,0 +1,37 @@
|
||||
# Copyright (C) 2022-2023 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import("../../../tools/build/suite.gni")
|
||||
module_output_path = "hats/libmeminfoPc"
|
||||
|
||||
memoryinfo_external_deps = [
|
||||
"drivers_interface_memorytracker:libmemorytracker_proxy_1.0",
|
||||
"ipc:ipc_core",
|
||||
]
|
||||
|
||||
ohos_moduletest_suite("HatsMemInfoTest") {
|
||||
module_out_path = module_output_path
|
||||
sources = [ "./meminfo_test.cpp" ]
|
||||
|
||||
deps = [ "//third_party/googletest:gtest_main" ]
|
||||
external_deps = [
|
||||
"c_utils:utils",
|
||||
"memory_utils:libmeminfo",
|
||||
]
|
||||
if (is_standard_system) {
|
||||
external_deps += memoryinfo_external_deps
|
||||
}
|
||||
include_dirs = [ "include" ]
|
||||
cflags = [ "-Wno-error" ]
|
||||
subsystem_name = "kernel"
|
||||
}
|
18
kernel/libmeminfoPc/Test.json
Normal file
18
kernel/libmeminfoPc/Test.json
Normal file
@ -0,0 +1,18 @@
|
||||
{
|
||||
"description": "Configuration for HatsMemInfoTest Tests",
|
||||
"kits": [
|
||||
{
|
||||
"push": [
|
||||
"HatsMemInfoTest->/data/local/tmp/HatsMemInfoTest"
|
||||
],
|
||||
"type": "PushKit"
|
||||
}
|
||||
],
|
||||
"driver": {
|
||||
"native-test-timeout": "120000",
|
||||
"type": "CppTest",
|
||||
"module-name": "HatsMemInfoTest",
|
||||
"runtime-hint": "1s",
|
||||
"native-test-device-path": "/data/local/tmp"
|
||||
}
|
||||
}
|
86
kernel/libmeminfoPc/meminfo_test.cpp
Normal file
86
kernel/libmeminfoPc/meminfo_test.cpp
Normal file
@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "meminfo.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace MemInfo {
|
||||
using namespace testing;
|
||||
using namespace testing::ext;
|
||||
|
||||
class MemInfoTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase();
|
||||
static void TearDownTestCase();
|
||||
void SetUp();
|
||||
void TearDown();
|
||||
};
|
||||
|
||||
void MemInfoTest::SetUpTestCase()
|
||||
{
|
||||
}
|
||||
|
||||
void MemInfoTest::TearDownTestCase()
|
||||
{
|
||||
}
|
||||
|
||||
void MemInfoTest::SetUp()
|
||||
{
|
||||
}
|
||||
|
||||
void MemInfoTest::TearDown()
|
||||
{
|
||||
}
|
||||
|
||||
HWTEST_F(MemInfoTest, GetRssByPid_Test_001, TestSize.Level1)
|
||||
{
|
||||
int pid = 1;
|
||||
uint64_t size = 0;
|
||||
size = GetRssByPid(pid);
|
||||
std::cout << "size = " << size << std::endl;
|
||||
ASSERT_EQ(size > 0, true);
|
||||
}
|
||||
|
||||
HWTEST_F(MemInfoTest, GetRssByPid_Test_002, TestSize.Level1)
|
||||
{
|
||||
int pid = -1;
|
||||
uint64_t size = 0;
|
||||
size = GetRssByPid(pid);
|
||||
ASSERT_EQ(size == 0, true);
|
||||
}
|
||||
|
||||
HWTEST_F(MemInfoTest, GetPssByPid_Test_001, TestSize.Level1)
|
||||
{
|
||||
int pid = 1;
|
||||
uint64_t size = 0;
|
||||
size = GetPssByPid(pid);
|
||||
std::cout << "size = " << size << std::endl;
|
||||
system("hidumper --mem 1");
|
||||
system("cat /proc/1/smaps_rollup");
|
||||
ASSERT_EQ(size > 0, true);
|
||||
}
|
||||
|
||||
HWTEST_F(MemInfoTest, GetPssByPid_Test_002, TestSize.Level1)
|
||||
{
|
||||
int pid = -1;
|
||||
uint64_t size = 0;
|
||||
size = GetPssByPid(pid);
|
||||
ASSERT_EQ(size == 0, true);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user