diff --git a/testsuites/unittest/process/rwlock/BUILD.gn b/testsuites/unittest/process/rwlock/BUILD.gn index aedc928f..4ed9394f 100644 --- a/testsuites/unittest/process/rwlock/BUILD.gn +++ b/testsuites/unittest/process/rwlock/BUILD.gn @@ -43,10 +43,10 @@ sources_entry = [ sources_smoke = [ "smoke/pthread_rwlock_test_001.cpp", - "smoke/pthread_rwlock_test_002.cpp", ] sources_full = [ + "full/pthread_rwlock_test_002.cpp", ] if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_LOW) { diff --git a/testsuites/unittest/process/rwlock/smoke/pthread_rwlock_test_002.cpp b/testsuites/unittest/process/rwlock/full/pthread_rwlock_test_002.cpp similarity index 99% rename from testsuites/unittest/process/rwlock/smoke/pthread_rwlock_test_002.cpp rename to testsuites/unittest/process/rwlock/full/pthread_rwlock_test_002.cpp index 544748e5..075c2aa8 100644 --- a/testsuites/unittest/process/rwlock/smoke/pthread_rwlock_test_002.cpp +++ b/testsuites/unittest/process/rwlock/full/pthread_rwlock_test_002.cpp @@ -100,6 +100,7 @@ static void *ThreadReadFunc(void *a) ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT); while (loop > 0) { + SLEEP_AND_YIELD(1); ret = pthread_rwlock_rdlock(&g_rwlockLock); ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT); g_isReading[threadCount] = 1; @@ -139,6 +140,7 @@ static void *ThreadWriteFunc1(void *a) ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT); while (CheckReadThreadExit()) { + SLEEP_AND_YIELD(1); ret = pthread_rwlock_wrlock(&g_rwlockLock); ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT); @@ -180,6 +182,7 @@ static void *ThreadWriteFunc(void *a) int threadCount = *((int *)a); while (CheckReadThreadExit() || CheckWriteThreadExit()) { + SLEEP_AND_YIELD(1); ret = pthread_rwlock_wrlock(&g_rwlockLock); ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT); @@ -247,20 +250,20 @@ static int PthreadRwlockTest(void) count = 1; while (count < WRITE_THREAD_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_isWriteExit[count] = 0; + ret = pthread_create(&newPthread, &a, ThreadWriteFunc1, &g_writePar[count]); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); count++; } count = 0; while (count < READ_THREAD_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_isReadExit[count] = 0; + ret = pthread_create(&newPthread, &a, ThreadReadFunc, &g_readPar[count]); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); count++; } diff --git a/testsuites/unittest/process/rwlock/process_rwlock_test.cpp b/testsuites/unittest/process/rwlock/process_rwlock_test.cpp index b4a6753d..2a0f5f7d 100644 --- a/testsuites/unittest/process/rwlock/process_rwlock_test.cpp +++ b/testsuites/unittest/process/rwlock/process_rwlock_test.cpp @@ -52,7 +52,9 @@ HWTEST_F(ProcessRwlockTest, ItTestPthreadRwlock001, TestSize.Level0) { ItTestPthreadRwlock001(); } +#endif +#if defined(LOSCFG_USER_TEST_FULL) /* * * @tc.name: it_test_pthread_rwlock_002 * @tc.desc: function for ProcessRwlockTest