|
|
|
@ -28,6 +28,242 @@
|
|
|
|
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
|
|
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
*/
|
|
|
|
|
// 包含标准输入输出头文件
|
|
|
|
|
#include "stdio.h"
|
|
|
|
|
// 包含C标准库中的极限定义
|
|
|
|
|
#include <climits>
|
|
|
|
|
// 包含Google Test测试框架头文件
|
|
|
|
|
#include <gtest/gtest.h>
|
|
|
|
|
// 包含自定义的pthread测试头文件
|
|
|
|
|
#include "it_pthread_test.h"
|
|
|
|
|
// 包含系统资源库头文件
|
|
|
|
|
#include <sys/resource.h>
|
|
|
|
|
|
|
|
|
|
// 使用Google Test框架的扩展命名空间
|
|
|
|
|
using namespace testing::ext;
|
|
|
|
|
|
|
|
|
|
// 定义一个名为OHOS的命名空间,用于封装测试代码
|
|
|
|
|
namespace OHOS {
|
|
|
|
|
// 定义一个测试类ProcessPthreadTest,它继承自Google Test框架的Test类
|
|
|
|
|
class ProcessPthreadTest : public testing::Test {
|
|
|
|
|
public:
|
|
|
|
|
// 测试套件开始前调用的静态成员函数,用于设置测试环境
|
|
|
|
|
static void SetUpTestCase(void) {
|
|
|
|
|
struct sched_param param = { 0 }; // 定义调度参数结构体
|
|
|
|
|
int currThreadPolicy, ret; // 定义当前线程策略和返回值变量
|
|
|
|
|
// 获取当前线程的调度参数
|
|
|
|
|
ret = pthread_getschedparam(pthread_self(), &currThreadPolicy, ¶m);
|
|
|
|
|
// 断言返回值为0,如果不为0则用-ret作为错误码
|
|
|
|
|
ICUNIT_ASSERT_EQUAL_VOID(ret, 0, -ret);
|
|
|
|
|
// 设置线程的调度优先级
|
|
|
|
|
param.sched_priority = TASK_PRIO_TEST;
|
|
|
|
|
// 设置当前线程的调度参数
|
|
|
|
|
ret = pthread_setschedparam(pthread_self(), SCHED_RR, ¶m);
|
|
|
|
|
// 断言返回值为0,如果不为0则用-ret作为错误码
|
|
|
|
|
ICUNIT_ASSERT_EQUAL_VOID(ret, 0, -ret);
|
|
|
|
|
}
|
|
|
|
|
// 测试套件结束后调用的静态成员函数,用于清理测试环境(这里为空实现)
|
|
|
|
|
static void TearDownTestCase(void) {}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#if defined(LOSCFG_USER_TEST_SMOKE)
|
|
|
|
|
// 如果定义了LOSCFG_USER_TEST_SMOKE,则编译并执行以下测试用例
|
|
|
|
|
/* *
|
|
|
|
|
* @tc.name: it_test_pthread_003
|
|
|
|
|
* @tc.desc: function for ProcessPthreadTest
|
|
|
|
|
* @tc.type: FUNC
|
|
|
|
|
*/
|
|
|
|
|
// 定义测试用例ItTestPthread003
|
|
|
|
|
HWTEST_F(ProcessPthreadTest, ItTestPthread003, TestSize.Level0) {
|
|
|
|
|
ItTestPthread003();
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef LOSCFG_USER_TEST_SMP
|
|
|
|
|
// 如果未定义LOSCFG_USER_TEST_SMP,则编译并执行以下测试用例
|
|
|
|
|
/* *
|
|
|
|
|
* @tc.name: it_test_pthread_006
|
|
|
|
|
* @tc.desc: function for ProcessPthreadTest
|
|
|
|
|
* @tc.type: FUNC
|
|
|
|
|
*/
|
|
|
|
|
// 定义测试用例ItTestPthread006
|
|
|
|
|
HWTEST_F(ProcessPthreadTest, ItTestPthread006, TestSize.Level0) {
|
|
|
|
|
ItTestPthread006();
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
// 以下是其他测试用例的定义,每个测试用例都有相应的注释说明其功能和类型
|
|
|
|
|
/* *
|
|
|
|
|
* @tc.name: it_test_pthread_007
|
|
|
|
|
* @tc.desc: function for ProcessPthreadTest
|
|
|
|
|
* @tc.type: FUNC
|
|
|
|
|
*/
|
|
|
|
|
HWTEST_F(ProcessPthreadTest, ItTestPthread007, TestSize.Level0) {
|
|
|
|
|
ItTestPthread007();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* *
|
|
|
|
|
* @tc.name: it_test_pthread_008
|
|
|
|
|
* @tc.desc: function for ProcessPthreadTest
|
|
|
|
|
* @tc.type: FUNC
|
|
|
|
|
*/
|
|
|
|
|
HWTEST_F(ProcessPthreadTest, ItTestPthread008, TestSize.Level0) {
|
|
|
|
|
ItTestPthread008();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* *
|
|
|
|
|
* @tc.name: it_test_pthread_009
|
|
|
|
|
* @tc.desc: function for ProcessPthreadTest
|
|
|
|
|
* @tc.type: FUNC
|
|
|
|
|
*/
|
|
|
|
|
HWTEST_F(ProcessPthreadTest, ItTestPthread009, TestSize.Level0) {
|
|
|
|
|
ItTestPthread009();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifndef LOSCFG_USER_TEST_SMP
|
|
|
|
|
/* *
|
|
|
|
|
* @tc.name: it_test_pthread_010
|
|
|
|
|
* @tc.desc: function for ProcessPthreadTest
|
|
|
|
|
* @tc.type: FUNC
|
|
|
|
|
*/
|
|
|
|
|
HWTEST_F(ProcessPthreadTest, ItTestPthread010, TestSize.Level0) {
|
|
|
|
|
ItTestPthread010();
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/* *
|
|
|
|
|
* @tc.name: it_test_pthread_011
|
|
|
|
|
* @tc.desc: function for ProcessPthreadTest
|
|
|
|
|
* @tc.type: FUNC
|
|
|
|
|
*/
|
|
|
|
|
HWTEST_F(ProcessPthreadTest, ItTestPthread011, TestSize.Level0) {
|
|
|
|
|
ItTestPthread011();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* *
|
|
|
|
|
* @tc.name: it_test_pthread_012
|
|
|
|
|
* @tc.desc: function for ProcessPthreadTest
|
|
|
|
|
* @tc.type: FUNC
|
|
|
|
|
*/
|
|
|
|
|
HWTEST_F(ProcessPthreadTest, ItTestPthread012, TestSize.Level0) {
|
|
|
|
|
ItTestPthread012();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* *
|
|
|
|
|
* @tc.name: it_test_pthread_013
|
|
|
|
|
* @tc.desc: function for ProcessPthreadTest
|
|
|
|
|
* @tc.type: FUNC
|
|
|
|
|
*/
|
|
|
|
|
HWTEST_F(ProcessPthreadTest, ItTestPthread013, TestSize.Level0) {
|
|
|
|
|
ItTestPthread013();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* *
|
|
|
|
|
* @tc.name: it_test_pthread_015
|
|
|
|
|
* @tc.desc: function for ProcessPthreadTest
|
|
|
|
|
* @tc.type: FUNC
|
|
|
|
|
*/
|
|
|
|
|
HWTEST_F(ProcessPthreadTest, ItTestPthread015, TestSize.Level0) {
|
|
|
|
|
ItTestPthread015();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* *
|
|
|
|
|
* @tc.name: it_test_pthread_016
|
|
|
|
|
* @tc.desc: function for ProcessPthreadTest
|
|
|
|
|
* @tc.type: FUNC
|
|
|
|
|
*/
|
|
|
|
|
HWTEST_F(ProcessPthreadTest, ItTestPthread016, TestSize.Level0) {
|
|
|
|
|
ItTestPthread016();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* *
|
|
|
|
|
* @tc.name: it_test_pthread_018
|
|
|
|
|
* @tc.desc: function for ProcessPthreadTest
|
|
|
|
|
* @tc.type: FUNC
|
|
|
|
|
*/
|
|
|
|
|
HWTEST_F(ProcessPthreadTest, ItTestPthread018, TestSize.Level0) {
|
|
|
|
|
ItTestPthread018();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* *
|
|
|
|
|
* @tc.name: it_test_pthread_019
|
|
|
|
|
* @tc.desc: function for ProcessPthreadTest
|
|
|
|
|
* @tc.type: FUNC
|
|
|
|
|
*/
|
|
|
|
|
HWTEST_F(ProcessPthreadTest, ItTestPthread019, TestSize.Level0) {
|
|
|
|
|
ItTestPthread019();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* *
|
|
|
|
|
* @tc.name: it_test_pthread_020
|
|
|
|
|
* @tc.desc: function for ProcessPthreadTest
|
|
|
|
|
* @tc.type: FUNC
|
|
|
|
|
* @tc.require: issueI6T3P3
|
|
|
|
|
* @tc.author:
|
|
|
|
|
*/
|
|
|
|
|
HWTEST_F(ProcessPthreadTest, ItTestPthread020, TestSize.Level0) {
|
|
|
|
|
ItTestPthread020();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* *
|
|
|
|
|
* @tc.name: it_test_pthread_021
|
|
|
|
|
* @tc.desc: function for ProcessPthreadTest
|
|
|
|
|
* @tc.type: FUNC
|
|
|
|
|
* @tc.require: issueI6T3P3
|
|
|
|
|
* @tc.author:
|
|
|
|
|
*/
|
|
|
|
|
HWTEST_F(ProcessPthreadTest, ItTestPthread021, TestSize.Level0) {
|
|
|
|
|
ItTestPthread021();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* *
|
|
|
|
|
* @tc.name: it_test_pthread_022
|
|
|
|
|
* @tc.desc: function for ProcessPthreadTest
|
|
|
|
|
* @tc.type: FUNC
|
|
|
|
|
* @tc.require: issueI6T3P3
|
|
|
|
|
* @tc.author:
|
|
|
|
|
*/
|
|
|
|
|
HWTEST_F(ProcessPthreadTest, ItTestPthread022, TestSize.Level0) {
|
|
|
|
|
ItTestPthread022();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* *
|
|
|
|
|
* @tc.name: it_test_pthread_024
|
|
|
|
|
* @tc.desc: function for ProcessPthreadTest
|
|
|
|
|
* @tc.type: FUNC
|
|
|
|
|
* @tc.require: issueI6T3P3
|
|
|
|
|
* @tc.author:
|
|
|
|
|
*/
|
|
|
|
|
HWTEST_F(ProcessPthreadTest, ItTestP/*
|
|
|
|
|
* 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> // 引入字符类型限制头文件
|
|
|
|
|