提交 2be59680 编写于 作者: Z zhushengle

fix: 添加进程线程冒烟用例

Close #I4EOGA
Signed-off-by: Nzhushengle <zhushengle@huawei.com>
Change-Id: I0f10f81d41564d4d34fc2f89692da0b3211f5918
上级 acd631c7
...@@ -63,15 +63,15 @@ LOSCFG_USER_TEST_POSIX_MQUEUE = true ...@@ -63,15 +63,15 @@ LOSCFG_USER_TEST_POSIX_MQUEUE = true
LOSCFG_USER_TEST_POSIX_MEM = true LOSCFG_USER_TEST_POSIX_MEM = true
LOSCFG_USER_TEST_SPINLOCK = true LOSCFG_USER_TEST_SPINLOCK = true
LOSCFG_USER_TEST_RWLOCK = true LOSCFG_USER_TEST_RWLOCK = true
LOSCFG_USER_TEST_PTHREAD = false LOSCFG_USER_TEST_PTHREAD = true
LOSCFG_USER_TEST_PROCESS = false LOSCFG_USER_TEST_PROCESS = true
LOSCFG_USER_TEST_MUTEX = true LOSCFG_USER_TEST_MUTEX = true
LOSCFG_USER_TEST_SECURITY_CAPABILITY = true LOSCFG_USER_TEST_SECURITY_CAPABILITY = true
LOSCFG_USER_TEST_SECURITY_VID = true LOSCFG_USER_TEST_SECURITY_VID = true
LOSCFG_USER_TEST_SECURITY_REUGID = true LOSCFG_USER_TEST_SECURITY_REUGID = true
LOSCFG_USER_TEST_SIGNAL = true LOSCFG_USER_TEST_SIGNAL = true
LOSCFG_USER_TEST_SYS = true LOSCFG_USER_TEST_SYS = true
LOSCFG_USER_TEST_TIME_CLOCK = true LOSCFG_USER_TEST_TIME_CLOCK = true
LOSCFG_USER_TEST_TIME_TIMER = true LOSCFG_USER_TEST_TIME_TIMER = true
LOSCFG_USER_TEST_UTIL = true LOSCFG_USER_TEST_UTIL = true
LOSCFG_USER_TEST_TRACE = false LOSCFG_USER_TEST_TRACE = false
...@@ -47,7 +47,6 @@ sources_smoke = [ ...@@ -47,7 +47,6 @@ sources_smoke = [
"smoke/process_test_004.cpp", "smoke/process_test_004.cpp",
"smoke/process_test_005.cpp", "smoke/process_test_005.cpp",
"smoke/process_test_006.cpp", "smoke/process_test_006.cpp",
"smoke/process_test_007.cpp",
"smoke/process_test_008.cpp", "smoke/process_test_008.cpp",
"smoke/process_test_009.cpp", "smoke/process_test_009.cpp",
"smoke/process_test_010.cpp", "smoke/process_test_010.cpp",
...@@ -79,8 +78,6 @@ sources_smoke = [ ...@@ -79,8 +78,6 @@ sources_smoke = [
"smoke/process_test_037.cpp", "smoke/process_test_037.cpp",
"smoke/process_test_038.cpp", "smoke/process_test_038.cpp",
"smoke/process_test_039.cpp", "smoke/process_test_039.cpp",
"smoke/process_test_040.cpp",
"smoke/process_test_041.cpp",
"smoke/process_test_042.cpp", "smoke/process_test_042.cpp",
"smoke/process_test_043.cpp", "smoke/process_test_043.cpp",
"smoke/process_test_044.cpp", "smoke/process_test_044.cpp",
...@@ -88,21 +85,9 @@ sources_smoke = [ ...@@ -88,21 +85,9 @@ sources_smoke = [
"smoke/process_test_046.cpp", "smoke/process_test_046.cpp",
"smoke/process_test_047.cpp", "smoke/process_test_047.cpp",
"smoke/process_test_048.cpp", "smoke/process_test_048.cpp",
"smoke/process_test_049.cpp", "smoke/process_test_054.cpp",
"smoke/process_test_050.cpp", "smoke/process_test_055.cpp",
"smoke/process_test_051.cpp", "smoke/process_test_061.cpp",
"smoke/process_test_056.cpp",
"smoke/process_test_057.cpp",
"smoke/process_test_058.cpp",
"smoke/process_test_059.cpp",
"smoke/process_test_060.cpp",
"smoke/process_test_063.cpp",
"smoke/process_test_064.cpp",
"smoke/process_test_065.cpp",
"smoke/process_test_066.cpp",
"smoke/process_test_067.cpp",
"smoke/process_test_068.cpp",
"smoke/process_test_069.cpp",
"smp/process_test_smp_001.cpp", "smp/process_test_smp_001.cpp",
"smp/process_test_smp_002.cpp", "smp/process_test_smp_002.cpp",
"smp/process_test_smp_003.cpp", "smp/process_test_smp_003.cpp",
...@@ -114,10 +99,25 @@ sources_smoke = [ ...@@ -114,10 +99,25 @@ sources_smoke = [
] ]
sources_full = [ sources_full = [
"full/process_test_007.cpp",
"full/process_test_040.cpp",
"full/process_test_041.cpp",
"full/process_test_049.cpp",
"full/process_test_050.cpp",
"full/process_test_051.cpp",
"full/process_test_056.cpp",
"full/process_test_057.cpp",
"full/process_test_058.cpp",
"full/process_test_059.cpp",
"full/process_test_060.cpp",
"full/process_test_063.cpp",
"full/process_test_064.cpp",
"full/process_test_065.cpp",
"full/process_test_066.cpp",
"full/process_test_067.cpp",
"full/process_test_068.cpp",
"full/process_test_069.cpp",
"full/process_test_053.cpp", "full/process_test_053.cpp",
"full/process_test_054.cpp",
"full/process_test_055.cpp",
"full/process_test_061.cpp",
"full/process_test_062.cpp", "full/process_test_062.cpp",
] ]
......
...@@ -126,17 +126,6 @@ HWTEST_F(ProcessProcessTest, ItTestProcess006, TestSize.Level0) ...@@ -126,17 +126,6 @@ HWTEST_F(ProcessProcessTest, ItTestProcess006, TestSize.Level0)
ItTestProcess006(); ItTestProcess006();
} }
/* *
* @tc.name: it_test_process_007
* @tc.desc: function for ProcessProcessTest
* @tc.type: FUNC
* @tc.require: AR000EEMQ9
*/
HWTEST_F(ProcessProcessTest, ItTestProcess007, TestSize.Level0)
{
ItTestProcess007();
}
/* * /* *
* @tc.name: it_test_process_008 * @tc.name: it_test_process_008
* @tc.desc: function for ProcessProcessTest * @tc.desc: function for ProcessProcessTest
...@@ -478,28 +467,6 @@ HWTEST_F(ProcessProcessTest, ItTestProcess039, TestSize.Level0) ...@@ -478,28 +467,6 @@ HWTEST_F(ProcessProcessTest, ItTestProcess039, TestSize.Level0)
ItTestProcess039(); ItTestProcess039();
} }
/* *
* @tc.name: it_test_process_040
* @tc.desc: function for ProcessProcessTest
* @tc.type: FUNC
* @tc.require: AR000EEMQ9
*/
HWTEST_F(ProcessProcessTest, ItTestProcess040, TestSize.Level0)
{
ItTestProcess040();
}
/* *
* @tc.name: it_test_process_041
* @tc.desc: function for ProcessProcessTest
* @tc.type: FUNC
* @tc.require: AR000EEMQ9
*/
HWTEST_F(ProcessProcessTest, ItTestProcess041, TestSize.Level0)
{
ItTestProcess041();
}
/* * /* *
* @tc.name: it_test_process_042 * @tc.name: it_test_process_042
* @tc.desc: function for ProcessProcessTest * @tc.desc: function for ProcessProcessTest
...@@ -578,172 +545,36 @@ HWTEST_F(ProcessProcessTest, ItTestProcess048, TestSize.Level0) ...@@ -578,172 +545,36 @@ HWTEST_F(ProcessProcessTest, ItTestProcess048, TestSize.Level0)
} }
/* * /* *
* @tc.name: it_test_process_049 * @tc.name: it_test_process_054
* @tc.desc: function for ProcessProcessTest * @tc.desc: function for waitid: The waitid parameter is incorrect and the error code is verified.
* @tc.type: FUNC
* @tc.require: DTS202101040I5J4KP0H00
*/
HWTEST_F(ProcessProcessTest, ItTestProcess049, TestSize.Level0)
{
ItTestProcess049();
}
/* *
* @tc.name: it_test_process_050
* @tc.desc: function for ProcessProcessTest
* @tc.type: FUNC
* @tc.require: DTS202101040I5J4KP0H00
*/
HWTEST_F(ProcessProcessTest, ItTestProcess050, TestSize.Level0)
{
ItTestProcess050();
}
/* *
* @tc.name: it_test_process_051
* @tc.desc: function for ProcessProcessTest
* @tc.type: FUNC
* @tc.require: DTS202101040I5J4KP0H00
*/
HWTEST_F(ProcessProcessTest, ItTestProcess051, TestSize.Level0)
{
ItTestProcess051();
}
/* *
* @tc.name: it_test_process_056
* @tc.desc: function for posix_spawn:Verifying Basic Functions
* @tc.type: FUNC
* @tc.require: AR000E0QAB
*/
HWTEST_F(ProcessProcessTest, ItTestProcess056, TestSize.Level0)
{
ItTestProcess056();
}
/* *
* @tc.name: it_test_process_057
* @tc.desc: function for posix_spawnp:Verifying Basic Functions
* @tc.type: FUNC
* @tc.require: AR000E0QAB
*/
HWTEST_F(ProcessProcessTest, ItTestProcess057, TestSize.Level0)
{
ItTestProcess057();
}
/* *
* @tc.name: it_test_process_058
* @tc.desc: function for posix_spawn: The attr parameter is correctly transferred and the flag is set.
* @tc.type: FUNC
* @tc.require: AR000E0QAB
*/
HWTEST_F(ProcessProcessTest, ItTestProcess058, TestSize.Level0)
{
ItTestProcess058();
}
/* *
* @tc.name: it_test_process_059
* @tc.desc: function for posix_spawnp: The attr parameter is correctly transferred and the flag is set.
* @tc.type: FUNC
* @tc.require: AR000E0QAB
*/
HWTEST_F(ProcessProcessTest, ItTestProcess059, TestSize.Level0)
{
ItTestProcess059();
}
/* *
* @tc.name: it_test_process_060
* @tc.desc: function for posix_spawnp: Error code verification for the attr setting function.
* The attr parameter is incorrect and the error code is verified.
* @tc.type: FUNC
* @tc.require: AR000E0QAB
*/
HWTEST_F(ProcessProcessTest, ItTestProcess060, TestSize.Level0)
{
ItTestProcess060();
}
/* *
* @tc.name: it_test_process_063
* @tc.desc: function for posix_spawn: The file path, argv command, and envp environment variable are invalid.
* Error code verification is performed.
* @tc.type: FUNC
* @tc.require: AR000E0QAB
*/
HWTEST_F(ProcessProcessTest, ItTestProcess063, TestSize.Level0)
{
ItTestProcess063();
}
/* *
* @tc.name: it_test_process_064
* @tc.desc: function for posix_spawnp: The file path, argv command, and envp environment variable are invalid.
* Error code verification is performed.
* @tc.type: FUNC
* @tc.require: AR000E0QAB
*/
HWTEST_F(ProcessProcessTest, ItTestProcess064, TestSize.Level0)
{
ItTestProcess064();
}
/* *
* @tc.name: it_test_process_065
* @tc.desc: function for posix_spawn: Error code verification for the attr setting function.
* The attr parameter is incorrect and the error code is verified.
* @tc.type: FUNC
* @tc.require: AR000E0QAB
*/
HWTEST_F(ProcessProcessTest, ItTestProcess065, TestSize.Level0)
{
ItTestProcess065();
}
/* *
* @tc.name: it_test_process_066
* @tc.desc: function for posix_spawn: Check the effect of subprocess settings when attr is valid.
* @tc.type: FUNC
* @tc.require: AR000E0QAB
*/
HWTEST_F(ProcessProcessTest, ItTestProcess066, TestSize.Level0)
{
ItTestProcess066();
}
/* *
* @tc.name: it_test_process_067
* @tc.desc: function for posix_spawn: Check the effect of subprocess settings when attr is valid.
* @tc.type: FUNC * @tc.type: FUNC
* @tc.require: AR000E0QAB * @tc.require: AR000E0QAB
*/ */
HWTEST_F(ProcessProcessTest, ItTestProcess067, TestSize.Level0) HWTEST_F(ProcessProcessTest, ItTestProcess054, TestSize.Level0)
{ {
ItTestProcess067(); ItTestProcess054();
} }
/* * /* *
* @tc.name: it_test_process_068 * @tc.name: it_test_process_055
* @tc.desc: function for posix_spawn: Verify the effect of the argv and envp parameters in subprocesses. * @tc.desc: function for waitid:To test the function of transferring different parameters of the waitid.
* @tc.type: FUNC * @tc.type: FUNC
* @tc.require: AR000E0QAB * @tc.require: AR000E0QAB
*/ */
HWTEST_F(ProcessProcessTest, ItTestProcess068, TestSize.Level0) HWTEST_F(ProcessProcessTest, ItTestProcess055, TestSize.Level0)
{ {
ItTestProcess068(); ItTestProcess055();
} }
/* * /* *
* @tc.name: it_test_process_069 * @tc.name: it_test_process_061
* @tc.desc: function for posix_spawnp: Verify the effect of the argv and envp parameters in subprocesses. * @tc.desc: function for killpg: The killpg parameter is incorrect and the error code is verified.
* @tc.type: FUNC * @tc.type: FUNC
* @tc.require: AR000E0QAB * @tc.require: AR000E0QAB
*/ */
HWTEST_F(ProcessProcessTest, ItTestProcess069, TestSize.Level0) HWTEST_F(ProcessProcessTest, ItTestProcess061, TestSize.Level0)
{ {
ItTestProcess069(); ItTestProcess061();
} }
#ifdef LOSCFG_USER_TEST_SMP #ifdef LOSCFG_USER_TEST_SMP
...@@ -839,48 +670,48 @@ HWTEST_F(ProcessProcessTest, ItTestProcessSmp008, TestSize.Level0) ...@@ -839,48 +670,48 @@ HWTEST_F(ProcessProcessTest, ItTestProcessSmp008, TestSize.Level0)
#if defined(LOSCFG_USER_TEST_FULL) #if defined(LOSCFG_USER_TEST_FULL)
/* * /* *
* @tc.name: it_test_process_053 * @tc.name: it_test_process_007
* @tc.desc: function for killpg:Sends a signal to the process group, * @tc.desc: function for ProcessProcessTest
* Other processes in the process group can receive the signal.
* @tc.type: FUNC * @tc.type: FUNC
* @tc.require: AR000E0QAB * @tc.require: AR000EEMQ9
*/ */
HWTEST_F(ProcessProcessTest, ItTestProcess053, TestSize.Level0) HWTEST_F(ProcessProcessTest, ItTestProcess007, TestSize.Level0)
{ {
ItTestProcess053(); ItTestProcess007();
} }
/* * /* *
* @tc.name: it_test_process_054 * @tc.name: it_test_process_040
* @tc.desc: function for waitid: The waitid parameter is incorrect and the error code is verified. * @tc.desc: function for ProcessProcessTest
* @tc.type: FUNC * @tc.type: FUNC
* @tc.require: AR000E0QAB * @tc.require: AR000EEMQ9
*/ */
HWTEST_F(ProcessProcessTest, ItTestProcess054, TestSize.Level0) HWTEST_F(ProcessProcessTest, ItTestProcess040, TestSize.Level0)
{ {
ItTestProcess054(); ItTestProcess040();
} }
/* * /* *
* @tc.name: it_test_process_055 * @tc.name: it_test_process_041
* @tc.desc: function for waitid:To test the function of transferring different parameters of the waitid. * @tc.desc: function for ProcessProcessTest
* @tc.type: FUNC * @tc.type: FUNC
* @tc.require: AR000E0QAB * @tc.require: AR000EEMQ9
*/ */
HWTEST_F(ProcessProcessTest, ItTestProcess055, TestSize.Level0) HWTEST_F(ProcessProcessTest, ItTestProcess041, TestSize.Level0)
{ {
ItTestProcess055(); ItTestProcess041();
} }
/* * /* *
* @tc.name: it_test_process_061 * @tc.name: it_test_process_053
* @tc.desc: function for killpg: The killpg parameter is incorrect and the error code is verified. * @tc.desc: function for killpg:Sends a signal to the process group,
* Other processes in the process group can receive the signal.
* @tc.type: FUNC * @tc.type: FUNC
* @tc.require: AR000E0QAB * @tc.require: AR000E0QAB
*/ */
HWTEST_F(ProcessProcessTest, ItTestProcess061, TestSize.Level0) HWTEST_F(ProcessProcessTest, ItTestProcess053, TestSize.Level0)
{ {
ItTestProcess061(); ItTestProcess053();
} }
/* * /* *
......
...@@ -46,12 +46,12 @@ sources_smoke = [ ...@@ -46,12 +46,12 @@ sources_smoke = [
"smoke/pthread_atfork_test_002.cpp", "smoke/pthread_atfork_test_002.cpp",
"smoke/pthread_cond_test_001.cpp", "smoke/pthread_cond_test_001.cpp",
"smoke/pthread_cond_test_002.cpp", "smoke/pthread_cond_test_002.cpp",
"smoke/pthread_cond_test_003.cpp",
"smoke/pthread_cond_test_004.cpp",
"smoke/pthread_once_test_001.cpp", "smoke/pthread_once_test_001.cpp",
"smoke/pthread_test_001.cpp", "smoke/pthread_test_001.cpp",
"smoke/pthread_test_002.cpp", "smoke/pthread_test_002.cpp",
"smoke/pthread_test_003.cpp", "smoke/pthread_test_003.cpp",
"smoke/pthread_test_004.cpp",
"smoke/pthread_test_005.cpp",
"smoke/pthread_test_006.cpp", "smoke/pthread_test_006.cpp",
"smoke/pthread_test_007.cpp", "smoke/pthread_test_007.cpp",
"smoke/pthread_test_008.cpp", "smoke/pthread_test_008.cpp",
...@@ -69,6 +69,8 @@ sources_smoke = [ ...@@ -69,6 +69,8 @@ sources_smoke = [
] ]
sources_full = [ sources_full = [
"full/pthread_test_004.cpp",
"full/pthread_test_005.cpp",
] ]
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_LOW) { if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_LOW) {
......
...@@ -245,6 +245,10 @@ static void *threadFunc(void *arg) ...@@ -245,6 +245,10 @@ static void *threadFunc(void *arg)
ret = pthread_create(&newPthread, &a, threadFunc2, 0); ret = pthread_create(&newPthread, &a, threadFunc2, 0);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT); ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
#ifdef LOSCFG_USER_TEST_SMP
sleep(1);
#endif
ret = pthread_spin_lock(&g_spinTestLock); ret = pthread_spin_lock(&g_spinTestLock);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT); ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
ICUNIT_GOTO_EQUAL(g_pthreadTestCount, 4, g_pthreadTestCount, EXIT); // 4, here assert the result. ICUNIT_GOTO_EQUAL(g_pthreadTestCount, 4, g_pthreadTestCount, EXIT); // 4, here assert the result.
......
...@@ -79,4 +79,6 @@ extern void ItTestPthreadAtfork002(void); ...@@ -79,4 +79,6 @@ extern void ItTestPthreadAtfork002(void);
extern void ItTestPthreadOnce001(void); extern void ItTestPthreadOnce001(void);
extern void ItTestPthreadCond001(void); extern void ItTestPthreadCond001(void);
extern void ItTestPthreadCond002(void); extern void ItTestPthreadCond002(void);
#endif extern void ItTestPthreadCond003(void);
\ No newline at end of file extern void ItTestPthreadCond004(void);
#endif
...@@ -87,28 +87,6 @@ HWTEST_F(ProcessPthreadTest, ItTestPthread003, TestSize.Level0) ...@@ -87,28 +87,6 @@ HWTEST_F(ProcessPthreadTest, ItTestPthread003, TestSize.Level0)
ItTestPthread003(); ItTestPthread003();
} }
/* *
* @tc.name: it_test_pthread_004
* @tc.desc: function for ProcessPthreadTest
* @tc.type: FUNC
* @tc.require: AR000EEMQ9
*/
HWTEST_F(ProcessPthreadTest, ItTestPthread004, TestSize.Level0)
{
ItTestPthread004();
}
/* *
* @tc.name: it_test_pthread_005
* @tc.desc: function for ProcessPthreadTest
* @tc.type: FUNC
* @tc.require: AR000EEMQ9
*/
HWTEST_F(ProcessPthreadTest, ItTestPthread005, TestSize.Level0)
{
ItTestPthread005();
}
#ifndef LOSCFG_USER_TEST_SMP #ifndef LOSCFG_USER_TEST_SMP
/* * /* *
* @tc.name: it_test_pthread_006 * @tc.name: it_test_pthread_006
...@@ -237,38 +215,39 @@ HWTEST_F(ProcessPthreadTest, ItTestPthread016, TestSize.Level0) ...@@ -237,38 +215,39 @@ HWTEST_F(ProcessPthreadTest, ItTestPthread016, TestSize.Level0)
} }
/* * /* *
* @tc.name: it_test_pthread_017 * @tc.name: it_test_pthread_018
* @tc.desc: function for ProcessPthreadTest * @tc.desc: function for ProcessPthreadTest
* @tc.type: FUNC * @tc.type: FUNC
* @tc.require: AR000EEMQ9 * @tc.require: AR000EEMQ9
*/ */
HWTEST_F(ProcessPthreadTest, ItTestPthread017, TestSize.Level0) HWTEST_F(ProcessPthreadTest, ItTestPthread018, TestSize.Level0)
{ {
ItTestPthread017(); ItTestPthread018();
} }
/* * /* *
* @tc.name: it_test_pthread_018 * @tc.name: it_test_pthread_019
* @tc.desc: function for ProcessPthreadTest * @tc.desc: function for ProcessPthreadTest
* @tc.type: FUNC * @tc.type: FUNC
* @tc.require: AR000EEMQ9 * @tc.require: AR000EEMQ9
*/ */
HWTEST_F(ProcessPthreadTest, ItTestPthread018, TestSize.Level0) HWTEST_F(ProcessPthreadTest, ItTestPthread019, TestSize.Level0)
{ {
ItTestPthread018(); ItTestPthread019();
} }
/* * /* *
* @tc.name: it_test_pthread_019 * @tc.name: it_test_pthread_017
* @tc.desc: function for ProcessPthreadTest * @tc.desc: function for ProcessPthreadTest
* @tc.type: FUNC * @tc.type: FUNC
* @tc.require: AR000EEMQ9 * @tc.require: AR000EEMQ9
*/ */
HWTEST_F(ProcessPthreadTest, ItTestPthread019, TestSize.Level0) HWTEST_F(ProcessPthreadTest, ItTestPthread017, TestSize.Level0)
{ {
ItTestPthread019(); ItTestPthread017();
} }
/* * /* *
* @tc.name: it_test_pthread_once_001 * @tc.name: it_test_pthread_once_001
* @tc.desc: function for ProcessPthreadTest * @tc.desc: function for ProcessPthreadTest
...@@ -323,5 +302,52 @@ HWTEST_F(ProcessPthreadTest, ItTestPthreadCond002, TestSize.Level0) ...@@ -323,5 +302,52 @@ HWTEST_F(ProcessPthreadTest, ItTestPthreadCond002, TestSize.Level0)
{ {
ItTestPthreadCond002(); ItTestPthreadCond002();
} }
/* *
* @tc.name: it_test_pthread_cond_003
* @tc.desc: function for ProcessPthreadTest
* @tc.type: FUNC
* @tc.require: AR000EEMQ9
*/
HWTEST_F(ProcessPthreadTest, ItTestPthreadCond003, TestSize.Level0)
{
ItTestPthreadCond003();
}
/* *
* @tc.name: it_test_pthread_cond_004
* @tc.desc: function for ProcessPthreadTest
* @tc.type: FUNC
* @tc.require: AR000EEMQ9
*/
HWTEST_F(ProcessPthreadTest, ItTestPthreadCond004, TestSize.Level0)
{
ItTestPthreadCond004();
}
#endif
#if defined(LOSCFG_USER_TEST_FULL)
/* *
* @tc.name: it_test_pthread_004
* @tc.desc: function for ProcessPthreadTest
* @tc.type: FUNC
* @tc.require: AR000EEMQ9
*/
HWTEST_F(ProcessPthreadTest, ItTestPthread004, TestSize.Level0)
{
ItTestPthread004();
}
/* *
* @tc.name: it_test_pthread_005
* @tc.desc: function for ProcessPthreadTest
* @tc.type: FUNC
* @tc.require: AR000EEMQ9
*/
HWTEST_F(ProcessPthreadTest, ItTestPthread005, TestSize.Level0)
{
ItTestPthread005();
}
#endif #endif
} // namespace OHOS } // namespace OHOS
/*
* 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 pthread_cond_t g_pthread_cond;
static pthread_mutex_t g_pthread_mutex;
#define TEST_THREAD_COUNT 5
static void *pthread_cond_func001(void *arg)
{
int ret;
struct timespec ts;
g_testCount++;
ret = pthread_mutex_lock(&g_pthread_mutex);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
clock_gettime(CLOCK_REALTIME, &ts);
ts.tv_sec += 60; /* 60: wait 1 minute */
ret = pthread_cond_timedwait(&g_pthread_cond, &g_pthread_mutex, &ts);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
ret = pthread_mutex_unlock(&g_pthread_mutex);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
g_testCount++;
EXIT:
return NULL;
}
static VOID *pthread_f06(void *argument)
{
int policy;
int ret;
int i;
pthread_attr_t attr;
struct sched_param schedParam = { 0 };
pthread_t thread[TEST_THREAD_COUNT];
g_testCount = 0;
ret = pthread_attr_init(&attr);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
ret = pthread_getschedparam(pthread_self(), &policy, &schedParam);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
schedParam.sched_priority -= 1;
ret = pthread_attr_setschedparam(&attr, &schedParam);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
ret = pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
for (i = 0; i < TEST_THREAD_COUNT; i++) {
ret = pthread_create(&thread[i], &attr, pthread_cond_func001, NULL);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
}
sleep(1);
ICUNIT_GOTO_EQUAL(g_testCount, 5, g_testCount, EXIT); /* 5: Five threads */
ret = pthread_mutex_lock(&g_pthread_mutex);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
ret = pthread_cond_broadcast(&g_pthread_cond);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
ret = pthread_mutex_unlock(&g_pthread_mutex);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
for (i = 0; i < TEST_THREAD_COUNT; i++) {
ret = pthread_join(thread[i], NULL);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
}
ICUNIT_GOTO_EQUAL(g_testCount, 10, g_testCount, EXIT); /* 10: Twice per thread */
EXIT:
return NULL;
}
static int TestCase(void)
{
int policy;
pthread_attr_t attr;
pthread_t newTh;
struct sched_param schedParam = { 0 };
int ret;
ret = pthread_mutex_init(&g_pthread_mutex, NULL);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
ret = pthread_cond_init(&g_pthread_cond, NULL);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
ret = pthread_attr_init(&attr);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
ret = pthread_getschedparam(pthread_self(), &policy, &schedParam);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
schedParam.sched_priority -= 1;
ret = pthread_attr_setschedparam(&attr, &schedParam);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
ret = pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
ret = pthread_create(&newTh, &attr, pthread_f06, NULL);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
ret = pthread_join(newTh, NULL);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
return 0;
}
void ItTestPthreadCond003(void)
{
TEST_ADD_CASE("IT_POSIX_PTHREAD_COND_003", TestCase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
}
/*
* 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 pthread_cond_t g_pthread_cond;
static pthread_mutex_t g_pthread_mutex;
#define TEST_THREAD_COUNT 5
static void *pthread_cond_func002(void *arg)
{
int ret;
struct timespec ts;
g_testCount++;
ret = pthread_mutex_lock(&g_pthread_mutex);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
clock_gettime(CLOCK_REALTIME, &ts);
ts.tv_sec += 2; /* 2: wait 2 seconds */
ret = pthread_cond_timedwait(&g_pthread_cond, &g_pthread_mutex, &ts);
ICUNIT_GOTO_EQUAL(ret, ETIMEDOUT, ret, EXIT);
ret = pthread_mutex_unlock(&g_pthread_mutex);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
g_testCount++;
EXIT:
return NULL;
}
static VOID *pthread_f07(void *argument)
{
int policy;
int ret;
int i;
pthread_attr_t attr;
struct sched_param schedParam = { 0 };
pthread_t thread[TEST_THREAD_COUNT];
g_testCount = 0;
ret = pthread_attr_init(&attr);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
ret = pthread_getschedparam(pthread_self(), &policy, &schedParam);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
schedParam.sched_priority -= 1;
ret = pthread_attr_setschedparam(&attr, &schedParam);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
ret = pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
for (i = 0; i < TEST_THREAD_COUNT; i++) {
ret = pthread_create(&thread[i], &attr, pthread_cond_func002, NULL);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
}
sleep(1);
ICUNIT_GOTO_EQUAL(g_testCount, 5, g_testCount, EXIT); /* 5: Five threads */
for (i = 0; i < TEST_THREAD_COUNT; i++) {
ret = pthread_join(thread[i], NULL);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
}
ICUNIT_GOTO_EQUAL(g_testCount, 10, g_testCount, EXIT); /* 10: Twice per thread */
EXIT:
return NULL;
}
static int TestCase(void)
{
int policy;
pthread_attr_t attr;
pthread_t newTh;
struct sched_param schedParam = { 0 };
int ret;
ret = pthread_mutex_init(&g_pthread_mutex, NULL);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
ret = pthread_cond_init(&g_pthread_cond, NULL);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
ret = pthread_attr_init(&attr);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
ret = pthread_getschedparam(pthread_self(), &policy, &schedParam);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
schedParam.sched_priority -= 1;
ret = pthread_attr_setschedparam(&attr, &schedParam);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
ret = pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
ret = pthread_create(&newTh, &attr, pthread_f07, NULL);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
ret = pthread_join(newTh, NULL);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
return 0;
}
void ItTestPthreadCond004(void)
{
TEST_ADD_CASE("IT_POSIX_PTHREAD_COND_004", TestCase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
}
...@@ -53,10 +53,6 @@ static UINT32 Testcase(VOID) ...@@ -53,10 +53,6 @@ static UINT32 Testcase(VOID)
#ifdef LOSCFG_USER_TEST_SMP #ifdef LOSCFG_USER_TEST_SMP
sleep(1); sleep(1);
#endif #endif
ret = pthread_join(g_th, NULL);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, assert the exit code.
return 0; return 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册