Compare commits
No commits in common. 'main' and 'panjiayan_branch' have entirely different histories.
main
...
panjiayan_
@ -1,60 +0,0 @@
|
|||||||
# Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved.
|
|
||||||
#
|
|
||||||
# Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
# are permitted provided that the following conditions are met:
|
|
||||||
#
|
|
||||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
|
||||||
# conditions and the following disclaimer.
|
|
||||||
#
|
|
||||||
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
|
||||||
# of conditions and the following disclaimer in the documentation and/or other materials
|
|
||||||
# provided with the distribution.
|
|
||||||
#
|
|
||||||
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
|
||||||
# to endorse or promote products derived from this software without specific prior written
|
|
||||||
# permission.
|
|
||||||
#
|
|
||||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
||||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
|
||||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
||||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
|
||||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
import("//kernel/liteos_a/testsuites/unittest/config.gni")
|
|
||||||
|
|
||||||
netdb_include_dirs = [ "$TEST_UNITTEST_DIR/net/netdb" ]
|
|
||||||
|
|
||||||
netdb_sources_entry = [ "$TEST_UNITTEST_DIR/net/netdb/net_netdb_test.cpp" ]
|
|
||||||
|
|
||||||
netdb_sources_smoke = [
|
|
||||||
"$TEST_UNITTEST_DIR/net/netdb/smoke/net_netdb_test_001.cpp",
|
|
||||||
"$TEST_UNITTEST_DIR/net/netdb/smoke/net_netdb_test_013.cpp",
|
|
||||||
]
|
|
||||||
|
|
||||||
netdb_sources_full = [
|
|
||||||
"$TEST_UNITTEST_DIR/net/netdb/full/net_netdb_test_002.cpp",
|
|
||||||
"$TEST_UNITTEST_DIR/net/netdb/full/net_netdb_test_003.cpp",
|
|
||||||
"$TEST_UNITTEST_DIR/net/netdb/full/net_netdb_test_004.cpp",
|
|
||||||
"$TEST_UNITTEST_DIR/net/netdb/full/net_netdb_test_005.cpp",
|
|
||||||
"$TEST_UNITTEST_DIR/net/netdb/full/net_netdb_test_006.cpp",
|
|
||||||
"$TEST_UNITTEST_DIR/net/netdb/full/net_netdb_test_007.cpp",
|
|
||||||
"$TEST_UNITTEST_DIR/net/netdb/full/net_netdb_test_008.cpp",
|
|
||||||
"$TEST_UNITTEST_DIR/net/netdb/full/net_netdb_test_009.cpp",
|
|
||||||
"$TEST_UNITTEST_DIR/net/netdb/full/net_netdb_test_010.cpp",
|
|
||||||
"$TEST_UNITTEST_DIR/net/netdb/full/net_netdb_test_011.cpp",
|
|
||||||
"$TEST_UNITTEST_DIR/net/netdb/full/net_netdb_test_012.cpp",
|
|
||||||
"$TEST_UNITTEST_DIR/net/netdb/full/net_netdb_test_015.cpp",
|
|
||||||
"$TEST_UNITTEST_DIR/net/netdb/full/net_netdb_test_016.cpp",
|
|
||||||
"$TEST_UNITTEST_DIR/net/netdb/full/net_netdb_test_017.cpp",
|
|
||||||
"$TEST_UNITTEST_DIR/net/netdb/full/net_netdb_test_018.cpp",
|
|
||||||
"$TEST_UNITTEST_DIR/net/netdb/full/net_netdb_test_019.cpp",
|
|
||||||
"$TEST_UNITTEST_DIR/net/netdb/full/net_netdb_test_020.cpp",
|
|
||||||
"$TEST_UNITTEST_DIR/net/netdb/full/net_netdb_test_021.cpp",
|
|
||||||
"$TEST_UNITTEST_DIR/net/netdb/full/net_netdb_test_022.cpp",
|
|
||||||
]
|
|
@ -1,123 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
|
||||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
* are permitted provided that the following conditions are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
|
||||||
* conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
|
||||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
|
||||||
* provided with the distribution.
|
|
||||||
*
|
|
||||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
|
||||||
* to endorse or promote products derived from this software without specific prior written
|
|
||||||
* permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
|
||||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
||||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
|
||||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
#include "it_pthread_test.h" // 包含测试框架的头文件
|
|
||||||
|
|
||||||
// 全局变量定义
|
|
||||||
static int g_number = 0; // 用于记录 InitRoutine 被调用的次数
|
|
||||||
static int g_okStatus = 777; // 定义一个特殊的状态值,表示状态正常
|
|
||||||
static pthread_once_t g_onceCtrl = PTHREAD_ONCE_INIT; // pthread_once 的控制变量,初始化为未执行状态
|
|
||||||
|
|
||||||
// 初始化函数,每次调用都会增加 g_number 的值
|
|
||||||
static void InitRoutine(void)
|
|
||||||
{
|
|
||||||
g_number++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 线程函数,测试 pthread_once 的行为
|
|
||||||
static void *Threadfunc(void *parm)
|
|
||||||
{
|
|
||||||
int err;
|
|
||||||
// 确保 InitRoutine 只被调用一次
|
|
||||||
err = pthread_once(&g_onceCtrl, InitRoutine);
|
|
||||||
ICUNIT_GOTO_EQUAL(err, 0, err, EXIT); // 使用测试框架的宏检查 pthread_once 的返回值是否为 0
|
|
||||||
return reinterpret_cast<void *>(g_okStatus); // 返回状态值
|
|
||||||
EXIT:
|
|
||||||
return NULL; // 出错时返回 NULL
|
|
||||||
}
|
|
||||||
|
|
||||||
// 测试函数,创建多个线程并检查 pthread_once 的行为
|
|
||||||
static void *ThreadFuncTest(void *arg)
|
|
||||||
{
|
|
||||||
pthread_t thread[3]; // 定义线程数组,用于存储线程 ID
|
|
||||||
int rc = 0; // 用于存储线程创建和加入的返回值
|
|
||||||
int i = 3; // 循环变量,但立即被重新赋值,这里可能是代码风格问题
|
|
||||||
void *status; // 用于存储线程函数的返回值
|
|
||||||
const int threadsNum = 3; // 定义线程数量
|
|
||||||
|
|
||||||
g_number = 0; // 重置全局计数器
|
|
||||||
|
|
||||||
// 创建多个线程
|
|
||||||
for (i = 0; i < threadsNum; ++i) {
|
|
||||||
rc = pthread_create(&thread[i], NULL, Threadfunc, NULL);
|
|
||||||
ICUNIT_GOTO_EQUAL(rc, 0, rc, EXIT); // 检查 pthread_create 的返回值
|
|
||||||
}
|
|
||||||
|
|
||||||
// 等待所有线程结束
|
|
||||||
for (i = 0; i < threadsNum; ++i) {
|
|
||||||
rc = pthread_join(thread[i], &status);
|
|
||||||
ICUNIT_GOTO_EQUAL(rc, 0, rc, EXIT); // 检查 pthread_join 的返回值
|
|
||||||
ICUNIT_GOTO_EQUAL((unsigned int)status, (unsigned int)g_okStatus, status, EXIT); // 检查线程函数的返回值
|
|
||||||
}
|
|
||||||
|
|
||||||
// 检查 InitRoutine 是否只被调用了一次
|
|
||||||
ICUNIT_GOTO_EQUAL(g_number, 1, g_number, EXIT);
|
|
||||||
|
|
||||||
EXIT:
|
|
||||||
return NULL; // 出错时返回 NULL
|
|
||||||
}
|
|
||||||
|
|
||||||
// 测试用例函数,设置线程属性并启动测试线程
|
|
||||||
static int Testcase(void)
|
|
||||||
{
|
|
||||||
int ret; // 用于存储函数调用的返回值
|
|
||||||
pthread_t newPthread; // 定义新线程的 ID
|
|
||||||
int curThreadPri, curThreadPolicy; // 用于存储当前线程的调度策略和优先级
|
|
||||||
pthread_attr_t a = { 0 }; // 定义线程属性对象并初始化
|
|
||||||
struct sched_param param = { 0 }; // 定义调度参数对象并初始化
|
|
||||||
|
|
||||||
g_onceCtrl = PTHREAD_ONCE_INIT; // 重置 pthread_once 的控制变量
|
|
||||||
|
|
||||||
// 获取当前线程的调度策略和优先级
|
|
||||||
ret = pthread_getschedparam(pthread_self(), &curThreadPolicy, ¶m);
|
|
||||||
ICUNIT_ASSERT_EQUAL(ret, 0, -ret); // 检查 pthread_getschedparam 的返回值
|
|
||||||
|
|
||||||
curThreadPri = param.sched_priority; // 获取当前线程的优先级
|
|
||||||
|
|
||||||
// 设置新线程的属性
|
|
||||||
ret = pthread_attr_init(&a); // 初始化线程属性
|
|
||||||
pthread_attr_setinheritsched(&a, PTHREAD_EXPLICIT_SCHED); // 设置线程继承调度策略为显式
|
|
||||||
param.sched_priority = curThreadPri + 2; // 设置新线程的优先级为当前线程优先级加 2
|
|
||||||
pthread_attr_setschedparam(&a, ¶m); // 设置线程调度参数
|
|
||||||
ret = pthread_create(&newPthread, &a, ThreadFuncTest, 0); // 创建新线程并运行测试函数
|
|
||||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret); // 检查 pthread_create 的返回值
|
|
||||||
|
|
||||||
// 等待新线程结束
|
|
||||||
ret = pthread_join(newPthread, NULL);
|
|
||||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret); // 检查 pthread_join 的返回值
|
|
||||||
|
|
||||||
return 0; // 测试成功结束
|
|
||||||
}
|
|
||||||
|
|
||||||
// 注册测试用例
|
|
||||||
void ItTestPthreadOnce001(void)
|
|
||||||
{
|
|
||||||
TEST_ADD_CASE("IT_PTHREAD_ONCE_001", Testcase, TEST_POSIX, TEST_MEM, TEST_LEVEL0, TEST_FUNCTION); // 使用测试框架的宏注册测试用例
|
|
||||||
}
|
|
@ -1,100 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
* are permitted provided that the following conditions are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
|
||||||
* conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
|
||||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
|
||||||
* provided with the distribution.
|
|
||||||
*
|
|
||||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
|
||||||
* to endorse or promote products derived from this software without specific prior written
|
|
||||||
* permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
|
||||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
||||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
|
||||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
#include <cstdio>
|
|
||||||
#include <cstdlib>
|
|
||||||
#include <climits>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <gtest/gtest.h>
|
|
||||||
#include <dirent.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <vector>
|
|
||||||
#include <cstring>
|
|
||||||
#include "It_process_plimits.h"
|
|
||||||
|
|
||||||
//write function to get process file mode
|
|
||||||
static std::string GetFileMode(const char* filePath)
|
|
||||||
{
|
|
||||||
const int MODE_COUNT = 11;
|
|
||||||
char fileProperty[MODE_COUNT] = "----------";
|
|
||||||
char fileMode[MODE_COUNT] = "-rwxrwxrwx";
|
|
||||||
struct stat buf;
|
|
||||||
stat(filePath, &buf);//get state of the file
|
|
||||||
unsigned int off = 256;
|
|
||||||
const int LOOP_VARY = 10;
|
|
||||||
for (int i = 1; i < LOOP_VARY; i++) {
|
|
||||||
if (buf.st_mode & (off >> (i - 1))) {
|
|
||||||
fileProperty[i] = fileMode[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return fileProperty;
|
|
||||||
}
|
|
||||||
|
|
||||||
//check the Property
|
|
||||||
static int IsFilePropertyR1(const char* filePath)
|
|
||||||
{
|
|
||||||
std::string fileOrg = "-r--r--r--";
|
|
||||||
std::string fileProperty = GetFileMode(filePath);
|
|
||||||
return strcmp(fileProperty.c_str(), fileOrg.c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
void ItProcessPlimits008(void)
|
|
||||||
{
|
|
||||||
//define process function ID
|
|
||||||
std::string filePath = "/proc/plimits/";
|
|
||||||
std::vector<std::string> fileName;
|
|
||||||
fileName.push_back("plimits.procs");
|
|
||||||
fileName.push_back("plimits.limiters");
|
|
||||||
fileName.push_back("pids.max");
|
|
||||||
fileName.push_back("sched.period");
|
|
||||||
fileName.push_back("sched.quota");
|
|
||||||
fileName.push_back("sched.stat");
|
|
||||||
fileName.push_back("memory.failcnt");
|
|
||||||
fileName.push_back("memory.limit");
|
|
||||||
fileName.push_back("memory.peak");
|
|
||||||
fileName.push_back("memory.usage");
|
|
||||||
fileName.push_back("memory.stat");
|
|
||||||
|
|
||||||
for (auto iter = fileName.begin(); iter != fileName.end(); ++iter) {
|
|
||||||
std::string fileFullPath = filePath + *iter;
|
|
||||||
int ret = IsFilePropertyR1(fileFullPath.c_str());
|
|
||||||
ASSERT_EQ(ret, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*It is used primarily to verify access to specific files in
|
|
||||||
the /proc/plimit/directory, ensuring that these files are read-only
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,59 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
* are permitted provided that the following conditions are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
|
||||||
* conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
|
||||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
|
||||||
* provided with the distribution.
|
|
||||||
*
|
|
||||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
|
||||||
* to endorse or promote products derived from this software without specific prior written
|
|
||||||
* permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
|
||||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
||||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
|
||||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <cstdio>
|
|
||||||
#include <cstdlib>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <cstring>
|
|
||||||
#include <gtest/gtest.h>
|
|
||||||
#include "It_process_plimits.h"
|
|
||||||
|
|
||||||
void ItProcessPlimitsIpc002(void)
|
|
||||||
{
|
|
||||||
mode_t mode;
|
|
||||||
int ret;
|
|
||||||
int fd;
|
|
||||||
std::string plimitsRootPath = "/proc/plimits/";
|
|
||||||
std::vector<std::string> ipcConfFileName;
|
|
||||||
ipcConfFileName.push_back("ipc.mq_limit");
|
|
||||||
ipcConfFileName.push_back("ipc.shm_limit");
|
|
||||||
ipcConfFileName.push_back("ipc.stat");
|
|
||||||
|
|
||||||
for (auto iter = ipcConfFileName.begin(); iter != ipcConfFileName.end(); ++iter) {
|
|
||||||
std::string fullPath = plimitsRootPath + *iter;
|
|
||||||
fd = access(fullPath.c_str(), W_OK | X_OK);
|
|
||||||
ASSERT_EQ(fd, -1);
|
|
||||||
fd = access(fullPath.c_str(), F_OK | R_OK);
|
|
||||||
ASSERT_EQ(fd, 0);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
@ -1,67 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
* are permitted provided that the following conditions are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
|
||||||
* conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
|
||||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
|
||||||
* provided with the distribution.
|
|
||||||
*
|
|
||||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
|
||||||
* to endorse or promote products derived from this software without specific prior written
|
|
||||||
* permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
|
||||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
||||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
|
||||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <cstdio>
|
|
||||||
#include <cstdlib>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <cstring>
|
|
||||||
#include <gtest/gtest.h>
|
|
||||||
#include "It_process_plimits.h"
|
|
||||||
|
|
||||||
void ItProcessPlimitsIpc003(void)
|
|
||||||
{
|
|
||||||
mode_t mode;
|
|
||||||
int ret;
|
|
||||||
std::string plimitsPath = "/proc/plimits/test";
|
|
||||||
std::string configFileMqCount = "/proc/plimits/test/ipc.mq_limit";
|
|
||||||
std::string configFileShmSize = "/proc/plimits/test/ipc.shm_limit";
|
|
||||||
std::string configFileStat = "/proc/plimits/test/ipc.stat";
|
|
||||||
|
|
||||||
ret = mkdir(plimitsPath.c_str(), S_IFDIR | mode);
|
|
||||||
ASSERT_EQ(ret, 0);
|
|
||||||
|
|
||||||
int fd = access(configFileMqCount.c_str(), F_OK | W_OK | R_OK);
|
|
||||||
ASSERT_EQ(fd, 0);
|
|
||||||
|
|
||||||
fd = access(configFileShmSize.c_str(), F_OK | W_OK | R_OK);
|
|
||||||
ASSERT_EQ(fd, 0);
|
|
||||||
|
|
||||||
fd = access(configFileStat.c_str(), F_OK | R_OK);
|
|
||||||
ASSERT_EQ(fd, 0);
|
|
||||||
|
|
||||||
fd = access(configFileStat.c_str(), W_OK | X_OK);
|
|
||||||
ASSERT_EQ(fd, -1);
|
|
||||||
|
|
||||||
ret = rmdir(plimitsPath.c_str());
|
|
||||||
ASSERT_EQ(ret, 0);
|
|
||||||
return;
|
|
||||||
}
|
|
@ -1,72 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
* are permitted provided that the following conditions are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
|
||||||
* conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
|
||||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
|
||||||
* provided with the distribution.
|
|
||||||
*
|
|
||||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
|
||||||
* to endorse or promote products derived from this software without specific prior written
|
|
||||||
* permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
|
||||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
||||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
|
||||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <cstdio>
|
|
||||||
#include <cstdlib>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <cstring>
|
|
||||||
#include <gtest/gtest.h>
|
|
||||||
#include "It_process_plimits.h"
|
|
||||||
|
|
||||||
void ItProcessPlimitsIpc004(void)
|
|
||||||
{
|
|
||||||
mode_t mode;
|
|
||||||
mode_t chmodMode = 0777;
|
|
||||||
int ret;
|
|
||||||
int fd;
|
|
||||||
std::string rootplimitsPath = "/proc/plimits";
|
|
||||||
std::string subPlimitsPath = "/proc/plimits/test";
|
|
||||||
|
|
||||||
std::vector<std::string> ipcConfFileName;
|
|
||||||
ipcConfFileName.push_back("ipc.mq_limit");
|
|
||||||
ipcConfFileName.push_back("ipc.shm_limit");
|
|
||||||
ipcConfFileName.push_back("ipc.stat");
|
|
||||||
|
|
||||||
ret = mkdir(subPlimitsPath.c_str(), S_IFDIR | mode);
|
|
||||||
ASSERT_EQ(ret, 0);
|
|
||||||
|
|
||||||
for (auto iter = ipcConfFileName.begin(); iter != ipcConfFileName.end(); ++iter) {
|
|
||||||
std::string fullPath = rootplimitsPath + "/" + *iter;
|
|
||||||
ret = chmod(fullPath.c_str(), mode);
|
|
||||||
ASSERT_EQ(ret, -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (auto iter = ipcConfFileName.begin(); iter != ipcConfFileName.end(); ++iter) {
|
|
||||||
std::string fullPath = subPlimitsPath + "/" + *iter;
|
|
||||||
ret = chmod(fullPath.c_str(), mode);
|
|
||||||
ASSERT_EQ(ret, -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = rmdir(subPlimitsPath.c_str());
|
|
||||||
ASSERT_EQ(ret, 0);
|
|
||||||
return;
|
|
||||||
}
|
|
@ -1,85 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
* are permitted provided that the following conditions are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
|
||||||
* conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
|
||||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
|
||||||
* provided with the distribution.
|
|
||||||
*
|
|
||||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
|
||||||
* to endorse or promote products derived from this software without specific prior written
|
|
||||||
* permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
|
||||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
||||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
|
||||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <cstdio>
|
|
||||||
#include <cstdlib>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <cstring>
|
|
||||||
#include <mqueue.h>
|
|
||||||
#include <gtest/gtest.h>
|
|
||||||
#include "It_process_plimits.h"
|
|
||||||
|
|
||||||
static const int g_buffSize = 512;
|
|
||||||
static const int g_arryLen = 4;
|
|
||||||
static const int MQ_MAX_PER_PROCESS_COUNT = 255;
|
|
||||||
static const int MQUEUE_STANDARD_NAME_LENGTH = 50;
|
|
||||||
|
|
||||||
void ItProcessPlimitsIpc005(void)
|
|
||||||
{
|
|
||||||
INT32 ret;
|
|
||||||
mode_t mode;
|
|
||||||
char buf[g_buffSize] = { 0 };
|
|
||||||
CHAR mqname[MQUEUE_STANDARD_NAME_LENGTH] = "";
|
|
||||||
mqd_t mqueue[MQ_MAX_PER_PROCESS_COUNT];
|
|
||||||
struct mq_attr attr = { 0 };
|
|
||||||
int index = 0;
|
|
||||||
attr.mq_msgsize = MQUEUE_STANDARD_NAME_LENGTH;
|
|
||||||
attr.mq_maxmsg = 1;
|
|
||||||
|
|
||||||
std::string plimitsPath = "/proc/plimits/test";
|
|
||||||
|
|
||||||
ret = mkdir(plimitsPath.c_str(), S_IFDIR | mode);
|
|
||||||
ASSERT_EQ(ret, 0);
|
|
||||||
|
|
||||||
ret = ReadFile("/proc/plimits/test/ipc.mq_limit", buf);
|
|
||||||
ASSERT_STREQ(buf, "1024\n");
|
|
||||||
|
|
||||||
for (index = 0; index < MQ_MAX_PER_PROCESS_COUNT; ++index) {
|
|
||||||
ret = snprintf_s(mqname, sizeof(mqname), MQUEUE_STANDARD_NAME_LENGTH, "/mq_005_%d_%d",
|
|
||||||
index, LosCurTaskIDGet());
|
|
||||||
ASSERT_NE(ret, -1);
|
|
||||||
mqueue[index] = mq_open(mqname, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, &attr);
|
|
||||||
ASSERT_NE(mqueue[index], (mqd_t)-1);
|
|
||||||
}
|
|
||||||
for (int k = 0; k < MQ_MAX_PER_PROCESS_COUNT; ++k) {
|
|
||||||
ret = mq_close(mqueue[k]);
|
|
||||||
ASSERT_NE(ret, -1);
|
|
||||||
ret = snprintf_s(mqname, sizeof(mqname), MQUEUE_STANDARD_NAME_LENGTH, "/mq_005_%d_%d", k, LosCurTaskIDGet());
|
|
||||||
ASSERT_NE(ret, -1);
|
|
||||||
ret = mq_unlink(mqname);
|
|
||||||
ASSERT_EQ(ret, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = rmdir(plimitsPath.c_str());
|
|
||||||
ASSERT_EQ(ret, 0);
|
|
||||||
return;
|
|
||||||
}
|
|
@ -1,119 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
* are permitted provided that the following conditions are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
|
||||||
* conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
|
||||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
|
||||||
* provided with the distribution.
|
|
||||||
*
|
|
||||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
|
||||||
* to endorse or promote products derived from this software without specific prior written
|
|
||||||
* permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
|
||||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
||||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
|
||||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <cstdio>
|
|
||||||
#include <cstdlib>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <cstring>
|
|
||||||
#include <mqueue.h>
|
|
||||||
#include <gtest/gtest.h>
|
|
||||||
#include "It_process_plimits.h"
|
|
||||||
|
|
||||||
static const int MQUEUE_STANDARD_NAME_LENGTH = 50;
|
|
||||||
static const int g_buffSize = 512;
|
|
||||||
static const int g_arryLen = 4;
|
|
||||||
static const int g_readLen = 254;
|
|
||||||
static const int MQ_MAX_LIMIT_COUNT = 10;
|
|
||||||
|
|
||||||
static int FreeResource(mqd_t *mqueue, int index, char *mqname)
|
|
||||||
{
|
|
||||||
int ret = -1;
|
|
||||||
for (int k = 0; k < index; ++k) {
|
|
||||||
if (snprintf_s(mqname, MQUEUE_STANDARD_NAME_LENGTH, MQUEUE_STANDARD_NAME_LENGTH, "/mq_006_%d_%d",
|
|
||||||
k, LosCurTaskIDGet()) < 0) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
ret = mq_close(mqueue[k]);
|
|
||||||
if (ret != 0) {
|
|
||||||
return -2; /* 2: errno */
|
|
||||||
}
|
|
||||||
ret = mq_unlink(mqname);
|
|
||||||
if (ret != 0) {
|
|
||||||
return -3; /* 3: errno */
|
|
||||||
}
|
|
||||||
(void)memset_s(mqname, MQUEUE_STANDARD_NAME_LENGTH, 0, MQUEUE_STANDARD_NAME_LENGTH);
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
// plimits_ipc_07, plimits_ipc_14, plimits_ipc_17
|
|
||||||
void ItProcessPlimitsIpc006(void)
|
|
||||||
{
|
|
||||||
INT32 ret;
|
|
||||||
mode_t mode;
|
|
||||||
char buf[g_buffSize] = { 0 };
|
|
||||||
char *array[g_arryLen] = { nullptr };
|
|
||||||
int mqSuccessCount = -1, mqFailedCount = -1;
|
|
||||||
CHAR mqname[MQUEUE_STANDARD_NAME_LENGTH] = "";
|
|
||||||
mqd_t mqueue[g_readLen];
|
|
||||||
std::string subPlimitsPath = "/proc/plimits/test";
|
|
||||||
std::string configFileMqCount = "/proc/plimits/test/ipc.mq_limit";
|
|
||||||
std::string limitMqCount = "10";
|
|
||||||
struct mq_attr attr = { 0 };
|
|
||||||
attr.mq_msgsize = MQUEUE_STANDARD_NAME_LENGTH;
|
|
||||||
attr.mq_maxmsg = 1;
|
|
||||||
int index = 0;
|
|
||||||
|
|
||||||
ret = mkdir(subPlimitsPath.c_str(), S_IFDIR | mode);
|
|
||||||
ASSERT_EQ(ret, 0);
|
|
||||||
|
|
||||||
ret = WriteFile(configFileMqCount.c_str(), limitMqCount.c_str());
|
|
||||||
ASSERT_NE(ret, -1);
|
|
||||||
|
|
||||||
for (index = 0; index < MQ_MAX_LIMIT_COUNT; ++index) {
|
|
||||||
ret = snprintf_s(mqname, sizeof(mqname), MQUEUE_STANDARD_NAME_LENGTH, "/mq_006_%d_%d",
|
|
||||||
index, LosCurTaskIDGet());
|
|
||||||
ASSERT_NE(ret, -1);
|
|
||||||
mqueue[index] = mq_open(mqname, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, &attr);
|
|
||||||
ASSERT_NE(mqueue[index], (mqd_t)-1);
|
|
||||||
(void)memset_s(mqname, sizeof(mqname), 0, sizeof(mqname));
|
|
||||||
}
|
|
||||||
ret = snprintf_s(mqname, sizeof(mqname), MQUEUE_STANDARD_NAME_LENGTH, "/mq_006_%d_%d", index, LosCurTaskIDGet());
|
|
||||||
ASSERT_NE(ret, -1);
|
|
||||||
mqueue[index] = mq_open(mqname, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, &attr);
|
|
||||||
ASSERT_EQ(mqueue[index], (mqd_t)-1);
|
|
||||||
(void)memset_s(mqname, sizeof(mqname), 0, sizeof(mqname));
|
|
||||||
|
|
||||||
ret = ReadFile("/proc/plimits/test/ipc.stat", buf);
|
|
||||||
printf("/proc/plimits/test/ipc.stat: %s\n", buf);
|
|
||||||
GetLine(buf, g_arryLen, g_readLen, array);
|
|
||||||
mqSuccessCount = atoi(array[0] + strlen("mq count: "));
|
|
||||||
mqFailedCount = atoi((array[1] + strlen("mq failed count: ")));
|
|
||||||
ASSERT_EQ(mqSuccessCount, MQ_MAX_LIMIT_COUNT);
|
|
||||||
ASSERT_EQ(mqFailedCount, 1);
|
|
||||||
ret = FreeResource(mqueue, index, mqname);
|
|
||||||
ASSERT_EQ(ret, 0);
|
|
||||||
|
|
||||||
ret = rmdir(subPlimitsPath.c_str());
|
|
||||||
ASSERT_EQ(ret, 0);
|
|
||||||
return;
|
|
||||||
}
|
|
@ -1,57 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
* are permitted provided that the following conditions are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
|
||||||
* conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
|
||||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
|
||||||
* provided with the distribution.
|
|
||||||
*
|
|
||||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
|
||||||
* to endorse or promote products derived from this software without specific prior written
|
|
||||||
* permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
|
||||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
||||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
|
||||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <cstdio>
|
|
||||||
#include <cstdlib>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <cstring>
|
|
||||||
#include <gtest/gtest.h>
|
|
||||||
#include "It_process_plimits.h"
|
|
||||||
|
|
||||||
void ItProcessPlimitsIpc007(void)
|
|
||||||
{
|
|
||||||
mode_t mode;
|
|
||||||
int ret;
|
|
||||||
std::string plimitsPath = "/proc/plimits/test";
|
|
||||||
std::string configFileMqCount = "/proc/plimits/test/ipc.mq_limit";
|
|
||||||
std::string mqLimitCount = "0123";
|
|
||||||
|
|
||||||
ret = mkdir(plimitsPath.c_str(), S_IFDIR | mode);
|
|
||||||
ASSERT_EQ(ret, 0);
|
|
||||||
|
|
||||||
ret = WriteFile(configFileMqCount.c_str(), mqLimitCount.c_str());
|
|
||||||
ASSERT_NE(ret, -1);
|
|
||||||
|
|
||||||
ret = rmdir(plimitsPath.c_str());
|
|
||||||
ASSERT_EQ(ret, 0);
|
|
||||||
return;
|
|
||||||
}
|
|
@ -1,56 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
|
||||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
* are permitted provided that the following conditions are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
|
||||||
* conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
|
||||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
|
||||||
* provided with the distribution.
|
|
||||||
*
|
|
||||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
|
||||||
* to endorse or promote products derived from this software without specific prior written
|
|
||||||
* permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
|
||||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
||||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
|
||||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
#include "stdio.h"
|
|
||||||
#include <climits>
|
|
||||||
#include <gtest/gtest.h>
|
|
||||||
|
|
||||||
#include "it_test_capability.h"
|
|
||||||
|
|
||||||
using namespace testing::ext;
|
|
||||||
namespace OHOS {
|
|
||||||
class SecurityCapabilityTest : public testing::Test {
|
|
||||||
public:
|
|
||||||
static void SetUpTestCase(void) {}
|
|
||||||
static void TearDownTestCase(void) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
#if defined(LOSCFG_USER_TEST_SMOKE)
|
|
||||||
/**
|
|
||||||
* @tc.name: It_Test_Cap_001
|
|
||||||
* @tc.desc: function for SecurityCapbilityTest
|
|
||||||
* @tc.type: FUNC
|
|
||||||
*/
|
|
||||||
HWTEST_F(SecurityCapabilityTest, ItTestCap001, TestSize.Level0)
|
|
||||||
{
|
|
||||||
ItTestCap001();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
} // namespace OHOS
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in new issue