test:修复rwlock用例在循环处会卡死的问题
【背景】修复rwlock门禁用例多次测试出现的程序会卡死在某一个地方的问题,经查找程序会卡在循环里面 【修改方案】 1.经测试,发现用例在创建线程后对退出标志位做了初始化,但卡在循环中不动的原因是在创建线程后立刻发生了调度,没有来得及初始化,则发生了错误,故会出现卡在循环中的情况。 而且,由于卡在循环中时线程是同一优先级,可能不会发生调度,故在循环里面加了一句可以调度的语句,防止在一处循环卡的太久。 2.将该用例挪出门禁,待稳定后恢复。 【影响】 对其它用例无影响。 re #I3VUX4 Signed-off-by:vcbchang<vcbchang@qq.com> Change-Id: Ie0f908001f59bfc832c2519104aa2e3188206910 Signed-off-by: vcbchang <vcbchang@qq.com>
This commit is contained in:
parent
a760c268f4
commit
f793dc1097
|
@ -43,10 +43,10 @@ sources_entry = [
|
||||||
|
|
||||||
sources_smoke = [
|
sources_smoke = [
|
||||||
"smoke/pthread_rwlock_test_001.cpp",
|
"smoke/pthread_rwlock_test_001.cpp",
|
||||||
"smoke/pthread_rwlock_test_002.cpp",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
sources_full = [
|
sources_full = [
|
||||||
|
"full/pthread_rwlock_test_002.cpp",
|
||||||
]
|
]
|
||||||
|
|
||||||
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_LOW) {
|
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_LOW) {
|
||||||
|
|
|
@ -100,6 +100,7 @@ static void *ThreadReadFunc(void *a)
|
||||||
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||||
|
|
||||||
while (loop > 0) {
|
while (loop > 0) {
|
||||||
|
SLEEP_AND_YIELD(1);
|
||||||
ret = pthread_rwlock_rdlock(&g_rwlockLock);
|
ret = pthread_rwlock_rdlock(&g_rwlockLock);
|
||||||
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||||
g_isReading[threadCount] = 1;
|
g_isReading[threadCount] = 1;
|
||||||
|
@ -139,6 +140,7 @@ static void *ThreadWriteFunc1(void *a)
|
||||||
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||||
|
|
||||||
while (CheckReadThreadExit()) {
|
while (CheckReadThreadExit()) {
|
||||||
|
SLEEP_AND_YIELD(1);
|
||||||
ret = pthread_rwlock_wrlock(&g_rwlockLock);
|
ret = pthread_rwlock_wrlock(&g_rwlockLock);
|
||||||
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||||
|
|
||||||
|
@ -180,6 +182,7 @@ static void *ThreadWriteFunc(void *a)
|
||||||
int threadCount = *((int *)a);
|
int threadCount = *((int *)a);
|
||||||
|
|
||||||
while (CheckReadThreadExit() || CheckWriteThreadExit()) {
|
while (CheckReadThreadExit() || CheckWriteThreadExit()) {
|
||||||
|
SLEEP_AND_YIELD(1);
|
||||||
ret = pthread_rwlock_wrlock(&g_rwlockLock);
|
ret = pthread_rwlock_wrlock(&g_rwlockLock);
|
||||||
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||||
|
|
||||||
|
@ -247,20 +250,20 @@ static int PthreadRwlockTest(void)
|
||||||
count = 1;
|
count = 1;
|
||||||
while (count < WRITE_THREAD_COUNT) {
|
while (count < WRITE_THREAD_COUNT) {
|
||||||
g_writePar[count] = count;
|
g_writePar[count] = count;
|
||||||
ret = pthread_create(&newPthread, &a, ThreadWriteFunc1, &g_writePar[count]);
|
|
||||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
|
||||||
g_isWriting[count] = 0;
|
g_isWriting[count] = 0;
|
||||||
g_isWriteExit[count] = 0;
|
g_isWriteExit[count] = 0;
|
||||||
|
ret = pthread_create(&newPthread, &a, ThreadWriteFunc1, &g_writePar[count]);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
count = 0;
|
count = 0;
|
||||||
while (count < READ_THREAD_COUNT) {
|
while (count < READ_THREAD_COUNT) {
|
||||||
g_readPar[count] = count;
|
g_readPar[count] = count;
|
||||||
ret = pthread_create(&newPthread, &a, ThreadReadFunc, &g_readPar[count]);
|
|
||||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
|
||||||
g_isReading[count] = 0;
|
g_isReading[count] = 0;
|
||||||
g_isReadExit[count] = 0;
|
g_isReadExit[count] = 0;
|
||||||
|
ret = pthread_create(&newPthread, &a, ThreadReadFunc, &g_readPar[count]);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,9 @@ HWTEST_F(ProcessRwlockTest, ItTestPthreadRwlock001, TestSize.Level0)
|
||||||
{
|
{
|
||||||
ItTestPthreadRwlock001();
|
ItTestPthreadRwlock001();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(LOSCFG_USER_TEST_FULL)
|
||||||
/* *
|
/* *
|
||||||
* @tc.name: it_test_pthread_rwlock_002
|
* @tc.name: it_test_pthread_rwlock_002
|
||||||
* @tc.desc: function for ProcessRwlockTest
|
* @tc.desc: function for ProcessRwlockTest
|
||||||
|
|
Loading…
Reference in New Issue