分支昶
wcr 7 months ago
parent 2bbd81e1bb
commit ba78f4af13

@ -28,59 +28,77 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
// 包含标准输入输出头文件
#include "stdio.h" #include "stdio.h"
// 包含C标准库中的极限定义
#include <climits> #include <climits>
// 包含Google Test测试框架头文件
#include <gtest/gtest.h> #include <gtest/gtest.h>
// 包含自定义的pthread测试头文件
#include "it_pthread_test.h" #include "it_pthread_test.h"
// 包含系统资源库头文件
#include <sys/resource.h> #include <sys/resource.h>
// 使用Google Test框架的扩展命名空间
using namespace testing::ext; using namespace testing::ext;
// 定义一个名为OHOS的命名空间用于封装测试代码
namespace OHOS { namespace OHOS {
// 定义一个测试类ProcessPthreadTest它继承自Google Test框架的Test类
class ProcessPthreadTest : public testing::Test { class ProcessPthreadTest : public testing::Test {
public: public:
static void SetUpTestCase(void) // 测试套件开始前调用的静态成员函数,用于设置测试环境
{ static void SetUpTestCase(void) {
struct sched_param param = { 0 }; struct sched_param param = { 0 }; // 定义调度参数结构体
int currThreadPolicy, ret; int currThreadPolicy, ret; // 定义当前线程策略和返回值变量
// 获取当前线程的调度参数
ret = pthread_getschedparam(pthread_self(), &currThreadPolicy, &param); ret = pthread_getschedparam(pthread_self(), &currThreadPolicy, &param);
// 断言返回值为0如果不为0则用-ret作为错误码
ICUNIT_ASSERT_EQUAL_VOID(ret, 0, -ret); ICUNIT_ASSERT_EQUAL_VOID(ret, 0, -ret);
// 设置线程的调度优先级
param.sched_priority = TASK_PRIO_TEST; param.sched_priority = TASK_PRIO_TEST;
// 设置当前线程的调度参数
ret = pthread_setschedparam(pthread_self(), SCHED_RR, &param); ret = pthread_setschedparam(pthread_self(), SCHED_RR, &param);
// 断言返回值为0如果不为0则用-ret作为错误码
ICUNIT_ASSERT_EQUAL_VOID(ret, 0, -ret); ICUNIT_ASSERT_EQUAL_VOID(ret, 0, -ret);
} }
// 测试套件结束后调用的静态成员函数,用于清理测试环境(这里为空实现)
static void TearDownTestCase(void) {} static void TearDownTestCase(void) {}
}; };
#if defined(LOSCFG_USER_TEST_SMOKE) #if defined(LOSCFG_USER_TEST_SMOKE)
// 如果定义了LOSCFG_USER_TEST_SMOKE则编译并执行以下测试用例
/* * /* *
* @tc.name: it_test_pthread_003 * @tc.name: it_test_pthread_003
* @tc.desc: function for ProcessPthreadTest * @tc.desc: function for ProcessPthreadTest
* @tc.type: FUNC * @tc.type: FUNC
*/ */
HWTEST_F(ProcessPthreadTest, ItTestPthread003, TestSize.Level0) // 定义测试用例ItTestPthread003
{ HWTEST_F(ProcessPthreadTest, ItTestPthread003, TestSize.Level0) {
ItTestPthread003(); ItTestPthread003();
} }
#endif
#ifndef LOSCFG_USER_TEST_SMP #ifndef LOSCFG_USER_TEST_SMP
// 如果未定义LOSCFG_USER_TEST_SMP则编译并执行以下测试用例
/* * /* *
* @tc.name: it_test_pthread_006 * @tc.name: it_test_pthread_006
* @tc.desc: function for ProcessPthreadTest * @tc.desc: function for ProcessPthreadTest
* @tc.type: FUNC * @tc.type: FUNC
*/ */
HWTEST_F(ProcessPthreadTest, ItTestPthread006, TestSize.Level0) // 定义测试用例ItTestPthread006
{ HWTEST_F(ProcessPthreadTest, ItTestPthread006, TestSize.Level0) {
ItTestPthread006(); ItTestPthread006();
} }
#endif #endif
// 以下是其他测试用例的定义,每个测试用例都有相应的注释说明其功能和类型
/* * /* *
* @tc.name: it_test_pthread_007 * @tc.name: it_test_pthread_007
* @tc.desc: function for ProcessPthreadTest * @tc.desc: function for ProcessPthreadTest
* @tc.type: FUNC * @tc.type: FUNC
*/ */
HWTEST_F(ProcessPthreadTest, ItTestPthread007, TestSize.Level0) HWTEST_F(ProcessPthreadTest, ItTestPthread007, TestSize.Level0) {
{
ItTestPthread007(); ItTestPthread007();
} }
@ -89,8 +107,7 @@ HWTEST_F(ProcessPthreadTest, ItTestPthread007, TestSize.Level0)
* @tc.desc: function for ProcessPthreadTest * @tc.desc: function for ProcessPthreadTest
* @tc.type: FUNC * @tc.type: FUNC
*/ */
HWTEST_F(ProcessPthreadTest, ItTestPthread008, TestSize.Level0) HWTEST_F(ProcessPthreadTest, ItTestPthread008, TestSize.Level0) {
{
ItTestPthread008(); ItTestPthread008();
} }
@ -99,8 +116,7 @@ HWTEST_F(ProcessPthreadTest, ItTestPthread008, TestSize.Level0)
* @tc.desc: function for ProcessPthreadTest * @tc.desc: function for ProcessPthreadTest
* @tc.type: FUNC * @tc.type: FUNC
*/ */
HWTEST_F(ProcessPthreadTest, ItTestPthread009, TestSize.Level0) HWTEST_F(ProcessPthreadTest, ItTestPthread009, TestSize.Level0) {
{
ItTestPthread009(); ItTestPthread009();
} }
@ -110,8 +126,7 @@ HWTEST_F(ProcessPthreadTest, ItTestPthread009, TestSize.Level0)
* @tc.desc: function for ProcessPthreadTest * @tc.desc: function for ProcessPthreadTest
* @tc.type: FUNC * @tc.type: FUNC
*/ */
HWTEST_F(ProcessPthreadTest, ItTestPthread010, TestSize.Level0) HWTEST_F(ProcessPthreadTest, ItTestPthread010, TestSize.Level0) {
{
ItTestPthread010(); ItTestPthread010();
} }
#endif #endif
@ -121,8 +136,7 @@ HWTEST_F(ProcessPthreadTest, ItTestPthread010, TestSize.Level0)
* @tc.desc: function for ProcessPthreadTest * @tc.desc: function for ProcessPthreadTest
* @tc.type: FUNC * @tc.type: FUNC
*/ */
HWTEST_F(ProcessPthreadTest, ItTestPthread011, TestSize.Level0) HWTEST_F(ProcessPthreadTest, ItTestPthread011, TestSize.Level0) {
{
ItTestPthread011(); ItTestPthread011();
} }
@ -131,8 +145,7 @@ HWTEST_F(ProcessPthreadTest, ItTestPthread011, TestSize.Level0)
* @tc.desc: function for ProcessPthreadTest * @tc.desc: function for ProcessPthreadTest
* @tc.type: FUNC * @tc.type: FUNC
*/ */
HWTEST_F(ProcessPthreadTest, ItTestPthread012, TestSize.Level0) HWTEST_F(ProcessPthreadTest, ItTestPthread012, TestSize.Level0) {
{
ItTestPthread012(); ItTestPthread012();
} }
@ -141,8 +154,7 @@ HWTEST_F(ProcessPthreadTest, ItTestPthread012, TestSize.Level0)
* @tc.desc: function for ProcessPthreadTest * @tc.desc: function for ProcessPthreadTest
* @tc.type: FUNC * @tc.type: FUNC
*/ */
HWTEST_F(ProcessPthreadTest, ItTestPthread013, TestSize.Level0) HWTEST_F(ProcessPthreadTest, ItTestPthread013, TestSize.Level0) {
{
ItTestPthread013(); ItTestPthread013();
} }
@ -151,8 +163,7 @@ HWTEST_F(ProcessPthreadTest, ItTestPthread013, TestSize.Level0)
* @tc.desc: function for ProcessPthreadTest * @tc.desc: function for ProcessPthreadTest
* @tc.type: FUNC * @tc.type: FUNC
*/ */
HWTEST_F(ProcessPthreadTest, ItTestPthread015, TestSize.Level0) HWTEST_F(ProcessPthreadTest, ItTestPthread015, TestSize.Level0) {
{
ItTestPthread015(); ItTestPthread015();
} }
@ -161,8 +172,7 @@ HWTEST_F(ProcessPthreadTest, ItTestPthread015, TestSize.Level0)
* @tc.desc: function for ProcessPthreadTest * @tc.desc: function for ProcessPthreadTest
* @tc.type: FUNC * @tc.type: FUNC
*/ */
HWTEST_F(ProcessPthreadTest, ItTestPthread016, TestSize.Level0) HWTEST_F(ProcessPthreadTest, ItTestPthread016, TestSize.Level0) {
{
ItTestPthread016(); ItTestPthread016();
} }
@ -171,8 +181,7 @@ HWTEST_F(ProcessPthreadTest, ItTestPthread016, TestSize.Level0)
* @tc.desc: function for ProcessPthreadTest * @tc.desc: function for ProcessPthreadTest
* @tc.type: FUNC * @tc.type: FUNC
*/ */
HWTEST_F(ProcessPthreadTest, ItTestPthread018, TestSize.Level0) HWTEST_F(ProcessPthreadTest, ItTestPthread018, TestSize.Level0) {
{
ItTestPthread018(); ItTestPthread018();
} }
@ -181,8 +190,7 @@ HWTEST_F(ProcessPthreadTest, ItTestPthread018, TestSize.Level0)
* @tc.desc: function for ProcessPthreadTest * @tc.desc: function for ProcessPthreadTest
* @tc.type: FUNC * @tc.type: FUNC
*/ */
HWTEST_F(ProcessPthreadTest, ItTestPthread019, TestSize.Level0) HWTEST_F(ProcessPthreadTest, ItTestPthread019, TestSize.Level0) {
{
ItTestPthread019(); ItTestPthread019();
} }
@ -193,8 +201,7 @@ HWTEST_F(ProcessPthreadTest, ItTestPthread019, TestSize.Level0)
* @tc.require: issueI6T3P3 * @tc.require: issueI6T3P3
* @tc.author: * @tc.author:
*/ */
HWTEST_F(ProcessPthreadTest, ItTestPthread020, TestSize.Level0) HWTEST_F(ProcessPthreadTest, ItTestPthread020, TestSize.Level0) {
{
ItTestPthread020(); ItTestPthread020();
} }
@ -205,8 +212,7 @@ HWTEST_F(ProcessPthreadTest, ItTestPthread020, TestSize.Level0)
* @tc.require: issueI6T3P3 * @tc.require: issueI6T3P3
* @tc.author: * @tc.author:
*/ */
HWTEST_F(ProcessPthreadTest, ItTestPthread021, TestSize.Level0) HWTEST_F(ProcessPthreadTest, ItTestPthread021, TestSize.Level0) {
{
ItTestPthread021(); ItTestPthread021();
} }
@ -217,8 +223,7 @@ HWTEST_F(ProcessPthreadTest, ItTestPthread021, TestSize.Level0)
* @tc.require: issueI6T3P3 * @tc.require: issueI6T3P3
* @tc.author: * @tc.author:
*/ */
HWTEST_F(ProcessPthreadTest, ItTestPthread022, TestSize.Level0) HWTEST_F(ProcessPthreadTest, ItTestPthread022, TestSize.Level0) {
{
ItTestPthread022(); ItTestPthread022();
} }
@ -229,197 +234,4 @@ HWTEST_F(ProcessPthreadTest, ItTestPthread022, TestSize.Level0)
* @tc.require: issueI6T3P3 * @tc.require: issueI6T3P3
* @tc.author: * @tc.author:
*/ */
HWTEST_F(ProcessPthreadTest, ItTestPthread024, TestSize.Level0) HWTEST_F(ProcessPthreadTest, ItTestP
{
ItTestPthread024();
}
/* *
* @tc.name: it_test_pthread_026
* @tc.desc: function for ProcessPthreadTest
* @tc.type: FUNC
* @tc.require: issueI6T3P3
* @tc.author:
*/
HWTEST_F(ProcessPthreadTest, ItTestPthread026, TestSize.Level0)
{
ItTestPthread026();
}
/* *
* @tc.name: it_test_pthread_027
* @tc.desc: function for ProcessPthreadTest
* @tc.type: FUNC
* @tc.require: issueI6T3P3
* @tc.author:
*/
HWTEST_F(ProcessPthreadTest, ItTestPthread027, TestSize.Level0)
{
ItTestPthread027();
}
/* *
* @tc.name: it_test_pthread_023
* @tc.desc: function for ProcessPthreadTest
* @tc.type: FUNC
* @tc.require: issueI6T3P3
* @tc.author:
*/
HWTEST_F(ProcessPthreadTest, ItTestPthread023, TestSize.Level0)
{
ItTestPthread023();
}
/* *
* @tc.name: it_test_pthread_025
* @tc.desc: function for ProcessPthreadTest
* @tc.type: FUNC
* @tc.require: issueI6T3P3
* @tc.author:
*/
HWTEST_F(ProcessPthreadTest, ItTestPthread025, TestSize.Level0)
{
ItTestPthread025();
}
/* *
* @tc.name: it_test_pthread_017
* @tc.desc: function for ProcessPthreadTest
* @tc.type: FUNC
*/
HWTEST_F(ProcessPthreadTest, ItTestPthread017, TestSize.Level0)
{
ItTestPthread017();
}
/* *
* @tc.name: it_test_pthread_once_001
* @tc.desc: function for ProcessPthreadTest
* @tc.type: FUNC
*/
HWTEST_F(ProcessPthreadTest, ItTestPthreadOnce001, TestSize.Level0)
{
ItTestPthreadOnce001();
}
/* *
* @tc.name: it_test_pthread_atfork_001
* @tc.desc: function for ProcessPthreadTest
* @tc.type: FUNC
*/
HWTEST_F(ProcessPthreadTest, ItTestPthreadAtfork001, TestSize.Level0)
{
ItTestPthreadAtfork001();
}
/* *
* @tc.name: it_test_pthread_atfork_002
* @tc.desc: function for ProcessPthreadTest
* @tc.type: FUNC
*/
HWTEST_F(ProcessPthreadTest, ItTestPthreadAtfork002, TestSize.Level0)
{
ItTestPthreadAtfork002();
}
/* *
* @tc.name: it_test_pthread_cond_001
* @tc.desc: function for ProcessPthreadTest
* @tc.type: FUNC
*/
HWTEST_F(ProcessPthreadTest, ItTestPthreadCond001, TestSize.Level0)
{
ItTestPthreadCond001();
}
/* *
* @tc.name: it_test_pthread_cond_002
* @tc.desc: function for ProcessPthreadTest
* @tc.type: FUNC
*/
HWTEST_F(ProcessPthreadTest, ItTestPthreadCond002, TestSize.Level0)
{
ItTestPthreadCond002();
}
/* *
* @tc.name: it_test_pthread_cond_003
* @tc.desc: function for ProcessPthreadTest
* @tc.type: FUNC
*/
HWTEST_F(ProcessPthreadTest, ItTestPthreadCond003, TestSize.Level0)
{
ItTestPthreadCond003();
}
/* *
* @tc.name: it_test_pthread_cond_004
* @tc.desc: function for ProcessPthreadTest
* @tc.type: FUNC
*/
HWTEST_F(ProcessPthreadTest, ItTestPthreadCond004, TestSize.Level0)
{
ItTestPthreadCond004();
}
#endif
#if defined(LOSCFG_USER_TEST_FULL)
/* *
* @tc.name: it_test_pthread_001
* @tc.desc: function for ProcessPthreadTest
* @tc.type: FUNC
*/
HWTEST_F(ProcessPthreadTest, ItTestPthread001, TestSize.Level0)
{
ItTestPthread001();
}
#ifndef LOSCFG_USER_TEST_SMP
/* *
* @tc.name: it_test_pthread_002
* @tc.desc: function for ProcessPthreadTest
* @tc.type: FUNC
*/
HWTEST_F(ProcessPthreadTest, ItTestPthread002, TestSize.Level0)
{
ItTestPthread002();
}
#endif
/* *
* @tc.name: it_test_pthread_004
* @tc.desc: function for ProcessPthreadTest
* @tc.type: FUNC
*/
HWTEST_F(ProcessPthreadTest, ItTestPthread004, TestSize.Level0)
{
ItTestPthread004();
}
/* *
* @tc.name: it_test_pthread_005
* @tc.desc: function for ProcessPthreadTest
* @tc.type: FUNC
*/
HWTEST_F(ProcessPthreadTest, ItTestPthread005, TestSize.Level0)
{
ItTestPthread005();
}
#ifndef LOSCFG_USER_TEST_SMP
/* *
* @tc.name: it_test_pthread_014
* @tc.desc: function for ProcessPthreadTest
* @tc.type: FUNC
*/
HWTEST_F(ProcessPthreadTest, ItTestPthread014, TestSize.Level0)
{
ItTestPthread014();
}
#endif
#endif
} // namespace OHOS
Loading…
Cancel
Save